| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.student.r2.core.fee.model; |
| 18 | |
|
| 19 | |
import org.kuali.student.common.entity.KSEntityConstants; |
| 20 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 21 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 22 | |
import org.kuali.student.r2.core.fee.dto.EnrollmentFeeInfo; |
| 23 | |
import org.kuali.student.r2.core.fee.infc.EnrollmentFee; |
| 24 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 25 | |
|
| 26 | |
import javax.persistence.*; |
| 27 | |
import java.util.ArrayList; |
| 28 | |
import java.util.List; |
| 29 | |
import org.kuali.student.r2.core.fee.dto.EnrollmentFeeAmountInfo; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
@Entity |
| 37 | |
@Table(name = "KSEN_ENROLLMENT_FEE") |
| 38 | |
public class EnrollmentFeeEntity extends MetaEntity { |
| 39 | |
|
| 40 | |
@Column(name = "CURRENCY_TYPE") |
| 41 | |
private String currencyType; |
| 42 | |
|
| 43 | |
@Column(name = "CURRENCY_QUANTITY") |
| 44 | |
private Integer currencyQuantity; |
| 45 | |
|
| 46 | |
@Column(name = "ORG_ID") |
| 47 | |
private String orgId; |
| 48 | |
|
| 49 | |
@Column(name = "REF_OBJECT_URI") |
| 50 | |
private String refObjectURI; |
| 51 | |
|
| 52 | |
@Column(name = "REF_OBJECT_ID") |
| 53 | |
private String refObjectId; |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
@Column(name = "ENRL_FEE_TYPE") |
| 59 | |
private String enrollFeeType; |
| 60 | |
|
| 61 | |
@Column(name = "ENRL_FEE_STATE") |
| 62 | |
private String enrollFeeState; |
| 63 | |
|
| 64 | |
@Column(name = "DESCR_PLAIN", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
| 65 | |
private String plain; |
| 66 | |
|
| 67 | |
@Column(name = "DESCR_FORMATTED", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
| 68 | |
private String formatted; |
| 69 | |
|
| 70 | 0 | @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 71 | |
private List<EnrollmentFeeAttributeEntity> attributes = new ArrayList<EnrollmentFeeAttributeEntity>(); |
| 72 | |
|
| 73 | 0 | public EnrollmentFeeEntity() { |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
public EnrollmentFeeEntity(EnrollmentFee fee) { |
| 77 | 0 | super(fee); |
| 78 | 0 | this.setId(fee.getId()); |
| 79 | 0 | this.setEnrollFeeType(fee.getTypeKey()); |
| 80 | 0 | this.fromDto(fee); |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
public void fromDto(EnrollmentFee fee) { |
| 84 | 0 | this.setEnrollFeeState(fee.getStateKey()); |
| 85 | 0 | this.setCurrencyType(fee.getAmount().getCurrencyTypeKey()); |
| 86 | 0 | this.setCurrencyQuantity(fee.getAmount().getCurrencyQuantity()); |
| 87 | 0 | this.setOrgId(fee.getOrgId()); |
| 88 | 0 | this.setRefObjectURI(fee.getRefObjectURI()); |
| 89 | 0 | this.setRefObjectId(fee.getRefObjectId()); |
| 90 | |
|
| 91 | 0 | if (fee.getDescr() != null) { |
| 92 | 0 | this.setPlain(fee.getDescr().getPlain()); |
| 93 | 0 | this.setFormatted(fee.getDescr().getFormatted()); |
| 94 | |
} |
| 95 | 0 | this.setAttributes(new ArrayList<EnrollmentFeeAttributeEntity>()); |
| 96 | 0 | for (Attribute att : fee.getAttributes()) { |
| 97 | 0 | EnrollmentFeeAttributeEntity attEntity = new EnrollmentFeeAttributeEntity(att, this); |
| 98 | 0 | this.getAttributes().add(attEntity); |
| 99 | 0 | } |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
public EnrollmentFeeInfo toDto() { |
| 103 | 0 | EnrollmentFeeInfo feeInfo = new EnrollmentFeeInfo(); |
| 104 | |
|
| 105 | 0 | feeInfo.setId(getId()); |
| 106 | 0 | feeInfo.setStateKey(getEnrollFeeState()); |
| 107 | 0 | feeInfo.setTypeKey(getEnrollFeeType()); |
| 108 | |
|
| 109 | 0 | if (getCurrencyType() != null) { |
| 110 | 0 | EnrollmentFeeAmountInfo amtInfo = new EnrollmentFeeAmountInfo(); |
| 111 | 0 | amtInfo.setCurrencyQuantity(getCurrencyQuantity()); |
| 112 | 0 | amtInfo.setCurrencyTypeKey(getCurrencyType()); |
| 113 | 0 | feeInfo.setAmount(amtInfo); |
| 114 | |
} |
| 115 | 0 | feeInfo.setOrgId(getOrgId()); |
| 116 | 0 | feeInfo.setRefObjectURI(getRefObjectURI()); |
| 117 | 0 | feeInfo.setRefObjectId(getRefObjectId()); |
| 118 | |
|
| 119 | 0 | feeInfo.setMeta(super.toDTO()); |
| 120 | |
|
| 121 | 0 | for (EnrollmentFeeAttributeEntity att: getAttributes()) { |
| 122 | 0 | AttributeInfo attInfo = att.toDto(); |
| 123 | 0 | feeInfo.getAttributes().add(attInfo); |
| 124 | 0 | } |
| 125 | 0 | return feeInfo; |
| 126 | |
} |
| 127 | |
|
| 128 | |
public String getCurrencyType() { |
| 129 | 0 | return currencyType; |
| 130 | |
} |
| 131 | |
|
| 132 | |
public void setCurrencyType(String currencyType) { |
| 133 | 0 | this.currencyType = currencyType; |
| 134 | 0 | } |
| 135 | |
|
| 136 | |
public Integer getCurrencyQuantity() { |
| 137 | 0 | return currencyQuantity; |
| 138 | |
} |
| 139 | |
|
| 140 | |
public void setCurrencyQuantity(Integer currencyQuantity) { |
| 141 | 0 | this.currencyQuantity = currencyQuantity; |
| 142 | 0 | } |
| 143 | |
|
| 144 | |
public String getOrgId() { |
| 145 | 0 | return orgId; |
| 146 | |
} |
| 147 | |
|
| 148 | |
public void setOrgId(String orgId) { |
| 149 | 0 | this.orgId = orgId; |
| 150 | 0 | } |
| 151 | |
|
| 152 | |
public String getRefObjectURI() { |
| 153 | 0 | return refObjectURI; |
| 154 | |
} |
| 155 | |
|
| 156 | |
public void setRefObjectURI(String refObjectURI) { |
| 157 | 0 | this.refObjectURI = refObjectURI; |
| 158 | 0 | } |
| 159 | |
|
| 160 | |
public String getRefObjectId() { |
| 161 | 0 | return refObjectId; |
| 162 | |
} |
| 163 | |
|
| 164 | |
public void setRefObjectId(String refObjectId) { |
| 165 | 0 | this.refObjectId = refObjectId; |
| 166 | 0 | } |
| 167 | |
|
| 168 | |
public String getEnrollFeeType() { |
| 169 | 0 | return enrollFeeType; |
| 170 | |
} |
| 171 | |
|
| 172 | |
public void setEnrollFeeType(String enrollFeeType) { |
| 173 | 0 | this.enrollFeeType = enrollFeeType; |
| 174 | 0 | } |
| 175 | |
|
| 176 | |
public String getEnrollFeeState() { |
| 177 | 0 | return enrollFeeState; |
| 178 | |
} |
| 179 | |
|
| 180 | |
public void setEnrollFeeState(String enrollFeeState) { |
| 181 | 0 | this.enrollFeeState = enrollFeeState; |
| 182 | 0 | } |
| 183 | |
|
| 184 | |
public String getPlain() { |
| 185 | 0 | return plain; |
| 186 | |
} |
| 187 | |
|
| 188 | |
public void setPlain(String plain) { |
| 189 | 0 | this.plain = plain; |
| 190 | 0 | } |
| 191 | |
|
| 192 | |
public String getFormatted() { |
| 193 | 0 | return formatted; |
| 194 | |
} |
| 195 | |
|
| 196 | |
public void setFormatted(String formatted) { |
| 197 | 0 | this.formatted = formatted; |
| 198 | 0 | } |
| 199 | |
|
| 200 | |
public List<EnrollmentFeeAttributeEntity> getAttributes() { |
| 201 | 0 | return attributes; |
| 202 | |
} |
| 203 | |
|
| 204 | |
public void setAttributes(List<EnrollmentFeeAttributeEntity> attributes) { |
| 205 | 0 | this.attributes = attributes; |
| 206 | 0 | } |
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
} |