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.core.class1.state.model.StateEntity; |
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 | |
|
44 | |
@Entity |
45 | |
@Table(name = "KSEN_ISSUE") |
46 | |
public class IssueEntity extends MetaEntity implements AttributeOwner<IssueAttributeEntity> { |
47 | |
|
48 | |
@Column(name = "NAME") |
49 | |
private String name; |
50 | |
|
51 | |
@Column(name = "ORG_ID") |
52 | |
private String organizationId; |
53 | |
|
54 | |
@Column(name = "TYPE_ID") |
55 | |
private String issueType; |
56 | |
|
57 | |
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) |
58 | |
@JoinColumn(name = "RT_DESCR_ID") |
59 | |
private HoldRichTextEntity descr; |
60 | |
|
61 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
62 | |
private List<IssueAttributeEntity> attributes; |
63 | |
|
64 | |
@Column(name = "STATE_ID") |
65 | |
private String issueState; |
66 | |
|
67 | 0 | public IssueEntity() { |
68 | 0 | } |
69 | |
|
70 | |
public IssueEntity(Issue issue) { |
71 | 0 | super(issue); |
72 | 0 | setName(issue.getName()); |
73 | 0 | setOrganizationId(issue.getOrganizationId()); |
74 | 0 | setIssueType(issue.getTypeKey()); |
75 | |
|
76 | 0 | setIssueState(issue.getStateKey()); |
77 | |
|
78 | 0 | setDescr(new HoldRichTextEntity(issue.getDescr())); |
79 | 0 | } |
80 | |
|
81 | |
@Override |
82 | |
public void setAttributes(List<IssueAttributeEntity> attributes) { |
83 | 0 | this.attributes = attributes; |
84 | 0 | } |
85 | |
|
86 | |
@Override |
87 | |
public List<IssueAttributeEntity> getAttributes() { |
88 | 0 | return attributes; |
89 | |
} |
90 | |
|
91 | |
public String getName() { |
92 | 0 | return name; |
93 | |
} |
94 | |
|
95 | |
public void setName(String name) { |
96 | 0 | this.name = name; |
97 | 0 | } |
98 | |
|
99 | |
public String getOrganizationId() { |
100 | 0 | return organizationId; |
101 | |
} |
102 | |
|
103 | |
public void setOrganizationId(String organizationId) { |
104 | 0 | this.organizationId = organizationId; |
105 | 0 | } |
106 | |
|
107 | |
public String getIssueType() { |
108 | 0 | return issueType; |
109 | |
} |
110 | |
|
111 | |
public void setIssueType(String issueType) { |
112 | 0 | this.issueType = issueType; |
113 | 0 | } |
114 | |
|
115 | |
public String getIssueState() { |
116 | 0 | return issueState; |
117 | |
} |
118 | |
|
119 | |
public void setIssueState(String issueState) { |
120 | 0 | this.issueState = issueState; |
121 | 0 | } |
122 | |
|
123 | |
public HoldRichTextEntity getDescr() { |
124 | 0 | return descr; |
125 | |
} |
126 | |
|
127 | |
public void setDescr(HoldRichTextEntity descr) { |
128 | 0 | this.descr = descr; |
129 | 0 | } |
130 | |
|
131 | |
public IssueInfo toDto() { |
132 | 0 | IssueInfo info = new IssueInfo(); |
133 | |
|
134 | 0 | info.setKey(getId()); |
135 | 0 | info.setName(getName()); |
136 | 0 | info.setTypeKey(getIssueType()); |
137 | 0 | info.setStateKey(getIssueState()); |
138 | 0 | info.setOrganizationId(getOrganizationId()); |
139 | 0 | info.setMeta(super.toDTO()); |
140 | |
|
141 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
142 | 0 | for (IssueAttributeEntity att : getAttributes()) { |
143 | 0 | AttributeInfo attInfo = att.toDto(); |
144 | 0 | atts.add(attInfo); |
145 | 0 | } |
146 | 0 | info.setAttributes(atts); |
147 | |
|
148 | 0 | info.setDescr(getDescr().toDto()); |
149 | |
|
150 | 0 | return info; |
151 | |
} |
152 | |
|
153 | |
} |