1 | |
package org.kuali.student.r2.common.entity; |
2 | |
|
3 | |
import javax.persistence.Column; |
4 | |
import javax.persistence.MappedSuperclass; |
5 | |
import javax.persistence.Table; |
6 | |
import javax.persistence.UniqueConstraint; |
7 | |
|
8 | |
import org.kuali.student.common.entity.KSEntityConstants; |
9 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
10 | |
import org.kuali.student.r2.common.infc.Attribute; |
11 | |
|
12 | |
@MappedSuperclass |
13 | |
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"ATTR_KEY", "OWNER_ID"})}) |
14 | |
public abstract class BaseAttributeEntityNew<T> extends BaseEntity { |
15 | |
|
16 | |
@Column(name = "ATTR_KEY") |
17 | |
private String key; |
18 | |
|
19 | |
@Column(name = "ATTR_VALUE", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
20 | |
private String value; |
21 | |
|
22 | 0 | public BaseAttributeEntityNew() {} |
23 | |
|
24 | 0 | public BaseAttributeEntityNew(String key, String value) { |
25 | 0 | this.key = key; |
26 | 0 | this.value = value; |
27 | 0 | } |
28 | |
|
29 | 0 | public BaseAttributeEntityNew(Attribute att) { |
30 | 0 | this.setId(att.getId()); |
31 | |
|
32 | 0 | this.fromDto(att); |
33 | 0 | } |
34 | |
|
35 | |
public String getKey() { |
36 | 0 | return key; |
37 | |
} |
38 | |
|
39 | |
public void setKey(String key) { |
40 | 0 | this.key = key; |
41 | 0 | } |
42 | |
|
43 | |
public String getValue() { |
44 | 0 | return value; |
45 | |
} |
46 | |
|
47 | |
public void setValue(String value) { |
48 | 0 | this.value = value; |
49 | 0 | } |
50 | |
|
51 | |
public abstract void setOwner(T owner); |
52 | |
|
53 | |
public abstract T getOwner(); |
54 | |
|
55 | |
public void fromDto(Attribute info) { |
56 | |
|
57 | 0 | this.setKey(info.getKey()); |
58 | 0 | this.setValue(info.getValue()); |
59 | |
|
60 | 0 | } |
61 | |
|
62 | |
public AttributeInfo toDto() { |
63 | 0 | AttributeInfo attributeInfo = new AttributeInfo(); |
64 | 0 | attributeInfo.setId(this.getId()); |
65 | 0 | attributeInfo.setKey(this.getKey()); |
66 | 0 | attributeInfo.setValue(this.getValue()); |
67 | 0 | return attributeInfo; |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public String toString() { |
72 | 0 | StringBuilder builder = new StringBuilder(); |
73 | 0 | builder.append("BaseAttributeEntityNew [id="); |
74 | 0 | builder.append(getId()); |
75 | 0 | builder.append(", key="); |
76 | 0 | builder.append(key); |
77 | 0 | builder.append(", value="); |
78 | 0 | builder.append(value); |
79 | 0 | builder.append("]"); |
80 | 0 | return builder.toString(); |
81 | |
} |
82 | |
|
83 | |
|
84 | |
|
85 | |
} |