| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.enrollment.class1.hold.model; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import javax.persistence.CascadeType; |
| 22 | |
import javax.persistence.Column; |
| 23 | |
import javax.persistence.Entity; |
| 24 | |
import javax.persistence.JoinColumn; |
| 25 | |
import javax.persistence.ManyToOne; |
| 26 | |
import javax.persistence.OneToMany; |
| 27 | |
import javax.persistence.Table; |
| 28 | |
|
| 29 | |
|
| 30 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 31 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
| 32 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 33 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 34 | |
import org.kuali.student.r2.core.hold.dto.IssueInfo; |
| 35 | |
import org.kuali.student.r2.core.hold.infc.Issue; |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
@Entity |
| 44 | |
@Table(name = "KSEN_ISSUE") |
| 45 | |
public class IssueEntity extends MetaEntity implements AttributeOwner<IssueAttributeEntity> { |
| 46 | |
|
| 47 | |
@Column(name = "NAME") |
| 48 | |
private String name; |
| 49 | |
@Column(name = "ORG_ID") |
| 50 | |
private String organizationId; |
| 51 | |
@Column(name = "TYPE_ID") |
| 52 | |
private String issueType; |
| 53 | |
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) |
| 54 | |
@JoinColumn(name = "RT_DESCR_ID") |
| 55 | |
private HoldRichTextEntity descr; |
| 56 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 57 | |
private List<IssueAttributeEntity> attributes; |
| 58 | |
@Column(name = "STATE_ID") |
| 59 | |
private String issueState; |
| 60 | |
|
| 61 | 0 | public IssueEntity() { |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
public IssueEntity(Issue issue) { |
| 65 | 0 | super(issue); |
| 66 | 0 | this.setId(this.getId()); |
| 67 | 0 | this.setIssueType(issue.getTypeKey()); |
| 68 | 0 | this.fromDto(issue); |
| 69 | 0 | } |
| 70 | |
|
| 71 | |
public void fromDto(Issue issue) { |
| 72 | 0 | setName(issue.getName()); |
| 73 | 0 | setOrganizationId(issue.getOrganizationId()); |
| 74 | 0 | setIssueState(issue.getStateKey()); |
| 75 | 0 | setDescr(new HoldRichTextEntity(issue.getDescr())); |
| 76 | 0 | this.setAttributes(new ArrayList<IssueAttributeEntity>()); |
| 77 | 0 | for (Attribute att : issue.getAttributes()) { |
| 78 | 0 | IssueAttributeEntity attEntity = new IssueAttributeEntity(att); |
| 79 | 0 | this.getAttributes().add(attEntity); |
| 80 | 0 | } |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
@Override |
| 84 | |
public void setAttributes(List<IssueAttributeEntity> attributes) { |
| 85 | 0 | this.attributes = attributes; |
| 86 | 0 | } |
| 87 | |
|
| 88 | |
@Override |
| 89 | |
public List<IssueAttributeEntity> getAttributes() { |
| 90 | 0 | return attributes; |
| 91 | |
} |
| 92 | |
|
| 93 | |
public String getName() { |
| 94 | 0 | return name; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public void setName(String name) { |
| 98 | 0 | this.name = name; |
| 99 | 0 | } |
| 100 | |
|
| 101 | |
public String getOrganizationId() { |
| 102 | 0 | return organizationId; |
| 103 | |
} |
| 104 | |
|
| 105 | |
public void setOrganizationId(String organizationId) { |
| 106 | 0 | this.organizationId = organizationId; |
| 107 | 0 | } |
| 108 | |
|
| 109 | |
public String getIssueType() { |
| 110 | 0 | return issueType; |
| 111 | |
} |
| 112 | |
|
| 113 | |
public void setIssueType(String issueType) { |
| 114 | 0 | this.issueType = issueType; |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
public String getIssueState() { |
| 118 | 0 | return issueState; |
| 119 | |
} |
| 120 | |
|
| 121 | |
public void setIssueState(String issueState) { |
| 122 | 0 | this.issueState = issueState; |
| 123 | 0 | } |
| 124 | |
|
| 125 | |
public HoldRichTextEntity getDescr() { |
| 126 | 0 | return descr; |
| 127 | |
} |
| 128 | |
|
| 129 | |
public void setDescr(HoldRichTextEntity descr) { |
| 130 | 0 | this.descr = descr; |
| 131 | 0 | } |
| 132 | |
|
| 133 | |
public IssueInfo toDto() { |
| 134 | 0 | IssueInfo info = new IssueInfo(); |
| 135 | 0 | info.setId(getId()); |
| 136 | 0 | info.setName(getName()); |
| 137 | 0 | info.setTypeKey(getIssueType()); |
| 138 | 0 | info.setStateKey(getIssueState()); |
| 139 | 0 | info.setOrganizationId(getOrganizationId()); |
| 140 | 0 | info.setDescr(getDescr().toDto()); |
| 141 | 0 | info.setMeta(super.toDTO()); |
| 142 | 0 | for (IssueAttributeEntity att : getAttributes()) { |
| 143 | 0 | AttributeInfo attInfo = att.toDto(); |
| 144 | 0 | info.getAttributes().add(attInfo); |
| 145 | 0 | } |
| 146 | 0 | return info; |
| 147 | |
} |
| 148 | |
} |