| 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.JoinTable; |
| 12 | |
import javax.persistence.ManyToMany; |
| 13 | |
import javax.persistence.ManyToOne; |
| 14 | |
import javax.persistence.OneToMany; |
| 15 | |
import javax.persistence.Table; |
| 16 | |
import javax.persistence.Temporal; |
| 17 | |
import javax.persistence.TemporalType; |
| 18 | |
|
| 19 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 20 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
| 21 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 22 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 23 | |
import org.kuali.student.r2.lum.lrc.dto.ResultValueRangeInfo; |
| 24 | |
import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo; |
| 25 | |
|
| 26 | |
@Entity |
| 27 | |
@Table(name = "KSEN_LRC_RES_VAL_GRP") |
| 28 | |
public class ResultValuesGroupEntity extends MetaEntity implements AttributeOwner<ResultValuesGroupAttributeEntity> { |
| 29 | |
|
| 30 | |
@Column(name = "NAME") |
| 31 | |
private String name; |
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
@Column(name = "RES_SCALE_ID") |
| 38 | |
private String resultScaleId; |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
@Column(name = "TYPE_ID") |
| 45 | |
private String type; |
| 46 | |
|
| 47 | |
@Column(name = "MIN_VALUE") |
| 48 | |
private String minValue; |
| 49 | |
|
| 50 | |
@Column(name = "MAX_VALUE") |
| 51 | |
private String maxValue; |
| 52 | |
|
| 53 | |
@Column(name = "INCR") |
| 54 | |
private String increment; |
| 55 | |
|
| 56 | |
@Column(name = "STATE_ID") |
| 57 | |
private String state; |
| 58 | |
|
| 59 | |
@Temporal(TemporalType.TIMESTAMP) |
| 60 | |
private Date effectiveDate; |
| 61 | |
|
| 62 | |
@Temporal(TemporalType.TIMESTAMP) |
| 63 | |
private Date expirationDate; |
| 64 | |
|
| 65 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 66 | |
private List<ResultValuesGroupAttributeEntity> attributes; |
| 67 | |
|
| 68 | 0 | public ResultValuesGroupEntity() {} |
| 69 | |
|
| 70 | |
public ResultValuesGroupEntity(ResultValuesGroupInfo dto) { |
| 71 | 0 | super(dto); |
| 72 | 0 | this.setName(dto.getName()); |
| 73 | 0 | this.setId(dto.getKey()); |
| 74 | 0 | if (dto.getDescr() != null) { |
| 75 | 0 | ResultValuesGroupRichTextEntity entityDesc = new ResultValuesGroupRichTextEntity(dto.getDescr()); |
| 76 | |
|
| 77 | |
} |
| 78 | 0 | this.setEffectiveDate(dto.getEffectiveDate()); |
| 79 | 0 | this.setExpirationDate(dto.getExpirationDate()); |
| 80 | 0 | this.setResultScaleId(dto.getResultScaleKey()); |
| 81 | 0 | this.setState(dto.getStateKey()); |
| 82 | |
|
| 83 | 0 | if (dto.getResultValueRange() != null) { |
| 84 | 0 | this.setMinValue(dto.getResultValueRange().getMinValue()); |
| 85 | 0 | this.setMaxValue(dto.getResultValueRange().getMaxValue()); |
| 86 | 0 | this.setIncrement(dto.getResultValueRange().getIncrement()); |
| 87 | |
} |
| 88 | |
|
| 89 | 0 | this.setAttributes(new ArrayList<ResultValuesGroupAttributeEntity>()); |
| 90 | 0 | if (null != dto.getAttributes()) { |
| 91 | 0 | for (Attribute att : dto.getAttributes()) { |
| 92 | 0 | ResultValuesGroupAttributeEntity attEntity = new ResultValuesGroupAttributeEntity(att); |
| 93 | 0 | this.getAttributes().add(attEntity); |
| 94 | 0 | } |
| 95 | |
} |
| 96 | 0 | } |
| 97 | |
|
| 98 | |
public String getName() { |
| 99 | 0 | return name; |
| 100 | |
} |
| 101 | |
|
| 102 | |
public void setName(String name) { |
| 103 | 0 | this.name = name; |
| 104 | 0 | } |
| 105 | |
|
| 106 | |
public String getType() { |
| 107 | 0 | return type; |
| 108 | |
} |
| 109 | |
|
| 110 | |
public void setType(String type) { |
| 111 | 0 | this.type = type; |
| 112 | 0 | } |
| 113 | |
|
| 114 | |
public String getState() { |
| 115 | 0 | return state; |
| 116 | |
} |
| 117 | |
|
| 118 | |
public void setState(String state) { |
| 119 | 0 | this.state = state; |
| 120 | 0 | } |
| 121 | |
|
| 122 | |
public Date getExpirationDate() { |
| 123 | 0 | return expirationDate; |
| 124 | |
} |
| 125 | |
|
| 126 | |
public void setExpirationDate(Date expirationDate) { |
| 127 | 0 | this.expirationDate = expirationDate; |
| 128 | 0 | } |
| 129 | |
|
| 130 | |
public Date getEffectiveDate() { |
| 131 | 0 | return effectiveDate; |
| 132 | |
} |
| 133 | |
|
| 134 | |
public void setEffectiveDate(Date effectiveDate) { |
| 135 | 0 | this.effectiveDate = effectiveDate; |
| 136 | 0 | } |
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
public String getResultScaleId() { |
| 147 | 0 | return resultScaleId; |
| 148 | |
} |
| 149 | |
|
| 150 | |
public void setResultScaleId(String resultScaleId) { |
| 151 | 0 | this.resultScaleId = resultScaleId; |
| 152 | 0 | } |
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
public String getMinValue() { |
| 163 | 0 | return minValue; |
| 164 | |
} |
| 165 | |
|
| 166 | |
public void setMinValue(String minValue) { |
| 167 | 0 | this.minValue = minValue; |
| 168 | 0 | } |
| 169 | |
|
| 170 | |
public String getMaxValue() { |
| 171 | 0 | return maxValue; |
| 172 | |
} |
| 173 | |
|
| 174 | |
public void setMaxValue(String maxValue) { |
| 175 | 0 | this.maxValue = maxValue; |
| 176 | 0 | } |
| 177 | |
|
| 178 | |
public String getIncrement() { |
| 179 | 0 | return increment; |
| 180 | |
} |
| 181 | |
|
| 182 | |
public void setIncrement(String increment) { |
| 183 | 0 | this.increment = increment; |
| 184 | 0 | } |
| 185 | |
|
| 186 | |
@Override |
| 187 | |
public void setAttributes(List<ResultValuesGroupAttributeEntity> attributes) { |
| 188 | 0 | this.attributes = attributes; |
| 189 | 0 | } |
| 190 | |
|
| 191 | |
@Override |
| 192 | |
public List<ResultValuesGroupAttributeEntity> getAttributes() { |
| 193 | 0 | return attributes; |
| 194 | |
} |
| 195 | |
|
| 196 | |
public ResultValuesGroupInfo toDto() { |
| 197 | |
|
| 198 | 0 | ResultValuesGroupInfo info = new ResultValuesGroupInfo(); |
| 199 | |
|
| 200 | 0 | info.setKey(getId()); |
| 201 | 0 | info.setName(getName()); |
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | 0 | if (getState() != null) { |
| 208 | 0 | info.setStateKey(getState()); |
| 209 | |
} |
| 210 | |
|
| 211 | 0 | if (getType() != null) { |
| 212 | 0 | info.setTypeKey(getType()); |
| 213 | |
} |
| 214 | |
|
| 215 | 0 | info.setEffectiveDate(getEffectiveDate()); |
| 216 | 0 | info.setExpirationDate(getExpirationDate()); |
| 217 | 0 | info.setMeta(info.getMeta()); |
| 218 | |
|
| 219 | 0 | info.setResultScaleKey(getResultScaleId()); |
| 220 | 0 | List<String> rvIDs = new ArrayList<String>(); |
| 221 | |
|
| 222 | |
|
| 223 | |
|
| 224 | 0 | info.setResultValueKeys(rvIDs); |
| 225 | |
|
| 226 | |
|
| 227 | 0 | ResultValueRangeInfo range = new ResultValueRangeInfo(); |
| 228 | 0 | range.setIncrement(getIncrement()); |
| 229 | 0 | range.setMaxValue(getMaxValue()); |
| 230 | 0 | range.setMinValue(getMinValue()); |
| 231 | 0 | info.setResultValueRange(range); |
| 232 | |
|
| 233 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
| 234 | 0 | for (ResultValuesGroupAttributeEntity att : getAttributes()) { |
| 235 | 0 | AttributeInfo attInfo = att.toDto(); |
| 236 | 0 | atts.add(attInfo); |
| 237 | 0 | } |
| 238 | 0 | info.setAttributes(atts); |
| 239 | 0 | info.setMeta(super.toDTO()); |
| 240 | |
|
| 241 | 0 | return info; |
| 242 | |
} |
| 243 | |
} |