1 | |
package org.kuali.student.enrollment.class1.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.Column; |
9 | |
import javax.persistence.Entity; |
10 | |
import javax.persistence.FetchType; |
11 | |
import javax.persistence.OneToMany; |
12 | |
import javax.persistence.Table; |
13 | |
import javax.persistence.Temporal; |
14 | |
import javax.persistence.TemporalType; |
15 | |
|
16 | |
import org.kuali.student.enrollment.lpr.dto.LprRosterEntryInfo; |
17 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
18 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
19 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
20 | |
import org.kuali.student.r2.common.infc.Attribute; |
21 | |
|
22 | |
@Entity |
23 | |
@Table(name = "KSEN_LPR_ROSTER_ENTRY") |
24 | |
public class LprRosterEntryEntity extends MetaEntity implements AttributeOwner<LprRosterEntryAttributeEntity> { |
25 | |
|
26 | |
@Column(name = "LPRROSTER_ID") |
27 | |
private String lprRosterId; |
28 | |
|
29 | |
@Column(name = "LPR_ID") |
30 | |
private String lprId; |
31 | |
|
32 | |
@Column(name = "POSITION") |
33 | |
private Integer position; |
34 | |
|
35 | |
@Temporal(TemporalType.TIMESTAMP) |
36 | |
private Date effectiveDate; |
37 | |
|
38 | |
@Temporal(TemporalType.TIMESTAMP) |
39 | |
private Date expirationDate; |
40 | |
|
41 | |
@Column(name = "RELATION_TYPE_ID") |
42 | |
private String lprEntryRelationType; |
43 | |
|
44 | |
@Column(name = "RELATION_STATE_ID") |
45 | |
private String lprEntryRelationState; |
46 | |
|
47 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", fetch = FetchType.EAGER) |
48 | |
private List<LprRosterEntryAttributeEntity> attributes; |
49 | |
|
50 | 0 | public LprRosterEntryEntity() {} |
51 | |
|
52 | 0 | public LprRosterEntryEntity(LprRosterEntryInfo dto) { |
53 | 0 | if (dto != null) { |
54 | 0 | this.setId(dto.getId()); |
55 | 0 | this.setLprId(dto.getLprId()); |
56 | 0 | this.setLprRosterId(dto.getLprRosterId()); |
57 | 0 | this.setExpirationDate(dto.getExpirationDate()); |
58 | 0 | this.setEffectiveDate(dto.getEffectiveDate()); |
59 | 0 | this.setPosition(dto.getPosition()); |
60 | 0 | if (dto.getStateKey() != null) { |
61 | 0 | this.setLprEntryRelationState(dto.getStateKey()); |
62 | |
} |
63 | 0 | this.setAttributes(new ArrayList<LprRosterEntryAttributeEntity>()); |
64 | 0 | if (null != dto.getAttributes()) { |
65 | 0 | for (Attribute att : dto.getAttributes()) { |
66 | 0 | LprRosterEntryAttributeEntity attEntity = new LprRosterEntryAttributeEntity(att); |
67 | 0 | this.getAttributes().add(attEntity); |
68 | 0 | } |
69 | |
} |
70 | |
} |
71 | 0 | } |
72 | |
|
73 | |
public Date getEffectiveDate() { |
74 | 0 | return effectiveDate; |
75 | |
} |
76 | |
|
77 | |
public void setEffectiveDate(Date effectiveDate) { |
78 | 0 | this.effectiveDate = effectiveDate; |
79 | 0 | } |
80 | |
|
81 | |
public Date getExpirationDate() { |
82 | 0 | return expirationDate; |
83 | |
} |
84 | |
|
85 | |
public void setExpirationDate(Date expirationDate) { |
86 | 0 | this.expirationDate = expirationDate; |
87 | 0 | } |
88 | |
|
89 | |
public String getLprId() { |
90 | 0 | return lprId; |
91 | |
} |
92 | |
|
93 | |
public void setLprId(String lprId) { |
94 | 0 | this.lprId = lprId; |
95 | 0 | } |
96 | |
|
97 | |
public String getLprRosterId() { |
98 | 0 | return lprRosterId; |
99 | |
} |
100 | |
|
101 | |
public void setLprRosterId(String lprRosterId) { |
102 | 0 | this.lprRosterId = lprRosterId; |
103 | 0 | } |
104 | |
|
105 | |
public Integer getPosition() { |
106 | 0 | return position; |
107 | |
} |
108 | |
|
109 | |
public void setPosition(Integer position) { |
110 | 0 | this.position = position; |
111 | 0 | } |
112 | |
|
113 | |
@Override |
114 | |
public List<LprRosterEntryAttributeEntity> getAttributes() { |
115 | 0 | return attributes; |
116 | |
} |
117 | |
|
118 | |
@Override |
119 | |
public void setAttributes(List<LprRosterEntryAttributeEntity> attributes) { |
120 | 0 | this.attributes = attributes; |
121 | 0 | } |
122 | |
|
123 | |
public String getLprEntryRelationState() { |
124 | 0 | return lprEntryRelationState; |
125 | |
} |
126 | |
|
127 | |
public void setLprEntryRelationState(String lprEntryRelationState) { |
128 | 0 | this.lprEntryRelationState = lprEntryRelationState; |
129 | 0 | } |
130 | |
|
131 | |
public String getLprEntryRelationType() { |
132 | 0 | return lprEntryRelationType; |
133 | |
} |
134 | |
|
135 | |
public void setLprEntryRelationType(String lprEntryRelationType) { |
136 | 0 | this.lprEntryRelationType = lprEntryRelationType; |
137 | 0 | } |
138 | |
|
139 | |
public LprRosterEntryInfo toDto() { |
140 | 0 | LprRosterEntryInfo info = new LprRosterEntryInfo(); |
141 | 0 | info.setId(this.getId()); |
142 | 0 | info.setEffectiveDate(getEffectiveDate()); |
143 | 0 | info.setExpirationDate(getExpirationDate()); |
144 | 0 | info.setLprId(getLprId()); |
145 | 0 | info.setLprRosterId(getLprRosterId()); |
146 | 0 | info.setPosition(getPosition()); |
147 | |
|
148 | 0 | if (getLprEntryRelationState() != null) { |
149 | 0 | info.setStateKey(getLprEntryRelationState()); |
150 | |
} |
151 | 0 | if (getLprEntryRelationType() != null) { |
152 | 0 | info.setTypeKey(getLprEntryRelationType()); |
153 | |
} |
154 | |
|
155 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
156 | 0 | for (LprRosterEntryAttributeEntity att : getAttributes()) { |
157 | 0 | AttributeInfo attInfo = att.toDto(); |
158 | 0 | atts.add(attInfo); |
159 | 0 | } |
160 | 0 | info.setAttributes(atts); |
161 | 0 | info.setMeta(super.toDTO()); |
162 | |
|
163 | 0 | return info; |
164 | |
} |
165 | |
|
166 | |
} |