1 | |
package org.kuali.student.enrollment.class1.roster.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.enrollment.roster.dto.LprRosterInfo; |
15 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
16 | |
import org.kuali.student.r2.common.dto.TimeAmountInfo; |
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 | |
|
21 | |
@Entity |
22 | |
@Table(name = "KSEN_LPR_ROSTER") |
23 | |
public class LprRosterEntity extends MetaEntity { |
24 | |
|
25 | |
@Column(name = "NAME") |
26 | |
private String name; |
27 | |
|
28 | |
@ManyToOne(cascade = CascadeType.ALL) |
29 | |
@JoinColumn(name = "RT_DESCR_ID") |
30 | |
private LprRichTextEntity descr; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
@Column(name = "MAX_CAPACITY") |
37 | |
private int maximumCapacity; |
38 | |
|
39 | |
@Column(name = "CHECK_IN_REQ") |
40 | |
private boolean checkInRequired; |
41 | |
|
42 | |
@Column(name = "TYPE_ID") |
43 | |
private String lprRosterType; |
44 | |
|
45 | |
@Column(name = "STATE_ID") |
46 | |
private String lprRosterState; |
47 | |
|
48 | |
@Column(name = "ATP_DUR_TYP_KEY") |
49 | |
private String atpDurationTypeKey; |
50 | |
|
51 | |
@Column(name = "TM_QUANTITY") |
52 | |
private Integer timeQuantity; |
53 | |
|
54 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
55 | |
private List<LprRosterAttributeEntity> attributes; |
56 | |
|
57 | 0 | public LprRosterEntity() { |
58 | |
|
59 | 0 | } |
60 | |
|
61 | |
public LprRosterEntity(LprRosterInfo dto) { |
62 | 0 | super(dto); |
63 | 0 | this.setCheckInRequired(dto.getCheckInRequired()); |
64 | 0 | this.setMaximumCapacity(dto.getMaximumCapacity()); |
65 | 0 | this.setId(dto.getId()); |
66 | 0 | if (dto.getStateKey() != null) { |
67 | 0 | this.setLprRosterState(dto.getStateKey()); |
68 | |
} |
69 | |
|
70 | 0 | if (dto.getCheckInFrequency() != null) { |
71 | 0 | this.setAtpDurationTypeKey(dto.getCheckInFrequency().getAtpDurationTypeKey()); |
72 | 0 | this.setTimeQuantity(dto.getCheckInFrequency().getTimeQuantity()); |
73 | |
} |
74 | 0 | this.setName(dto.getName()); |
75 | 0 | if (dto.getDescr() != null) { |
76 | 0 | LprRichTextEntity entityDesc = new LprRichTextEntity(dto.getDescr()); |
77 | 0 | this.setDescr(entityDesc); |
78 | |
} |
79 | |
|
80 | 0 | this.setAttributes(new ArrayList<LprRosterAttributeEntity>()); |
81 | 0 | if (null != dto.getAttributes()) { |
82 | 0 | for (Attribute att : dto.getAttributes()) { |
83 | 0 | LprRosterAttributeEntity attEntity = new LprRosterAttributeEntity(att); |
84 | 0 | this.getAttributes().add(attEntity); |
85 | 0 | } |
86 | |
} |
87 | 0 | } |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
public void setCheckInRequired(boolean checkInRequired) { |
98 | 0 | this.checkInRequired = checkInRequired; |
99 | 0 | } |
100 | |
|
101 | |
public int getMaximumCapacity() { |
102 | 0 | return maximumCapacity; |
103 | |
} |
104 | |
|
105 | |
public void setMaximumCapacity(int maximumCapacity) { |
106 | 0 | this.maximumCapacity = maximumCapacity; |
107 | 0 | } |
108 | |
|
109 | |
public Boolean getCheckInRequired() { |
110 | 0 | return checkInRequired; |
111 | |
} |
112 | |
|
113 | |
public void setCheckInRequired(Boolean checkInRequired) { |
114 | 0 | this.checkInRequired = checkInRequired; |
115 | 0 | } |
116 | |
|
117 | |
public String getLprRosterType() { |
118 | 0 | return lprRosterType; |
119 | |
} |
120 | |
|
121 | |
public void setLprRosterType(String lprRosterType) { |
122 | 0 | this.lprRosterType = lprRosterType; |
123 | 0 | } |
124 | |
|
125 | |
public String getLprRosterState() { |
126 | 0 | return lprRosterState; |
127 | |
} |
128 | |
|
129 | |
public void setLprRosterState(String lprRosterState) { |
130 | 0 | this.lprRosterState = lprRosterState; |
131 | 0 | } |
132 | |
|
133 | |
public String getAtpDurationTypeKey() { |
134 | 0 | return atpDurationTypeKey; |
135 | |
} |
136 | |
|
137 | |
public void setAtpDurationTypeKey(String atpDurationTypeKey) { |
138 | 0 | this.atpDurationTypeKey = atpDurationTypeKey; |
139 | 0 | } |
140 | |
|
141 | |
public Integer getTimeQuantity() { |
142 | 0 | return timeQuantity; |
143 | |
} |
144 | |
|
145 | |
public void setTimeQuantity(Integer timeQuantity) { |
146 | 0 | this.timeQuantity = timeQuantity; |
147 | 0 | } |
148 | |
|
149 | |
public List<LprRosterAttributeEntity> getAttributes() { |
150 | 0 | return attributes; |
151 | |
} |
152 | |
|
153 | |
public void setAttributes(List<LprRosterAttributeEntity> attributes) { |
154 | 0 | this.attributes = attributes; |
155 | 0 | } |
156 | |
|
157 | |
public LprRichTextEntity getDescr() { |
158 | 0 | return descr; |
159 | |
} |
160 | |
|
161 | |
public void setDescr(LprRichTextEntity descr) { |
162 | 0 | this.descr = descr; |
163 | 0 | } |
164 | |
|
165 | |
public String getName() { |
166 | 0 | return name; |
167 | |
} |
168 | |
|
169 | |
public void setName(String name) { |
170 | 0 | this.name = name; |
171 | 0 | } |
172 | |
|
173 | |
public LprRosterInfo toDto() { |
174 | 0 | LprRosterInfo info = new LprRosterInfo(); |
175 | 0 | info.setId(this.getId()); |
176 | 0 | TimeAmountInfo timeAmountInfo = new TimeAmountInfo(); |
177 | 0 | timeAmountInfo.setAtpDurationTypeKey(this.getAtpDurationTypeKey()); |
178 | 0 | timeAmountInfo.setTimeQuantity(this.getTimeQuantity()); |
179 | 0 | info.setCheckInFrequency(timeAmountInfo); |
180 | 0 | info.setCheckInRequired(this.getCheckInRequired()); |
181 | 0 | info.setMaximumCapacity(this.getMaximumCapacity()); |
182 | 0 | info.setName(this.getName()); |
183 | 0 | info.setStateKey(getLprRosterState()); |
184 | 0 | info.setTypeKey(getLprRosterType()); |
185 | |
|
186 | |
|
187 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
188 | 0 | for (LprRosterAttributeEntity att : getAttributes()) { |
189 | 0 | AttributeInfo attInfo = att.toDto(); |
190 | 0 | atts.add(attInfo); |
191 | 0 | } |
192 | 0 | info.setAttributes(atts); |
193 | |
|
194 | 0 | info.setMeta(super.toDTO()); |
195 | |
|
196 | 0 | if (descr != null) { |
197 | 0 | info.setDescr(descr.toDto()); |
198 | |
} |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | 0 | return info; |
204 | |
} |
205 | |
} |