1 | |
package org.kuali.student.r2.core.class1.process.model; |
2 | |
|
3 | |
import org.kuali.student.common.entity.KSEntityConstants; |
4 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
5 | |
import org.kuali.student.r2.common.entity.AttributeOwnerNew; |
6 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
7 | |
import org.kuali.student.r2.common.infc.Attribute; |
8 | |
import org.kuali.student.r2.common.util.RichTextHelper; |
9 | |
import org.kuali.student.r2.core.process.dto.CheckInfo; |
10 | |
import org.kuali.student.r2.core.process.infc.Check; |
11 | |
|
12 | |
import javax.persistence.CascadeType; |
13 | |
import javax.persistence.Column; |
14 | |
import javax.persistence.Entity; |
15 | |
import javax.persistence.OneToMany; |
16 | |
import javax.persistence.Table; |
17 | |
import java.util.ArrayList; |
18 | |
import java.util.List; |
19 | |
|
20 | |
@Entity |
21 | |
@Table(name = "KSEN_CHECK") |
22 | |
public class CheckEntity extends MetaEntity implements AttributeOwnerNew<CheckAttributeEntity> { |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
@Column(name = "PROCESS_CHECK_TYPE", nullable = false) |
29 | |
private String checkType; |
30 | |
|
31 | |
@Column(name = "PROCESS_CHECK_STATE", nullable = false) |
32 | |
private String checkState; |
33 | |
|
34 | |
@Column(name = "NAME") |
35 | |
private String name; |
36 | |
|
37 | |
@Column(name = "DESCR_PLAIN", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
38 | |
private String descrPlain; |
39 | |
|
40 | |
@Column(name = "DESCR_FORMATTED", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
41 | |
private String descrFormatted; |
42 | |
|
43 | |
@Column(name = "ISSUE_ID") |
44 | |
private String issueId; |
45 | |
|
46 | |
@Column(name = "MILESTONE_TYPE") |
47 | |
private String milestoneType; |
48 | |
|
49 | |
@Column(name = "AGENDA_ID") |
50 | |
private String agendaId; |
51 | |
|
52 | |
@Column(name = "RIGHT_AGENDA_ID") |
53 | |
private String rightAgendaId; |
54 | |
|
55 | |
@Column(name = "LEFT_AGENDA_ID") |
56 | |
private String leftAgendaId; |
57 | |
|
58 | |
@Column(name = "CHILD_PROCESS_ID") |
59 | |
private String childProcessId; |
60 | |
|
61 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", orphanRemoval = true) |
62 | |
private List<CheckAttributeEntity> attributes; |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | 0 | public CheckEntity() {} |
69 | |
|
70 | |
public CheckEntity(Check check) { |
71 | 0 | super(check); |
72 | 0 | this.setId(check.getId()); |
73 | 0 | this.setCheckType(check.getTypeKey()); |
74 | 0 | this.fromDTO(check); |
75 | 0 | } |
76 | |
|
77 | |
public void fromDTO(Check check) { |
78 | 0 | this.setCheckState(check.getStateKey()); |
79 | 0 | this.setName(check.getName()); |
80 | 0 | if (check.getDescr() != null) { |
81 | 0 | this.setDescrFormatted(check.getDescr().getFormatted()); |
82 | 0 | this.setDescrPlain(check.getDescr().getPlain()); |
83 | |
} else { |
84 | 0 | this.setDescrFormatted(null); |
85 | 0 | this.setDescrPlain(null); |
86 | |
} |
87 | 0 | this.setIssueId(check.getIssueId()); |
88 | 0 | this.setMilestoneType(check.getMilestoneTypeKey()); |
89 | 0 | this.setAgendaId(check.getAgendaId()); |
90 | 0 | this.setRightAgendaId(check.getRightComparisonValue()); |
91 | 0 | this.setLeftAgendaId(check.getLeftComparisonAgendaId()); |
92 | 0 | this.setChildProcessId(check.getProcessKey()); |
93 | 0 | this.setAttributes(new ArrayList<CheckAttributeEntity>()); |
94 | 0 | for (Attribute att : check.getAttributes()) { |
95 | 0 | this.getAttributes().add(new CheckAttributeEntity(att, this)); |
96 | |
} |
97 | 0 | } |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
public CheckInfo toDto() { |
103 | 0 | CheckInfo checkInfo = new CheckInfo(); |
104 | 0 | checkInfo.setMeta(super.toDTO()); |
105 | 0 | checkInfo.setId(getId()); |
106 | 0 | checkInfo.setTypeKey(checkType); |
107 | 0 | checkInfo.setStateKey(checkState); |
108 | 0 | checkInfo.setDescr(new RichTextHelper().toRichTextInfo(descrPlain, descrFormatted)); |
109 | 0 | checkInfo.setIssueId(issueId); |
110 | 0 | checkInfo.setMilestoneTypeKey(milestoneType); |
111 | 0 | checkInfo.setAgendaId(agendaId); |
112 | 0 | checkInfo.setRightComparisonAgendaId(rightAgendaId); |
113 | 0 | checkInfo.setLeftComparisonAgendaId(leftAgendaId); |
114 | 0 | checkInfo.setProcessKey(childProcessId); |
115 | 0 | List<AttributeInfo> attributes = checkInfo.getAttributes(); |
116 | 0 | if (getAttributes() != null) { |
117 | 0 | for (CheckAttributeEntity att : getAttributes()) { |
118 | 0 | AttributeInfo attInfo = att.toDto(); |
119 | 0 | attributes.add(attInfo); |
120 | 0 | } |
121 | |
} |
122 | 0 | return checkInfo; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public String getCheckType() { |
130 | 0 | return checkType; |
131 | |
} |
132 | |
|
133 | |
public void setCheckType(String checkType) { |
134 | 0 | this.checkType = checkType; |
135 | 0 | } |
136 | |
|
137 | |
public String getCheckState() { |
138 | 0 | return checkState; |
139 | |
} |
140 | |
|
141 | |
public void setCheckState(String checkState) { |
142 | 0 | this.checkState = checkState; |
143 | 0 | } |
144 | |
|
145 | |
public String getName() { |
146 | 0 | return name; |
147 | |
} |
148 | |
|
149 | |
public void setName(String name) { |
150 | 0 | this.name = name; |
151 | 0 | } |
152 | |
|
153 | |
public String getDescrPlain() { |
154 | 0 | return descrPlain; |
155 | |
} |
156 | |
|
157 | |
public void setDescrPlain(String descrPlain) { |
158 | 0 | this.descrPlain = descrPlain; |
159 | 0 | } |
160 | |
|
161 | |
public String getDescrFormatted() { |
162 | 0 | return descrFormatted; |
163 | |
} |
164 | |
|
165 | |
public void setDescrFormatted(String descrFormatted) { |
166 | 0 | this.descrFormatted = descrFormatted; |
167 | 0 | } |
168 | |
|
169 | |
public String getIssueId() { |
170 | 0 | return issueId; |
171 | |
} |
172 | |
|
173 | |
public void setIssueId(String issueId) { |
174 | 0 | this.issueId = issueId; |
175 | 0 | } |
176 | |
|
177 | |
public String getMilestoneType() { |
178 | 0 | return milestoneType; |
179 | |
} |
180 | |
|
181 | |
public void setMilestoneType(String milestoneType) { |
182 | 0 | this.milestoneType = milestoneType; |
183 | 0 | } |
184 | |
|
185 | |
public String getAgendaId() { |
186 | 0 | return agendaId; |
187 | |
} |
188 | |
|
189 | |
public void setAgendaId(String agendaId) { |
190 | 0 | this.agendaId = agendaId; |
191 | 0 | } |
192 | |
public String getRightAgendaId() { |
193 | 0 | return rightAgendaId; |
194 | |
} |
195 | |
|
196 | |
public void setRightAgendaId(String rightAgendaId) { |
197 | 0 | this.rightAgendaId = rightAgendaId; |
198 | 0 | } |
199 | |
|
200 | |
public String getLeftAgendaId() { |
201 | 0 | return leftAgendaId; |
202 | |
} |
203 | |
|
204 | |
public void setLeftAgendaId(String leftAgendaId) { |
205 | 0 | this.leftAgendaId = leftAgendaId; |
206 | 0 | } |
207 | |
|
208 | |
public String getChildProcessId() { |
209 | 0 | return childProcessId; |
210 | |
} |
211 | |
|
212 | |
public void setChildProcessId(String childProcessId) { |
213 | 0 | this.childProcessId = childProcessId; |
214 | 0 | } |
215 | |
|
216 | |
@Override |
217 | |
public List<CheckAttributeEntity> getAttributes() { |
218 | 0 | return attributes; |
219 | |
} |
220 | |
|
221 | |
@Override |
222 | |
public void setAttributes(List<CheckAttributeEntity> attributes) { |
223 | 0 | this.attributes = attributes; |
224 | 0 | } |
225 | |
|
226 | |
} |