| 1 | |
package org.kuali.student.enrollment.class1.lpr.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.FetchType; |
| 10 | |
import javax.persistence.JoinColumn; |
| 11 | |
import javax.persistence.ManyToOne; |
| 12 | |
import javax.persistence.OneToMany; |
| 13 | |
import javax.persistence.Table; |
| 14 | |
|
| 15 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionInfo; |
| 16 | |
import org.kuali.student.enrollment.lpr.dto.LprTransactionItemInfo; |
| 17 | |
import org.kuali.student.enrollment.lpr.infc.LprTransaction; |
| 18 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 19 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
| 20 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 21 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 22 | |
|
| 23 | |
@Entity |
| 24 | |
@Table(name = "KSEN_LPR_TRANS") |
| 25 | |
public class LprTransactionEntity extends MetaEntity implements AttributeOwner<LprTransAttributeEntity> { |
| 26 | |
|
| 27 | |
@Column(name = "NAME") |
| 28 | |
private String name; |
| 29 | |
|
| 30 | |
@Column(name = "REQ_PERSON_ID") |
| 31 | |
private String requestingPersonId; |
| 32 | |
|
| 33 | |
@Column(name = "ATP_ID") |
| 34 | |
private String atpId; |
| 35 | |
|
| 36 | |
@ManyToOne(cascade = CascadeType.ALL) |
| 37 | |
@JoinColumn(name = "RT_DESCR_ID") |
| 38 | |
private LprRichTextEntity descr; |
| 39 | |
|
| 40 | |
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) |
| 41 | |
@JoinColumn(name = "LPR_TRANS_ID") |
| 42 | |
private List<LprTransactionItemEntity> lprTransactionItems; |
| 43 | |
|
| 44 | |
@Column(name = "LPR_TYPE_ID") |
| 45 | |
private String lprTransType; |
| 46 | |
|
| 47 | |
@Column(name = "STATE_ID") |
| 48 | |
private String lprTransState; |
| 49 | |
|
| 50 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 51 | |
private List<LprTransAttributeEntity> attributes; |
| 52 | |
|
| 53 | 0 | public LprTransactionEntity() {} |
| 54 | |
|
| 55 | |
public LprTransactionEntity(LprTransaction lprTransaction) { |
| 56 | 0 | super(lprTransaction); |
| 57 | 0 | this.setName(lprTransaction.getName()); |
| 58 | 0 | this.setRequestingPersonId(lprTransaction.getRequestingPersonId()); |
| 59 | 0 | this.requestingPersonId = lprTransaction.getAtpId(); |
| 60 | 0 | this.lprTransactionItems = new ArrayList<LprTransactionItemEntity>(); |
| 61 | 0 | this.setLprTransState(lprTransaction.getStateKey()); |
| 62 | 0 | this.setLprTransType(lprTransaction.getTypeKey()); |
| 63 | 0 | this.setId(lprTransaction.getId()); |
| 64 | 0 | this.setDescr(new LprRichTextEntity(lprTransaction.getDescr())); |
| 65 | |
|
| 66 | 0 | if (null != lprTransaction.getAttributes()) { |
| 67 | 0 | for (Attribute att : lprTransaction.getAttributes()) { |
| 68 | 0 | this.getAttributes().add(new LprTransAttributeEntity(att)); |
| 69 | |
|
| 70 | |
} |
| 71 | |
} |
| 72 | |
|
| 73 | 0 | } |
| 74 | |
|
| 75 | |
public LprTransactionInfo toDto() { |
| 76 | |
|
| 77 | 0 | LprTransactionInfo lpr = new LprTransactionInfo(); |
| 78 | 0 | lpr.setId(getId()); |
| 79 | |
|
| 80 | 0 | if (this.getLprTransType() != null) |
| 81 | 0 | lpr.setTypeKey(this.getLprTransType()); |
| 82 | 0 | if (this.getLprTransState() != null) |
| 83 | 0 | lpr.setStateKey(this.getLprTransState()); |
| 84 | 0 | lpr.setMeta(super.toDTO()); |
| 85 | 0 | if (this.getDescr() != null) |
| 86 | 0 | lpr.setDescr(this.getDescr().toDto()); |
| 87 | 0 | if (getAttributes() != null) { |
| 88 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
| 89 | 0 | for (LprTransAttributeEntity att : getAttributes()) { |
| 90 | 0 | AttributeInfo attInfo = att.toDto(); |
| 91 | 0 | atts.add(attInfo); |
| 92 | 0 | } |
| 93 | 0 | lpr.setAttributes(atts); |
| 94 | |
} |
| 95 | 0 | lpr.setName(getName()); |
| 96 | 0 | lpr.setRequestingPersonId(getRequestingPersonId()); |
| 97 | 0 | lpr.setAtpId(getAtpId()); |
| 98 | 0 | List<LprTransactionItemInfo> lprItemsInfo = new ArrayList<LprTransactionItemInfo>(); |
| 99 | 0 | if (lprTransactionItems != null) { |
| 100 | 0 | for (LprTransactionItemEntity lprItemEntity : lprTransactionItems) { |
| 101 | 0 | lprItemsInfo.add(lprItemEntity.toDto()); |
| 102 | |
} |
| 103 | |
} |
| 104 | 0 | lpr.setLprTransactionItems(lprItemsInfo); |
| 105 | 0 | return lpr; |
| 106 | |
|
| 107 | |
} |
| 108 | |
|
| 109 | |
public String getName() { |
| 110 | 0 | return name; |
| 111 | |
} |
| 112 | |
|
| 113 | |
public void setName(String name) { |
| 114 | 0 | this.name = name; |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
public LprRichTextEntity getDescr() { |
| 118 | 0 | return descr; |
| 119 | |
} |
| 120 | |
|
| 121 | |
public void setDescr(LprRichTextEntity descr) { |
| 122 | 0 | this.descr = descr; |
| 123 | 0 | } |
| 124 | |
|
| 125 | |
public String getLprTransType() { |
| 126 | 0 | return lprTransType; |
| 127 | |
} |
| 128 | |
|
| 129 | |
public void setLprTransType(String lprTransType) { |
| 130 | 0 | this.lprTransType = lprTransType; |
| 131 | 0 | } |
| 132 | |
|
| 133 | |
public String getLprTransState() { |
| 134 | 0 | return lprTransState; |
| 135 | |
} |
| 136 | |
|
| 137 | |
public void setLprTransState(String lprTransState) { |
| 138 | 0 | this.lprTransState = lprTransState; |
| 139 | 0 | } |
| 140 | |
|
| 141 | |
public String getRequestingPersonId() { |
| 142 | 0 | return requestingPersonId; |
| 143 | |
} |
| 144 | |
|
| 145 | |
public void setRequestingPersonId(String requestingPersonId) { |
| 146 | 0 | this.requestingPersonId = requestingPersonId; |
| 147 | 0 | } |
| 148 | |
|
| 149 | |
public String getAtpId() { |
| 150 | 0 | return atpId; |
| 151 | |
} |
| 152 | |
|
| 153 | |
public void setAtpId(String atpId) { |
| 154 | 0 | this.atpId = atpId; |
| 155 | 0 | } |
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
public List<LprTransactionItemEntity> getLprTransactionItems() { |
| 160 | 0 | return lprTransactionItems; |
| 161 | |
} |
| 162 | |
|
| 163 | |
public void setLprTransactionItems(List<LprTransactionItemEntity> lprTransactionItems) { |
| 164 | 0 | this.lprTransactionItems = lprTransactionItems; |
| 165 | 0 | } |
| 166 | |
|
| 167 | |
@Override |
| 168 | |
public void setAttributes(List<LprTransAttributeEntity> attributes) { |
| 169 | 0 | this.setAttributes(attributes); |
| 170 | 0 | } |
| 171 | |
|
| 172 | |
@Override |
| 173 | |
public List<LprTransAttributeEntity> getAttributes() { |
| 174 | 0 | return this.attributes; |
| 175 | |
} |
| 176 | |
|
| 177 | |
} |