| 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"})}) |
| 14 | |
public abstract class BaseAttributeEntity<T extends AttributeOwner<?>> 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 BaseAttributeEntity() {} |
| 23 | |
|
| 24 | 0 | public BaseAttributeEntity(String key, String value) { |
| 25 | 0 | this.key = key; |
| 26 | 0 | this.value = value; |
| 27 | 0 | } |
| 28 | |
|
| 29 | 0 | public BaseAttributeEntity(Attribute att) { |
| 30 | 0 | this.setId(att.getId()); |
| 31 | 0 | this.key = att.getKey(); |
| 32 | 0 | this.value = att.getValue(); |
| 33 | |
|
| 34 | 0 | } |
| 35 | |
|
| 36 | |
public String getKey() { |
| 37 | 0 | return key; |
| 38 | |
} |
| 39 | |
|
| 40 | |
public void setKey(String key) { |
| 41 | 0 | this.key = key; |
| 42 | 0 | } |
| 43 | |
|
| 44 | |
public String getValue() { |
| 45 | 0 | return value; |
| 46 | |
} |
| 47 | |
|
| 48 | |
public void setValue(String value) { |
| 49 | 0 | this.value = value; |
| 50 | 0 | } |
| 51 | |
|
| 52 | |
public abstract void setOwner(T owner); |
| 53 | |
|
| 54 | |
public abstract T getOwner(); |
| 55 | |
|
| 56 | |
public AttributeInfo toDto() { |
| 57 | 0 | AttributeInfo attributeInfo = new AttributeInfo(); |
| 58 | 0 | attributeInfo.setId(this.getId()); |
| 59 | 0 | attributeInfo.setKey(this.getKey()); |
| 60 | 0 | attributeInfo.setValue(this.getValue()); |
| 61 | 0 | return attributeInfo; |
| 62 | |
} |
| 63 | |
|
| 64 | |
} |