| 1 | |
package org.kuali.student.r2.common.entity; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.Date; |
| 5 | |
import java.util.List; |
| 6 | |
|
| 7 | |
import javax.persistence.CascadeType; |
| 8 | |
import javax.persistence.Column; |
| 9 | |
import javax.persistence.Entity; |
| 10 | |
import javax.persistence.JoinColumn; |
| 11 | |
import javax.persistence.ManyToOne; |
| 12 | |
import javax.persistence.OneToMany; |
| 13 | |
import javax.persistence.Table; |
| 14 | |
import javax.persistence.Temporal; |
| 15 | |
import javax.persistence.TemporalType; |
| 16 | |
|
| 17 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 18 | |
import org.kuali.student.r2.common.dto.TypeTypeRelationInfo; |
| 19 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 20 | |
import org.kuali.student.r2.common.infc.TypeTypeRelation; |
| 21 | |
import org.kuali.student.r2.core.class1.atp.model.AtpRichTextEntity; |
| 22 | |
|
| 23 | |
@Entity |
| 24 | |
@Table(name = "KSEN_TYPETYPE_RELTN") |
| 25 | |
public class TypeTypeRelationEntity extends MetaEntity implements AttributeOwner<TypeTypeRelationAttributeEntity> { |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
@Column(name="OWNER_TYPE_ID") |
| 31 | |
private String ownerTypeId; |
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
@Column(name="RELATED_TYPE_ID") |
| 37 | |
private String relatedTypeId; |
| 38 | |
|
| 39 | |
@Column(name="TYPETYPE_RELATION_TYPE") |
| 40 | |
private String type; |
| 41 | |
|
| 42 | |
@Column(name = "RANK") |
| 43 | |
private Integer rank; |
| 44 | |
|
| 45 | |
@Column(name = "NAME") |
| 46 | |
private String name; |
| 47 | |
|
| 48 | |
@ManyToOne(cascade = CascadeType.ALL) |
| 49 | |
@JoinColumn(name = "RT_DESCR_ID") |
| 50 | |
private AtpRichTextEntity descr; |
| 51 | |
|
| 52 | |
@Temporal(TemporalType.TIMESTAMP) |
| 53 | |
@Column(name = "EFF_DT") |
| 54 | |
private Date effectiveDate; |
| 55 | |
|
| 56 | |
@Temporal(TemporalType.TIMESTAMP) |
| 57 | |
@Column(name = "EXPIR_DT") |
| 58 | |
private Date expirationDate; |
| 59 | |
|
| 60 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 61 | |
private List<TypeTypeRelationAttributeEntity> attributes; |
| 62 | |
|
| 63 | 0 | public TypeTypeRelationEntity() {} |
| 64 | |
|
| 65 | |
public TypeTypeRelationEntity(TypeTypeRelation typeTypeRel){ |
| 66 | 0 | super(typeTypeRel); |
| 67 | 0 | this.setId(typeTypeRel.getKey()); |
| 68 | 0 | this.setEffectiveDate(typeTypeRel.getEffectiveDate()); |
| 69 | 0 | this.setExpirationDate(typeTypeRel.getExpirationDate()); |
| 70 | 0 | this.setAttributes(new ArrayList<TypeTypeRelationAttributeEntity>()); |
| 71 | 0 | if (null != typeTypeRel.getAttributes()) { |
| 72 | 0 | for (Attribute att : typeTypeRel.getAttributes()) { |
| 73 | 0 | this.getAttributes().add(new TypeTypeRelationAttributeEntity(att)); |
| 74 | |
} |
| 75 | |
} |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
public void setOwnerTypeId(String ownerTypeId) { |
| 107 | 0 | this.ownerTypeId = ownerTypeId; |
| 108 | 0 | } |
| 109 | |
|
| 110 | |
public String getOwnerTypeId() { |
| 111 | 0 | return ownerTypeId; |
| 112 | |
} |
| 113 | |
|
| 114 | |
public void setRelatedTypeId(String relatedTypeId) { |
| 115 | 0 | this.relatedTypeId = relatedTypeId; |
| 116 | 0 | } |
| 117 | |
|
| 118 | |
public String getRelatedTypeId() { |
| 119 | 0 | return relatedTypeId; |
| 120 | |
} |
| 121 | |
|
| 122 | |
public void setType(String type) { |
| 123 | 0 | this.type = type; |
| 124 | 0 | } |
| 125 | |
|
| 126 | |
public String getType() { |
| 127 | 0 | return type; |
| 128 | |
} |
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
public Date getEffectiveDate() { |
| 134 | 0 | return effectiveDate; |
| 135 | |
} |
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
public void setEffectiveDate(Date effectiveDate) { |
| 141 | 0 | this.effectiveDate = effectiveDate; |
| 142 | 0 | } |
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
public Date getExpirationDate() { |
| 148 | 0 | return expirationDate; |
| 149 | |
} |
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
public void setExpirationDate(Date expirationDate) { |
| 155 | 0 | this.expirationDate = expirationDate; |
| 156 | 0 | } |
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
public Integer getRank() { |
| 162 | 0 | return rank; |
| 163 | |
} |
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
public void setRank(Integer rank) { |
| 169 | 0 | this.rank = rank; |
| 170 | 0 | } |
| 171 | |
|
| 172 | |
public void setName(String name) { |
| 173 | 0 | this.name = name; |
| 174 | 0 | } |
| 175 | |
|
| 176 | |
public String getName() { |
| 177 | 0 | return name; |
| 178 | |
} |
| 179 | |
|
| 180 | |
public void setDescr(AtpRichTextEntity descr) { |
| 181 | 0 | this.descr = descr; |
| 182 | 0 | } |
| 183 | |
|
| 184 | |
public AtpRichTextEntity getDescr() { |
| 185 | 0 | return descr; |
| 186 | |
} |
| 187 | |
|
| 188 | |
public void setAttributes(List<TypeTypeRelationAttributeEntity> attributes) { |
| 189 | 0 | this.attributes = attributes; |
| 190 | 0 | } |
| 191 | |
|
| 192 | |
public List<TypeTypeRelationAttributeEntity> getAttributes() { |
| 193 | 0 | return attributes; |
| 194 | |
} |
| 195 | |
|
| 196 | |
public TypeTypeRelationInfo toDto() { |
| 197 | 0 | TypeTypeRelationInfo typeTypeRel = new TypeTypeRelationInfo(); |
| 198 | |
|
| 199 | 0 | typeTypeRel.setDescr(null != descr ? descr.toDto() : null); |
| 200 | 0 | typeTypeRel.setRank(rank); |
| 201 | 0 | typeTypeRel.setEffectiveDate(new Date(effectiveDate.getTime())); |
| 202 | 0 | typeTypeRel.setExpirationDate(new Date(expirationDate.getTime())); |
| 203 | 0 | typeTypeRel.setKey(getId()); |
| 204 | 0 | typeTypeRel.setName(name); |
| 205 | 0 | typeTypeRel.setOwnerTypeKey(ownerTypeId); |
| 206 | 0 | typeTypeRel.setRelatedTypeKey(relatedTypeId); |
| 207 | 0 | typeTypeRel.setMeta(super.toDTO()); |
| 208 | |
|
| 209 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
| 210 | 0 | for (TypeTypeRelationAttributeEntity att : getAttributes()) { |
| 211 | 0 | AttributeInfo attInfo = att.toDto(); |
| 212 | 0 | atts.add(attInfo); |
| 213 | 0 | } |
| 214 | 0 | typeTypeRel.setAttributes(atts); |
| 215 | |
|
| 216 | 0 | return typeTypeRel; |
| 217 | |
} |
| 218 | |
} |