1 | |
package org.kuali.student.enrollment.class1.roster.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.roster.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 { |
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 | |
public List<LprRosterEntryAttributeEntity> getAttributes() { |
114 | 0 | return attributes; |
115 | |
} |
116 | |
|
117 | |
public void setAttributes(List<LprRosterEntryAttributeEntity> attributes) { |
118 | 0 | this.attributes = attributes; |
119 | 0 | } |
120 | |
|
121 | |
public String getLprEntryRelationState() { |
122 | 0 | return lprEntryRelationState; |
123 | |
} |
124 | |
|
125 | |
public void setLprEntryRelationState(String lprEntryRelationState) { |
126 | 0 | this.lprEntryRelationState = lprEntryRelationState; |
127 | 0 | } |
128 | |
|
129 | |
public String getLprEntryRelationType() { |
130 | 0 | return lprEntryRelationType; |
131 | |
} |
132 | |
|
133 | |
public void setLprEntryRelationType(String lprEntryRelationType) { |
134 | 0 | this.lprEntryRelationType = lprEntryRelationType; |
135 | 0 | } |
136 | |
|
137 | |
public LprRosterEntryInfo toDto() { |
138 | 0 | LprRosterEntryInfo info = new LprRosterEntryInfo(); |
139 | 0 | info.setId(this.getId()); |
140 | 0 | info.setEffectiveDate(getEffectiveDate()); |
141 | 0 | info.setExpirationDate(getExpirationDate()); |
142 | 0 | info.setLprId(getLprId()); |
143 | 0 | info.setLprRosterId(getLprRosterId()); |
144 | 0 | info.setPosition(getPosition()); |
145 | |
|
146 | 0 | if (getLprEntryRelationState() != null) { |
147 | 0 | info.setStateKey(getLprEntryRelationState()); |
148 | |
} |
149 | 0 | if (getLprEntryRelationType() != null) { |
150 | 0 | info.setTypeKey(getLprEntryRelationType()); |
151 | |
} |
152 | |
|
153 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
154 | 0 | for (LprRosterEntryAttributeEntity att : getAttributes()) { |
155 | 0 | AttributeInfo attInfo = att.toDto(); |
156 | 0 | atts.add(attInfo); |
157 | 0 | } |
158 | 0 | info.setAttributes(atts); |
159 | 0 | info.setMeta(super.toDTO()); |
160 | |
|
161 | 0 | return info; |
162 | |
} |
163 | |
|
164 | |
} |