1 | |
package org.kuali.student.enrollment.class1.lpr.model; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import javax.persistence.CascadeType; |
7 | |
import javax.persistence.Column; |
8 | |
import javax.persistence.Entity; |
9 | |
import javax.persistence.JoinColumn; |
10 | |
import javax.persistence.ManyToOne; |
11 | |
import javax.persistence.OneToMany; |
12 | |
import javax.persistence.Table; |
13 | |
|
14 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionItemInfo; |
15 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionItemResultInfo; |
16 | |
import org.kuali.student.enrollment.lpr.infc.LprTransactionItem; |
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_TRANS_ITEMS") |
24 | |
public class LprTransactionItemEntity extends MetaEntity implements AttributeOwner<LprTransItemAttributeEntity> { |
25 | |
|
26 | |
@Column(name = "PERSON_ID") |
27 | |
private String personId; |
28 | |
|
29 | |
@Column(name = "NEW_LUI_ID") |
30 | |
private String newLuiId; |
31 | |
|
32 | |
@Column(name = "EXIST_LUI_ID") |
33 | |
private String existingLuiId; |
34 | |
|
35 | |
@Column(name = "RESULTING_LPR_ID") |
36 | |
private String resultingLprId; |
37 | |
|
38 | |
@Column(name = "STATUS") |
39 | |
private String status; |
40 | |
|
41 | |
@Column(name = "GROUP_ID") |
42 | |
private String groupId; |
43 | |
|
44 | |
@ManyToOne(cascade = CascadeType.ALL) |
45 | |
@JoinColumn(name = "RT_DESCR_ID") |
46 | |
private LprRichTextEntity descr; |
47 | |
|
48 | |
@Column(name = "TYPE_ID") |
49 | |
private String lprTransactionItemType; |
50 | |
|
51 | |
@Column(name = "STATE_ID") |
52 | |
private String lprTransactionItemState; |
53 | |
|
54 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
55 | |
private List<LprTransItemAttributeEntity> attributes; |
56 | |
|
57 | 0 | public LprTransactionItemEntity() {} |
58 | |
|
59 | |
public LprTransactionItemEntity(LprTransactionItem lprTransactionItem) { |
60 | |
|
61 | 0 | super(lprTransactionItem); |
62 | 0 | if (lprTransactionItem != null) { |
63 | 0 | this.setId(lprTransactionItem.getId()); |
64 | 0 | this.setNewLuiId(lprTransactionItem.getNewLuiId()); |
65 | 0 | this.setExistingLuiId(lprTransactionItem.getExistingLuiId()); |
66 | 0 | this.setPersonId(lprTransactionItem.getPersonId()); |
67 | 0 | this.setGroupId(lprTransactionItem.getGroupId()); |
68 | 0 | this.setLprTransactionItemState(lprTransactionItem.getStateKey()); |
69 | 0 | this.setAttributes(new ArrayList<LprTransItemAttributeEntity>()); |
70 | 0 | if (null != lprTransactionItem.getAttributes()) { |
71 | 0 | for (Attribute att : lprTransactionItem.getAttributes()) { |
72 | 0 | LprTransItemAttributeEntity attEntity = new LprTransItemAttributeEntity(att); |
73 | 0 | this.getAttributes().add(attEntity); |
74 | 0 | } |
75 | |
} |
76 | 0 | if (lprTransactionItem.getLprTransactionItemResult() != null) { |
77 | 0 | this.setResultingLprId(lprTransactionItem.getLprTransactionItemResult().getResultingLprId()); |
78 | 0 | this.setStatus(lprTransactionItem.getLprTransactionItemResult().getStatus()); |
79 | |
} |
80 | |
} |
81 | |
|
82 | 0 | } |
83 | |
|
84 | |
public LprTransactionItemInfo toDto() { |
85 | |
|
86 | 0 | LprTransactionItemInfo lprTransItemInfo = new LprTransactionItemInfo(); |
87 | 0 | lprTransItemInfo.setId(getId()); |
88 | |
|
89 | 0 | lprTransItemInfo.setTypeKey(this.getLprTransactionItemType()); |
90 | 0 | lprTransItemInfo.setStateKey(this.getLprTransactionItemState()); |
91 | 0 | lprTransItemInfo.setExistingLuiId(this.getExistingLuiId()); |
92 | 0 | lprTransItemInfo.setNewLuiId(this.getNewLuiId()); |
93 | 0 | lprTransItemInfo.setPersonId(this.getPersonId()); |
94 | 0 | lprTransItemInfo.setMeta(super.toDTO()); |
95 | 0 | if (this.getDescr() != null) |
96 | 0 | lprTransItemInfo.setDescr(this.getDescr().toDto()); |
97 | 0 | if (getAttributes() != null) { |
98 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
99 | 0 | for (LprTransItemAttributeEntity att : getAttributes()) { |
100 | 0 | AttributeInfo attInfo = att.toDto(); |
101 | 0 | atts.add(attInfo); |
102 | 0 | } |
103 | 0 | lprTransItemInfo.setAttributes(atts); |
104 | |
} |
105 | |
|
106 | 0 | LprTransactionItemResultInfo lprItemResult = new LprTransactionItemResultInfo(); |
107 | 0 | lprItemResult.setResultingLprId(this.getResultingLprId()); |
108 | 0 | lprItemResult.setStatus(this.getStatus()); |
109 | 0 | lprTransItemInfo.setGroupId(this.getGroupId()); |
110 | 0 | lprTransItemInfo.setLprTransactionItemResult(lprItemResult); |
111 | 0 | return lprTransItemInfo; |
112 | |
|
113 | |
} |
114 | |
|
115 | |
public LprRichTextEntity getDescr() { |
116 | 0 | return descr; |
117 | |
} |
118 | |
|
119 | |
public void setDescr(LprRichTextEntity descr) { |
120 | 0 | this.descr = descr; |
121 | 0 | } |
122 | |
|
123 | |
public String getResultingLprId() { |
124 | 0 | return resultingLprId; |
125 | |
} |
126 | |
|
127 | |
public void setResultingLprId(String resultingLprId) { |
128 | 0 | this.resultingLprId = resultingLprId; |
129 | 0 | } |
130 | |
|
131 | |
public String getPersonId() { |
132 | 0 | return personId; |
133 | |
} |
134 | |
|
135 | |
public String getGroupId() { |
136 | 0 | return groupId; |
137 | |
} |
138 | |
|
139 | |
public void setGroupId(String groupId) { |
140 | 0 | this.groupId = groupId; |
141 | 0 | } |
142 | |
|
143 | |
public void setPersonId(String personId) { |
144 | 0 | this.personId = personId; |
145 | 0 | } |
146 | |
|
147 | |
public String getNewLuiId() { |
148 | 0 | return newLuiId; |
149 | |
} |
150 | |
|
151 | |
public String getStatus() { |
152 | 0 | return status; |
153 | |
} |
154 | |
|
155 | |
public void setStatus(String status) { |
156 | 0 | this.status = status; |
157 | 0 | } |
158 | |
|
159 | |
public void setNewLuiId(String newLuiId) { |
160 | 0 | this.newLuiId = newLuiId; |
161 | 0 | } |
162 | |
|
163 | |
public String getExistingLuiId() { |
164 | 0 | return existingLuiId; |
165 | |
} |
166 | |
|
167 | |
public void setExistingLuiId(String existingLuiId) { |
168 | 0 | this.existingLuiId = existingLuiId; |
169 | 0 | } |
170 | |
|
171 | |
public String getLprTransactionItemType() { |
172 | 0 | return lprTransactionItemType; |
173 | |
} |
174 | |
|
175 | |
public void setLprTransactionItemType(String lprTransactionType) { |
176 | 0 | this.lprTransactionItemType = lprTransactionType; |
177 | 0 | } |
178 | |
|
179 | |
public String getLprTransactionItemState() { |
180 | 0 | return lprTransactionItemState; |
181 | |
} |
182 | |
|
183 | |
public void setLprTransactionItemState(String lprTransactionState) { |
184 | 0 | this.lprTransactionItemState = lprTransactionState; |
185 | 0 | } |
186 | |
|
187 | |
@Override |
188 | |
public List<LprTransItemAttributeEntity> getAttributes() { |
189 | 0 | return attributes; |
190 | |
} |
191 | |
|
192 | |
@Override |
193 | |
public void setAttributes(List<LprTransItemAttributeEntity> attributes) { |
194 | 0 | this.attributes = attributes; |
195 | 0 | } |
196 | |
|
197 | |
} |