| 1 | |
package org.kuali.student.enrollment.class2.courseofferingset.model; |
| 2 | |
|
| 3 | |
import org.kuali.student.common.entity.KSEntityConstants; |
| 4 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 5 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 6 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 7 | |
import org.kuali.student.r2.common.util.RichTextHelper; |
| 8 | |
|
| 9 | |
import javax.persistence.CascadeType; |
| 10 | |
import javax.persistence.Column; |
| 11 | |
import javax.persistence.Entity; |
| 12 | |
import javax.persistence.OneToMany; |
| 13 | |
import javax.persistence.Table; |
| 14 | |
import java.util.ArrayList; |
| 15 | |
import java.util.List; |
| 16 | |
import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultItemInfo; |
| 17 | |
import org.kuali.student.enrollment.courseofferingset.infc.SocRolloverResultItem; |
| 18 | |
|
| 19 | |
@Entity |
| 20 | |
@Table(name = "KSEN_SOC_ROR_ITEM") |
| 21 | |
public class SocRolloverResultItemEntity extends MetaEntity { |
| 22 | |
|
| 23 | |
@Column(name = "ROR_ID") |
| 24 | |
private String socRolloverResultId; |
| 25 | |
@Column(name = "SOC_ROR_TYPE", nullable = false) |
| 26 | |
private String socRorType; |
| 27 | |
@Column(name = "SOC_ROR_STATE", nullable = false) |
| 28 | |
private String socRorState; |
| 29 | |
@Column(name = "SOURCE_CO_ID") |
| 30 | |
private String sourceCourseOfferingId; |
| 31 | |
@Column(name = "TARGET_CO_ID") |
| 32 | |
private String targetCourseOfferingId; |
| 33 | |
@Column(name = "MESG_FORMATTED", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
| 34 | |
private String mesgFormatted; |
| 35 | |
@Column(name = "MESG_PLAIN", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH) |
| 36 | |
private String mesgPlain; |
| 37 | 0 | @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 38 | |
private List<SocRolloverResultItemAttributeEntity> attributes = new ArrayList<SocRolloverResultItemAttributeEntity>(); |
| 39 | |
|
| 40 | 0 | public SocRolloverResultItemEntity() { |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
public SocRolloverResultItemEntity(SocRolloverResultItem item) { |
| 44 | 0 | super(item); |
| 45 | 0 | this.setId(item.getId()); |
| 46 | 0 | this.setSocRolloverResultId(item.getSocRolloverResultId()); |
| 47 | 0 | this.setSocRorType(item.getTypeKey()); |
| 48 | 0 | this.fromDTO(item); |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
public void fromDTO(SocRolloverResultItem item) { |
| 52 | 0 | this.setSocRorState(item.getStateKey()); |
| 53 | 0 | this.setSourceCourseOfferingId(item.getSourceCourseOfferingId()); |
| 54 | 0 | this.setTargetCourseOfferingId(item.getTargetCourseOfferingId()); |
| 55 | 0 | if (item.getMessage() != null) { |
| 56 | 0 | this.setMesgFormatted(item.getMessage().getFormatted()); |
| 57 | 0 | this.setMesgPlain(item.getMessage().getPlain()); |
| 58 | |
} else { |
| 59 | 0 | this.setMesgFormatted(null); |
| 60 | 0 | this.setMesgPlain(null); |
| 61 | |
} |
| 62 | 0 | this.setAttributes(new ArrayList<SocRolloverResultItemAttributeEntity>()); |
| 63 | 0 | for (Attribute att : item.getAttributes()) { |
| 64 | 0 | this.getAttributes().add(new SocRolloverResultItemAttributeEntity(att, this)); |
| 65 | |
} |
| 66 | 0 | } |
| 67 | |
|
| 68 | |
|
| 69 | |
public SocRolloverResultItemInfo toDto() { |
| 70 | 0 | SocRolloverResultItemInfo info = new SocRolloverResultItemInfo(); |
| 71 | 0 | info.setId(getId()); |
| 72 | 0 | info.setTypeKey(socRorType); |
| 73 | 0 | info.setStateKey(socRorState); |
| 74 | 0 | info.setSocRolloverResultId(socRolloverResultId); |
| 75 | 0 | info.setSourceCourseOfferingId(sourceCourseOfferingId); |
| 76 | 0 | info.setTargetCourseOfferingId(targetCourseOfferingId); |
| 77 | 0 | info.setMessage(new RichTextHelper().toRichTextInfo(getMesgPlain(), getMesgFormatted())); |
| 78 | 0 | info.setMeta(super.toDTO()); |
| 79 | 0 | if (getAttributes() != null) { |
| 80 | 0 | for (SocRolloverResultItemAttributeEntity att : getAttributes()) { |
| 81 | 0 | AttributeInfo attInfo = att.toDto(); |
| 82 | 0 | info.getAttributes().add(attInfo); |
| 83 | 0 | } |
| 84 | |
} |
| 85 | |
|
| 86 | 0 | return info; |
| 87 | |
} |
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
public String getMesgFormatted() { |
| 92 | 0 | return mesgFormatted; |
| 93 | |
} |
| 94 | |
|
| 95 | |
public void setMesgFormatted(String mesgFormatted) { |
| 96 | 0 | this.mesgFormatted = mesgFormatted; |
| 97 | 0 | } |
| 98 | |
|
| 99 | |
public String getMesgPlain() { |
| 100 | 0 | return mesgPlain; |
| 101 | |
} |
| 102 | |
|
| 103 | |
public void setMesgPlain(String mesgPlain) { |
| 104 | 0 | this.mesgPlain = mesgPlain; |
| 105 | 0 | } |
| 106 | |
|
| 107 | |
public String getSocRolloverResultId() { |
| 108 | 0 | return socRolloverResultId; |
| 109 | |
} |
| 110 | |
|
| 111 | |
public void setSocRolloverResultId(String socRolloverResultId) { |
| 112 | 0 | this.socRolloverResultId = socRolloverResultId; |
| 113 | 0 | } |
| 114 | |
|
| 115 | |
public String getSocRorState() { |
| 116 | 0 | return socRorState; |
| 117 | |
} |
| 118 | |
|
| 119 | |
public void setSocRorState(String socRorState) { |
| 120 | 0 | this.socRorState = socRorState; |
| 121 | 0 | } |
| 122 | |
|
| 123 | |
public String getSocRorType() { |
| 124 | 0 | return socRorType; |
| 125 | |
} |
| 126 | |
|
| 127 | |
public void setSocRorType(String socRorType) { |
| 128 | 0 | this.socRorType = socRorType; |
| 129 | 0 | } |
| 130 | |
|
| 131 | |
public String getSourceCourseOfferingId() { |
| 132 | 0 | return sourceCourseOfferingId; |
| 133 | |
} |
| 134 | |
|
| 135 | |
public void setSourceCourseOfferingId(String sourceCourseOfferingId) { |
| 136 | 0 | this.sourceCourseOfferingId = sourceCourseOfferingId; |
| 137 | 0 | } |
| 138 | |
|
| 139 | |
public String getTargetCourseOfferingId() { |
| 140 | 0 | return targetCourseOfferingId; |
| 141 | |
} |
| 142 | |
|
| 143 | |
public void setTargetCourseOfferingId(String targetCourseOfferingId) { |
| 144 | 0 | this.targetCourseOfferingId = targetCourseOfferingId; |
| 145 | 0 | } |
| 146 | |
|
| 147 | |
public List<SocRolloverResultItemAttributeEntity> getAttributes() { |
| 148 | 0 | return attributes; |
| 149 | |
} |
| 150 | |
|
| 151 | |
public void setAttributes(List<SocRolloverResultItemAttributeEntity> attributes) { |
| 152 | 0 | this.attributes = attributes; |
| 153 | 0 | } |
| 154 | |
|
| 155 | |
|
| 156 | |
} |