| 1 | |
package org.kuali.student.enrollment.lpr.model; |
| 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.Entity; |
| 9 | |
import javax.persistence.FetchType; |
| 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.common.infc.Attribute; |
| 18 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo; |
| 19 | |
import org.kuali.student.enrollment.lpr.infc.LuiPersonRelation; |
| 20 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
| 21 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
@Entity |
| 27 | |
@Table(name = "KSLP_LPR") |
| 28 | |
public class LuiPersonRelationEntity extends MetaEntity implements AttributeOwner<LuiPersonRelationAttributeEntity> { |
| 29 | |
|
| 30 | |
private String personId; |
| 31 | |
|
| 32 | |
private String luiId; |
| 33 | |
|
| 34 | |
@Temporal(TemporalType.TIMESTAMP) |
| 35 | |
private Date effectiveDate; |
| 36 | |
|
| 37 | |
@Temporal(TemporalType.TIMESTAMP) |
| 38 | |
private Date expirationDate; |
| 39 | |
|
| 40 | |
@ManyToOne(cascade = CascadeType.ALL) |
| 41 | |
@JoinColumn(name = "RELATION_TYPE_ID") |
| 42 | |
private LuiPersonRelationTypeEntity personRelationType; |
| 43 | |
|
| 44 | |
@ManyToOne(cascade = CascadeType.ALL) |
| 45 | |
@JoinColumn(name = "RELATION_STATE_ID") |
| 46 | |
private LuiPersonRelationStateEntity personRelationState; |
| 47 | |
|
| 48 | |
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER) |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
private List<LuiPersonRelationAttributeEntity> attributes; |
| 54 | |
|
| 55 | 0 | public LuiPersonRelationEntity() { |
| 56 | 0 | } |
| 57 | |
|
| 58 | 0 | public LuiPersonRelationEntity(LuiPersonRelation dto) { |
| 59 | |
|
| 60 | 0 | this.setEffectiveDate(dto.getEffectiveDate()); |
| 61 | 0 | this.setExpirationDate(dto.getExpirationDate()); |
| 62 | 0 | this.setId(dto.getId()); |
| 63 | 0 | this.setLuiId(dto.getLuiId()); |
| 64 | 0 | this.setPersonId(dto.getPersonId()); |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | 0 | this.setAttributes(new ArrayList<LuiPersonRelationAttributeEntity>()); |
| 70 | 0 | if (null != dto.getAttributes()) { |
| 71 | 0 | for (Attribute att : dto.getAttributes()) { |
| 72 | 0 | this.getAttributes().add(new LuiPersonRelationAttributeEntity(att)); |
| 73 | |
} |
| 74 | |
} |
| 75 | 0 | } |
| 76 | |
|
| 77 | |
public String getPersonId() { |
| 78 | 0 | return personId; |
| 79 | |
} |
| 80 | |
|
| 81 | |
public void setPersonId(String personId) { |
| 82 | 0 | this.personId = personId; |
| 83 | 0 | } |
| 84 | |
|
| 85 | |
public String getLuiId() { |
| 86 | 0 | return luiId; |
| 87 | |
} |
| 88 | |
|
| 89 | |
public void setLuiId(String luiId) { |
| 90 | 0 | this.luiId = luiId; |
| 91 | 0 | } |
| 92 | |
|
| 93 | |
public Date getEffectiveDate() { |
| 94 | 0 | return effectiveDate; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public void setEffectiveDate(Date effectiveDate) { |
| 98 | 0 | this.effectiveDate = effectiveDate; |
| 99 | 0 | } |
| 100 | |
|
| 101 | |
public Date getExpirationDate() { |
| 102 | 0 | return expirationDate; |
| 103 | |
} |
| 104 | |
|
| 105 | |
public void setExpirationDate(Date expirationDate) { |
| 106 | 0 | this.expirationDate = expirationDate; |
| 107 | 0 | } |
| 108 | |
|
| 109 | |
public LuiPersonRelationTypeEntity getPersonRelationType() { |
| 110 | 0 | return personRelationType; |
| 111 | |
} |
| 112 | |
|
| 113 | |
public void setPersonRelationType(LuiPersonRelationTypeEntity personRelationType) { |
| 114 | 0 | this.personRelationType = personRelationType; |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
public LuiPersonRelationStateEntity getPersonRelationState() { |
| 118 | 0 | return personRelationState; |
| 119 | |
} |
| 120 | |
|
| 121 | |
public void setPersonRelationState(LuiPersonRelationStateEntity personRelationState) { |
| 122 | 0 | this.personRelationState = personRelationState; |
| 123 | 0 | } |
| 124 | |
|
| 125 | |
@Override |
| 126 | |
public List<LuiPersonRelationAttributeEntity> getAttributes() { |
| 127 | 0 | return attributes; |
| 128 | |
} |
| 129 | |
|
| 130 | |
@Override |
| 131 | |
public void setAttributes(List<LuiPersonRelationAttributeEntity> attributes) { |
| 132 | 0 | this.attributes = attributes; |
| 133 | 0 | } |
| 134 | |
|
| 135 | |
public LuiPersonRelationInfo toDto() { |
| 136 | 0 | LuiPersonRelationInfo.Builder builder = new LuiPersonRelationInfo.Builder(); |
| 137 | 0 | builder.setId(getId()); |
| 138 | 0 | builder.setLuiId(luiId); |
| 139 | 0 | builder.setPersonId(personId); |
| 140 | 0 | builder.setEffectiveDate(effectiveDate); |
| 141 | 0 | builder.setExpirationDate(expirationDate); |
| 142 | 0 | builder.setTypeKey(personRelationType.getId()); |
| 143 | 0 | builder.setStateKey(personRelationState.getId()); |
| 144 | 0 | builder.setMetaInfo(super.toDTO()); |
| 145 | 0 | List<Attribute> atts = new ArrayList<Attribute>(); |
| 146 | 0 | for (LuiPersonRelationAttributeEntity att : getAttributes()) { |
| 147 | 0 | Attribute attInfo = att.toDto(); |
| 148 | 0 | atts.add(attInfo); |
| 149 | 0 | } |
| 150 | 0 | builder.setAttributes(atts); |
| 151 | |
|
| 152 | 0 | LuiPersonRelationInfo info = builder.build(); |
| 153 | 0 | return info; |
| 154 | |
} |
| 155 | |
} |