| 1 | |
package org.kuali.student.enrollment.class1.lui.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.common.entity.KSEntityConstants; |
| 15 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 16 | |
import org.kuali.student.r2.common.dto.RichTextInfo; |
| 17 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
| 18 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 19 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 20 | |
import org.kuali.student.r2.common.infc.RichText; |
| 21 | |
import org.kuali.student.r2.lum.clu.dto.FeeInfo; |
| 22 | |
import org.kuali.student.r2.lum.clu.infc.Fee; |
| 23 | |
|
| 24 | |
@Entity |
| 25 | |
@Table(name = "KSEN_LUI_FEE") |
| 26 | |
public class LuiFeeEntity extends MetaEntity implements AttributeOwner<LuiFeeAttributeEntity> { |
| 27 | |
|
| 28 | |
@Column(name = "FEE_TYPE") |
| 29 | |
private String feeType; |
| 30 | |
|
| 31 | |
@Column(name = "RATE_TYPE") |
| 32 | |
private String rateType; |
| 33 | |
|
| 34 | |
@Column(name = "FEE_KEY") |
| 35 | |
private String feeKey; |
| 36 | |
|
| 37 | |
@Column(name = "DESCR_FORMATTED", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
| 38 | |
private String formatted; |
| 39 | |
|
| 40 | |
@Column(name = "DESCR_PLAIN", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH, nullable = false) |
| 41 | |
private String plain; |
| 42 | |
|
| 43 | |
@ManyToOne |
| 44 | |
@JoinColumn(name = "LUI_ID") |
| 45 | |
private LuiEntity lui; |
| 46 | |
|
| 47 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 48 | |
private List<LuiFeeAttributeEntity> attributes; |
| 49 | |
|
| 50 | 0 | public LuiFeeEntity() {} |
| 51 | |
|
| 52 | |
public LuiFeeEntity(Fee fee) { |
| 53 | 0 | super(fee); |
| 54 | 0 | this.setFeeKey(fee.getKey()); |
| 55 | 0 | this.setFeeType(fee.getFeeType()); |
| 56 | 0 | this.setRateType(fee.getRateType()); |
| 57 | |
|
| 58 | |
|
| 59 | 0 | if (fee.getDescr() != null) { |
| 60 | 0 | RichText rt = fee.getDescr(); |
| 61 | 0 | this.setFormatted(rt.getFormatted()); |
| 62 | 0 | this.setPlain(rt.getPlain()); |
| 63 | |
} |
| 64 | |
|
| 65 | |
|
| 66 | 0 | this.setAttributes(new ArrayList<LuiFeeAttributeEntity>()); |
| 67 | 0 | if (null != fee.getAttributes()) { |
| 68 | 0 | for (Attribute att : fee.getAttributes()) { |
| 69 | 0 | LuiFeeAttributeEntity attEntity = new LuiFeeAttributeEntity(att); |
| 70 | 0 | this.getAttributes().add(attEntity); |
| 71 | 0 | } |
| 72 | |
} |
| 73 | 0 | } |
| 74 | |
|
| 75 | |
public String getFeeType() { |
| 76 | 0 | return feeType; |
| 77 | |
} |
| 78 | |
|
| 79 | |
public void setFeeType(String feeType) { |
| 80 | 0 | this.feeType = feeType; |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
public String getRateType() { |
| 84 | 0 | return rateType; |
| 85 | |
} |
| 86 | |
|
| 87 | |
public void setRateType(String rateType) { |
| 88 | 0 | this.rateType = rateType; |
| 89 | 0 | } |
| 90 | |
|
| 91 | |
public String getFeeKey() { |
| 92 | 0 | return feeKey; |
| 93 | |
} |
| 94 | |
|
| 95 | |
public void setFeeKey(String feeKey) { |
| 96 | 0 | this.feeKey = feeKey; |
| 97 | 0 | } |
| 98 | |
|
| 99 | |
public String getFormatted() { |
| 100 | 0 | return formatted; |
| 101 | |
} |
| 102 | |
|
| 103 | |
public void setFormatted(String formatted) { |
| 104 | 0 | this.formatted = formatted; |
| 105 | 0 | } |
| 106 | |
|
| 107 | |
public String getPlain() { |
| 108 | 0 | return plain; |
| 109 | |
} |
| 110 | |
|
| 111 | |
public void setPlain(String plain) { |
| 112 | 0 | this.plain = plain; |
| 113 | 0 | } |
| 114 | |
|
| 115 | |
public LuiEntity getLui() { |
| 116 | 0 | return lui; |
| 117 | |
} |
| 118 | |
|
| 119 | |
public void setLui(LuiEntity lui) { |
| 120 | 0 | this.lui = lui; |
| 121 | 0 | } |
| 122 | |
|
| 123 | |
public FeeInfo toDto() { |
| 124 | 0 | FeeInfo obj = new FeeInfo(); |
| 125 | 0 | obj.setId(this.getId()); |
| 126 | |
|
| 127 | |
|
| 128 | 0 | obj.setFeeType(this.getFeeType()); |
| 129 | 0 | obj.setRateType(this.getRateType()); |
| 130 | |
|
| 131 | |
|
| 132 | 0 | RichTextInfo rtInfo = new RichTextInfo(); |
| 133 | 0 | rtInfo.setFormatted(this.getFormatted()); |
| 134 | 0 | rtInfo.setPlain(this.getPlain()); |
| 135 | 0 | obj.setDescr(rtInfo); |
| 136 | |
|
| 137 | |
|
| 138 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
| 139 | 0 | for (LuiFeeAttributeEntity att : getAttributes()) { |
| 140 | 0 | AttributeInfo attInfo = att.toDto(); |
| 141 | 0 | atts.add(attInfo); |
| 142 | 0 | } |
| 143 | 0 | obj.setAttributes(atts); |
| 144 | |
|
| 145 | 0 | obj.setMeta(super.toDTO()); |
| 146 | |
|
| 147 | 0 | return obj; |
| 148 | |
|
| 149 | |
} |
| 150 | |
|
| 151 | |
@Override |
| 152 | |
public void setAttributes(List<LuiFeeAttributeEntity> attributes) { |
| 153 | 0 | this.attributes = attributes; |
| 154 | 0 | } |
| 155 | |
|
| 156 | |
@Override |
| 157 | |
public List<LuiFeeAttributeEntity> getAttributes() { |
| 158 | 0 | return attributes; |
| 159 | |
} |
| 160 | |
} |