| 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.ResultScaleInfo; | 
  | 22 |  |  import org.kuali.student.r2.lum.lrc.dto.ResultValueRangeInfo; | 
  | 23 |  |   | 
  | 24 |  |  @Entity | 
  | 25 |  |  @Table(name = "KSEN_LRC_RES_SCALE") | 
  | 26 |  |  public class ResultScaleEntity extends MetaEntity implements AttributeOwner<ResultScaleAttributeEntity> { | 
  | 27 |  |   | 
  | 28 |  |      @Column(name = "NAME") | 
  | 29 |  |      private String name; | 
  | 30 |  |   | 
  | 31 |  |      @ManyToOne(cascade = CascadeType.ALL) | 
  | 32 |  |      @JoinColumn(name = "RT_DESCR_ID") | 
  | 33 |  |      private ResultScaleRichTextEntity descr; | 
  | 34 |  |   | 
  | 35 |  |      @Column(name = "TYPE_ID") | 
  | 36 |  |      private String type; | 
  | 37 |  |   | 
  | 38 |  |      @Column(name = "STATE_ID") | 
  | 39 |  |      private String state; | 
  | 40 |  |   | 
  | 41 |  |      @Temporal(TemporalType.TIMESTAMP) | 
  | 42 |  |      private Date effectiveDate; | 
  | 43 |  |   | 
  | 44 |  |      @Temporal(TemporalType.TIMESTAMP) | 
  | 45 |  |      private Date expirationDate; | 
  | 46 |  |   | 
  | 47 |  |      @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") | 
  | 48 |  |      private List<ResultScaleAttributeEntity> attributes; | 
  | 49 |  |   | 
  | 50 |  |      @Column(name = "MIN_VALUE") | 
  | 51 |  |      private String minValue; | 
  | 52 |  |   | 
  | 53 |  |      @Column(name = "MAX_VALUE") | 
  | 54 |  |      private String maxValue; | 
  | 55 |  |   | 
  | 56 |  |      @Column(name = "INCR") | 
  | 57 |  |      private String increment; | 
  | 58 |  |   | 
  | 59 | 0 |      public ResultScaleEntity() { | 
  | 60 |  |   | 
  | 61 | 0 |      } | 
  | 62 |  |   | 
  | 63 |  |      public ResultScaleEntity(ResultScaleInfo dto) { | 
  | 64 | 0 |          super(dto); | 
  | 65 | 0 |          this.setName(dto.getName()); | 
  | 66 | 0 |          this.setId(dto.getKey()); | 
  | 67 | 0 |          if (dto.getDescr() != null) { | 
  | 68 | 0 |              ResultScaleRichTextEntity entityDesc = new ResultScaleRichTextEntity(dto.getDescr()); | 
  | 69 | 0 |              this.setDescr(entityDesc); | 
  | 70 |  |          } | 
  | 71 | 0 |          this.setEffectiveDate(dto.getEffectiveDate()); | 
  | 72 | 0 |          this.setExpirationDate(dto.getExpirationDate()); | 
  | 73 | 0 |          this.setState(dto.getStateKey()); | 
  | 74 |  |           | 
  | 75 | 0 |          if (dto.getResultValueRange() != null) { | 
  | 76 | 0 |              this.setMinValue(dto.getResultValueRange().getMinValue()); | 
  | 77 | 0 |              this.setMaxValue(dto.getResultValueRange().getMaxValue()); | 
  | 78 | 0 |              this.setIncrement(dto.getResultValueRange().getIncrement()); | 
  | 79 |  |          } | 
  | 80 |  |   | 
  | 81 | 0 |          this.setAttributes(new ArrayList<ResultScaleAttributeEntity>()); | 
  | 82 | 0 |          if (null != dto.getAttributes()) { | 
  | 83 | 0 |              for (Attribute att : dto.getAttributes()) { | 
  | 84 | 0 |                  ResultScaleAttributeEntity attEntity = new ResultScaleAttributeEntity(att); | 
  | 85 | 0 |                  this.getAttributes().add(attEntity); | 
  | 86 | 0 |              } | 
  | 87 |  |          } | 
  | 88 | 0 |      } | 
  | 89 |  |   | 
  | 90 |  |      public String getName() { | 
  | 91 | 0 |          return name; | 
  | 92 |  |      } | 
  | 93 |  |   | 
  | 94 |  |      public void setName(String name) { | 
  | 95 | 0 |          this.name = name; | 
  | 96 | 0 |      } | 
  | 97 |  |   | 
  | 98 |  |      public ResultScaleRichTextEntity getDescr() { | 
  | 99 | 0 |          return descr; | 
  | 100 |  |      } | 
  | 101 |  |   | 
  | 102 |  |      public void setDescr(ResultScaleRichTextEntity descr) { | 
  | 103 | 0 |          this.descr = descr; | 
  | 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 getEffectiveDate() { | 
  | 123 | 0 |          return effectiveDate; | 
  | 124 |  |      } | 
  | 125 |  |   | 
  | 126 |  |      public void setEffectiveDate(Date effectiveDate) { | 
  | 127 | 0 |          this.effectiveDate = effectiveDate; | 
  | 128 | 0 |      } | 
  | 129 |  |   | 
  | 130 |  |      public Date getExpirationDate() { | 
  | 131 | 0 |          return expirationDate; | 
  | 132 |  |      } | 
  | 133 |  |   | 
  | 134 |  |      public void setExpirationDate(Date expirationDate) { | 
  | 135 | 0 |          this.expirationDate = expirationDate; | 
  | 136 | 0 |      } | 
  | 137 |  |   | 
  | 138 |  |      public String getMinValue() { | 
  | 139 | 0 |          return minValue; | 
  | 140 |  |      } | 
  | 141 |  |   | 
  | 142 |  |      public void setMinValue(String minValue) { | 
  | 143 | 0 |          this.minValue = minValue; | 
  | 144 | 0 |      } | 
  | 145 |  |   | 
  | 146 |  |      public String getMaxValue() { | 
  | 147 | 0 |          return maxValue; | 
  | 148 |  |      } | 
  | 149 |  |   | 
  | 150 |  |      public void setMaxValue(String maxValue) { | 
  | 151 | 0 |          this.maxValue = maxValue; | 
  | 152 | 0 |      } | 
  | 153 |  |   | 
  | 154 |  |      public String getIncrement() { | 
  | 155 | 0 |          return increment; | 
  | 156 |  |      } | 
  | 157 |  |   | 
  | 158 |  |      public void setIncrement(String increment) { | 
  | 159 | 0 |          this.increment = increment; | 
  | 160 | 0 |      } | 
  | 161 |  |   | 
  | 162 |  |      @Override | 
  | 163 |  |      public void setAttributes(List<ResultScaleAttributeEntity> attributes) { | 
  | 164 | 0 |          this.attributes = attributes; | 
  | 165 | 0 |      } | 
  | 166 |  |   | 
  | 167 |  |      @Override | 
  | 168 |  |      public List<ResultScaleAttributeEntity> getAttributes() { | 
  | 169 | 0 |          return attributes; | 
  | 170 |  |      } | 
  | 171 |  |   | 
  | 172 |  |      public ResultScaleInfo toDto() { | 
  | 173 |  |   | 
  | 174 | 0 |          ResultScaleInfo info = new ResultScaleInfo(); | 
  | 175 |  |   | 
  | 176 | 0 |          info.setKey(getId()); | 
  | 177 | 0 |          info.setName(getName()); | 
  | 178 |  |   | 
  | 179 | 0 |          if (getDescr() != null) { | 
  | 180 | 0 |              info.setDescr(getDescr().toDto()); | 
  | 181 |  |          } | 
  | 182 |  |   | 
  | 183 | 0 |          if (getState() != null) { | 
  | 184 | 0 |              info.setStateKey(getState()); | 
  | 185 |  |          } | 
  | 186 |  |   | 
  | 187 | 0 |          if (getType() != null) { | 
  | 188 | 0 |              info.setTypeKey(getType()); | 
  | 189 |  |          } | 
  | 190 |  |   | 
  | 191 | 0 |          info.setEffectiveDate(getEffectiveDate()); | 
  | 192 | 0 |          info.setExpirationDate(getExpirationDate()); | 
  | 193 |  |   | 
  | 194 |  |           | 
  | 195 | 0 |          ResultValueRangeInfo resultValueRange = new ResultValueRangeInfo(); | 
  | 196 | 0 |          resultValueRange.setMaxValue(getMaxValue()); | 
  | 197 | 0 |          resultValueRange.setMinValue(getMinValue()); | 
  | 198 | 0 |          resultValueRange.setIncrement(getIncrement()); | 
  | 199 | 0 |          info.setResultValueRange(resultValueRange); | 
  | 200 |  |   | 
  | 201 | 0 |          List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); | 
  | 202 | 0 |          for (ResultScaleAttributeEntity att : getAttributes()) { | 
  | 203 | 0 |              AttributeInfo attInfo = att.toDto(); | 
  | 204 | 0 |              atts.add(attInfo); | 
  | 205 | 0 |          } | 
  | 206 | 0 |          info.setAttributes(atts); | 
  | 207 | 0 |          info.setMeta(super.toDTO()); | 
  | 208 |  |   | 
  | 209 | 0 |          return info; | 
  | 210 |  |      } | 
  | 211 |  |  } |