1 | |
package org.kuali.student.enrollment.class1.lrc.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.JoinColumn; |
11 | |
import javax.persistence.ManyToOne; |
12 | |
import javax.persistence.OneToMany; |
13 | |
import javax.persistence.Table; |
14 | |
import javax.persistence.Temporal; |
15 | |
import javax.persistence.TemporalType; |
16 | |
|
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 | |
import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo; |
22 | |
|
23 | |
@Entity |
24 | |
@Table(name = "KSEN_LRC_RES_VALUE") |
25 | |
public class ResultValueEntity extends MetaEntity implements AttributeOwner<ResultValueAttributeEntity> { |
26 | |
|
27 | |
@Column(name = "NAME") |
28 | |
private String name; |
29 | |
|
30 | |
@ManyToOne(cascade = CascadeType.ALL) |
31 | |
@JoinColumn(name = "RT_DESCR_ID") |
32 | |
private ResultValueRichTextEntity descr; |
33 | |
|
34 | |
@Column(name = "RES_SCALE_ID") |
35 | |
private String resultScaleId; |
36 | |
|
37 | |
@Column(name = "NUMERIC_VALUE") |
38 | |
private String numericValue; |
39 | |
|
40 | |
@Column(name = "VALUE") |
41 | |
private String value; |
42 | |
|
43 | |
@Column(name = "TYPE_ID") |
44 | |
private String type; |
45 | |
|
46 | |
@Column(name = "STATE_ID") |
47 | |
private String state; |
48 | |
|
49 | |
@Temporal(TemporalType.TIMESTAMP) |
50 | |
private Date effectiveDate; |
51 | |
|
52 | |
@Temporal(TemporalType.TIMESTAMP) |
53 | |
private Date expirationDate; |
54 | |
|
55 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
56 | |
private List<ResultValueAttributeEntity> attributes; |
57 | |
|
58 | 0 | public ResultValueEntity() {} |
59 | |
|
60 | |
public ResultValueEntity(ResultValueInfo dto) { |
61 | 0 | super(dto); |
62 | 0 | setName(dto.getName()); |
63 | 0 | if (dto.getDescr() != null) { |
64 | 0 | ResultValueRichTextEntity entityDesc = new ResultValueRichTextEntity(dto.getDescr()); |
65 | 0 | this.setDescr(entityDesc); |
66 | |
} |
67 | 0 | setId(dto.getKey()); |
68 | 0 | setEffectiveDate(dto.getEffectiveDate()); |
69 | 0 | setExpirationDate(dto.getExpirationDate()); |
70 | 0 | setNumericValue(dto.getNumericValue()); |
71 | 0 | setResultScaleId(dto.getResultScaleKey()); |
72 | 0 | setValue(dto.getValue()); |
73 | 0 | this.setState(dto.getStateKey()); |
74 | |
|
75 | 0 | this.setAttributes(new ArrayList<ResultValueAttributeEntity>()); |
76 | 0 | if (null != dto.getAttributes()) { |
77 | 0 | for (Attribute att : dto.getAttributes()) { |
78 | 0 | ResultValueAttributeEntity attEntity = new ResultValueAttributeEntity(att); |
79 | 0 | this.getAttributes().add(attEntity); |
80 | 0 | } |
81 | |
} |
82 | |
|
83 | 0 | } |
84 | |
|
85 | |
public String getResultScaleId() { |
86 | 0 | return resultScaleId; |
87 | |
} |
88 | |
|
89 | |
public void setResultScaleId(String resultScaleId) { |
90 | 0 | this.resultScaleId = resultScaleId; |
91 | 0 | } |
92 | |
|
93 | |
public String getNumericValue() { |
94 | 0 | return numericValue; |
95 | |
} |
96 | |
|
97 | |
public void setNumericValue(String numericValue) { |
98 | 0 | this.numericValue = numericValue; |
99 | 0 | } |
100 | |
|
101 | |
public String getValue() { |
102 | 0 | return value; |
103 | |
} |
104 | |
|
105 | |
public void setValue(String value) { |
106 | 0 | this.value = value; |
107 | 0 | } |
108 | |
|
109 | |
public Date getEffectiveDate() { |
110 | 0 | return effectiveDate; |
111 | |
} |
112 | |
|
113 | |
public void setEffectiveDate(Date effectiveDate) { |
114 | 0 | this.effectiveDate = effectiveDate; |
115 | 0 | } |
116 | |
|
117 | |
public Date getExpirationDate() { |
118 | 0 | return expirationDate; |
119 | |
} |
120 | |
|
121 | |
public void setExpirationDate(Date expirationDate) { |
122 | 0 | this.expirationDate = expirationDate; |
123 | 0 | } |
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 | |
public ResultValueRichTextEntity getDescr() { |
134 | 0 | return descr; |
135 | |
} |
136 | |
|
137 | |
public void setDescr(ResultValueRichTextEntity descr) { |
138 | 0 | this.descr = descr; |
139 | 0 | } |
140 | |
|
141 | |
public String getType() { |
142 | 0 | return type; |
143 | |
} |
144 | |
|
145 | |
public void setType(String type) { |
146 | 0 | this.type = type; |
147 | 0 | } |
148 | |
|
149 | |
public String getState() { |
150 | 0 | return state; |
151 | |
} |
152 | |
|
153 | |
public void setState(String state) { |
154 | 0 | this.state = state; |
155 | 0 | } |
156 | |
|
157 | |
@Override |
158 | |
public void setAttributes(List<ResultValueAttributeEntity> attributes) { |
159 | 0 | this.attributes = attributes; |
160 | 0 | } |
161 | |
|
162 | |
@Override |
163 | |
public List<ResultValueAttributeEntity> getAttributes() { |
164 | 0 | return attributes; |
165 | |
} |
166 | |
|
167 | |
public ResultValueInfo toDto() { |
168 | 0 | ResultValueInfo info = new ResultValueInfo(); |
169 | 0 | info.setKey(getId()); |
170 | 0 | info.setEffectiveDate(getEffectiveDate()); |
171 | 0 | info.setExpirationDate(getExpirationDate()); |
172 | 0 | info.setMeta(super.toDTO()); |
173 | |
|
174 | 0 | if (this.getDescr() != null) { |
175 | 0 | info.setDescr(this.getDescr().toDto()); |
176 | |
} |
177 | |
|
178 | 0 | info.setName(getName()); |
179 | 0 | info.setNumericValue(getNumericValue()); |
180 | 0 | info.setValue(getValue()); |
181 | 0 | info.setScaleKey(getResultScaleId()); |
182 | |
|
183 | 0 | if (getState() != null) { |
184 | 0 | info.setStateKey(getState()); |
185 | |
} |
186 | 0 | if (getType() != null) { |
187 | 0 | info.setTypeKey(getType()); |
188 | |
} |
189 | |
|
190 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
191 | 0 | for (ResultValueAttributeEntity att : getAttributes()) { |
192 | 0 | AttributeInfo attInfo = att.toDto(); |
193 | 0 | atts.add(attInfo); |
194 | 0 | } |
195 | 0 | info.setAttributes(atts); |
196 | 0 | info.setMeta(super.toDTO()); |
197 | 0 | return info; |
198 | |
} |
199 | |
} |