1 | |
package org.kuali.student.r2.core.process.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.r2.common.dto.AttributeInfo; |
15 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
16 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
17 | |
import org.kuali.student.r2.common.infc.Attribute; |
18 | |
import org.kuali.student.r2.core.process.dto.CheckInfo; |
19 | |
import org.kuali.student.r2.core.process.infc.Check; |
20 | |
|
21 | |
@Entity |
22 | |
@Table(name = "KSEN_CHECK") |
23 | |
public class CheckEntity extends MetaEntity implements AttributeOwner<CheckAttributeEntity> { |
24 | |
|
25 | |
|
26 | |
@Column(name = "NAME") |
27 | |
private String name; |
28 | |
|
29 | |
|
30 | |
@ManyToOne(cascade = CascadeType.ALL) |
31 | |
@JoinColumn(name = "RT_DESCR_ID") |
32 | |
private CheckRichTextEntity descr; |
33 | |
|
34 | |
|
35 | |
@Column(name = "CHECK_STATE") |
36 | |
private String checkState; |
37 | |
|
38 | |
|
39 | |
@Column(name = "CHECK_TYPE") |
40 | |
private String checkType; |
41 | |
|
42 | |
@Column(name = "ISSUE_ID") |
43 | |
private String issueId; |
44 | |
|
45 | |
@Column(name = "MILESTONE_TYPE_ID") |
46 | |
private String milestoneTypeId; |
47 | |
|
48 | |
@ManyToOne(optional = true) |
49 | |
@JoinColumn(name = "PROCESS_ID") |
50 | |
private ProcessEntity process; |
51 | |
|
52 | |
@Column(name = "AGENDA_ID") |
53 | |
private String agendaId; |
54 | |
|
55 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
56 | |
private List<CheckAttributeEntity> attributes; |
57 | |
|
58 | |
@Override |
59 | |
public void setAttributes(List<CheckAttributeEntity> attributes) { |
60 | 0 | this.attributes = attributes; |
61 | 0 | } |
62 | |
|
63 | 0 | public CheckEntity() {} |
64 | |
|
65 | |
public CheckEntity(Check check) { |
66 | 0 | super(check); |
67 | 0 | this.setId(check.getKey()); |
68 | 0 | this.setName(check.getName()); |
69 | 0 | if (check.getDescr() != null) { |
70 | 0 | this.setDescr(new CheckRichTextEntity(check.getDescr())); |
71 | |
} |
72 | 0 | if (check.getStateKey() != null) { |
73 | 0 | this.setCheckState(check.getStateKey()); |
74 | |
} |
75 | 0 | this.setAttributes(new ArrayList<CheckAttributeEntity>()); |
76 | 0 | if (null != check.getAttributes()) { |
77 | 0 | for (Attribute att : check.getAttributes()) { |
78 | 0 | CheckAttributeEntity attEntity = new CheckAttributeEntity(att); |
79 | 0 | this.getAttributes().add(attEntity); |
80 | 0 | } |
81 | |
} |
82 | |
|
83 | 0 | this.setIssueId(check.getIssueKey()); |
84 | 0 | this.setMilestoneTypeId(check.getMilestoneTypeKey()); |
85 | 0 | this.setAgendaId(check.getAgendaId()); |
86 | 0 | } |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public CheckInfo toDto() { |
92 | 0 | CheckInfo obj = new CheckInfo(); |
93 | 0 | obj.setMeta(super.toDTO()); |
94 | 0 | obj.setKey(getId()); |
95 | 0 | obj.setName(name); |
96 | 0 | if (checkType != null) { |
97 | 0 | obj.setTypeKey(checkType); |
98 | |
} |
99 | 0 | if (checkState != null) { |
100 | 0 | obj.setStateKey(checkState); |
101 | |
} |
102 | 0 | if (descr != null) { |
103 | 0 | obj.setDescr(descr.toDto()); |
104 | |
} |
105 | |
|
106 | 0 | if (null != process) { |
107 | 0 | obj.setProcessKey(process.getId()); |
108 | |
} |
109 | |
|
110 | 0 | obj.setIssueKey(issueId); |
111 | 0 | obj.setMilestoneTypeKey(milestoneTypeId); |
112 | 0 | obj.setAgendaId(agendaId); |
113 | |
|
114 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
115 | 0 | for (CheckAttributeEntity att : getAttributes()) { |
116 | 0 | AttributeInfo attInfo = att.toDto(); |
117 | 0 | atts.add(attInfo); |
118 | 0 | } |
119 | 0 | obj.setAttributes(atts); |
120 | |
|
121 | 0 | return obj; |
122 | |
} |
123 | |
|
124 | |
|
125 | |
public String getName() { |
126 | 0 | return name; |
127 | |
} |
128 | |
|
129 | |
public void setName(String name) { |
130 | 0 | this.name = name; |
131 | 0 | } |
132 | |
|
133 | |
|
134 | |
public CheckRichTextEntity getDescr() { |
135 | 0 | return descr; |
136 | |
} |
137 | |
|
138 | |
public void setDescr(CheckRichTextEntity descr) { |
139 | 0 | this.descr = descr; |
140 | 0 | } |
141 | |
|
142 | |
public String getCheckState() { |
143 | 0 | return checkState; |
144 | |
} |
145 | |
|
146 | |
public void setCheckState(String checkState) { |
147 | 0 | this.checkState = checkState; |
148 | 0 | } |
149 | |
|
150 | |
public String getCheckType() { |
151 | 0 | return checkType; |
152 | |
} |
153 | |
|
154 | |
public void setCheckType(String checkType) { |
155 | 0 | this.checkType = checkType; |
156 | 0 | } |
157 | |
|
158 | |
public String getIssueId() { |
159 | 0 | return issueId; |
160 | |
} |
161 | |
|
162 | |
public void setIssueId(String issueId) { |
163 | 0 | this.issueId = issueId; |
164 | 0 | } |
165 | |
|
166 | |
public String getMilestoneTypeId() { |
167 | 0 | return milestoneTypeId; |
168 | |
} |
169 | |
|
170 | |
public void setMilestoneTypeId(String milestoneTypeId) { |
171 | 0 | this.milestoneTypeId = milestoneTypeId; |
172 | 0 | } |
173 | |
|
174 | |
public ProcessEntity getProcess() { |
175 | 0 | return process; |
176 | |
} |
177 | |
|
178 | |
public void setProcess(ProcessEntity process) { |
179 | 0 | this.process = process; |
180 | 0 | } |
181 | |
|
182 | |
public String getAgendaId() { |
183 | 0 | return agendaId; |
184 | |
} |
185 | |
|
186 | |
public void setAgendaId(String agendaId) { |
187 | 0 | this.agendaId = agendaId; |
188 | 0 | } |
189 | |
|
190 | |
@Override |
191 | |
public List<CheckAttributeEntity> getAttributes() { |
192 | 0 | return attributes; |
193 | |
} |
194 | |
} |