1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.edl.impl.extract;
17
18 import org.kuali.rice.core.api.util.RiceConstants;
19 import org.kuali.rice.edl.framework.extract.DumpDTO;
20 import org.kuali.rice.edl.framework.extract.FieldDTO;
21 import org.kuali.rice.kew.api.KewApiConstants;
22
23 import javax.persistence.CascadeType;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.FetchType;
27 import javax.persistence.Id;
28 import javax.persistence.OneToMany;
29 import javax.persistence.Table;
30 import javax.persistence.Version;
31 import java.io.Serializable;
32 import java.sql.Timestamp;
33 import java.text.DateFormat;
34 import java.text.SimpleDateFormat;
35 import java.util.ArrayList;
36 import java.util.Calendar;
37 import java.util.Date;
38 import java.util.List;
39
40
41
42
43
44 @Entity
45 @Table(name="KREW_EDL_DMP_T")
46 public class Dump implements Serializable {
47
48
49
50 @Id
51 @Column(name="DOC_HDR_ID", nullable = false)
52 private String docId;
53
54 @Column(name="DOC_TYP_NM", nullable = false)
55 private String docTypeName;
56
57 @Column(name="DOC_HDR_STAT_CD", nullable = false)
58 private String docRouteStatusCode;
59
60 @Column(name="DOC_HDR_MDFN_DT", nullable = false)
61 private Timestamp docModificationDate;
62
63 @Column(name="DOC_HDR_CRTE_DT", nullable = false)
64 private Timestamp docCreationDate;
65
66 @Column(name="DOC_HDR_TTL")
67 private String docDescription;
68
69 @Column(name="DOC_HDR_INITR_PRNCPL_ID", nullable = false)
70 private String docInitiatorId;
71
72 @Column(name="CRNT_NODE_NM", nullable = false)
73 private String docCurrentNodeName;
74
75 @Version
76 @Column(name="VER_NBR", nullable = false)
77 private Integer lockVerNbr;
78
79 @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL},mappedBy="dump")
80 private List<Fields> fields = new ArrayList<Fields>();
81
82
83
84
85
86 public Timestamp getDocCreationDate() {
87 return docCreationDate;
88 }
89
90
91
92
93
94 public void setDocCreationDate(final Timestamp docCreationDate) {
95 this.docCreationDate = docCreationDate;
96 }
97
98
99
100
101
102 public String getDocCurrentNodeName() {
103 return docCurrentNodeName;
104 }
105
106
107
108
109
110 public void setDocCurrentNodeName(final String docCurrentNodeName) {
111 this.docCurrentNodeName = docCurrentNodeName;
112 }
113
114
115
116
117
118 public String getDocDescription() {
119 return docDescription;
120 }
121
122
123
124
125
126 public void setDocDescription(final String docDescription) {
127 this.docDescription = docDescription;
128 }
129
130
131
132
133
134 public String getDocId() {
135 return docId;
136 }
137
138
139
140
141
142 public String getDocInitiatorId() {
143 return docInitiatorId;
144 }
145
146
147
148
149
150 public void setDocInitiatorId(final String docInitiatorId) {
151 this.docInitiatorId = docInitiatorId;
152 }
153
154
155
156
157
158 public Timestamp getDocModificationDate() {
159 return docModificationDate;
160 }
161
162
163
164
165
166 public void setDocModificationDate(final Timestamp docModificationDate) {
167 this.docModificationDate = docModificationDate;
168 }
169
170
171
172
173
174 public String getDocRouteStatusCode() {
175 return docRouteStatusCode;
176 }
177
178
179
180
181
182 public void setDocRouteStatusCode(final String docRouteStatusCode) {
183 this.docRouteStatusCode = docRouteStatusCode;
184 }
185
186
187
188
189
190 public String getDocTypeName() {
191 return docTypeName;
192 }
193
194
195
196
197
198 public void setDocTypeName(final String docTypeName) {
199 this.docTypeName = docTypeName;
200 }
201
202
203
204
205
206 public Integer getLockVerNbr() {
207 return lockVerNbr;
208 }
209
210
211
212
213
214 public void setLockVerNbr(final Integer lockVerNbr) {
215 this.lockVerNbr = lockVerNbr;
216 }
217
218
219
220
221
222 public String getFormattedCreateDateTime() {
223 long time = getDocCreationDate().getTime();
224 Calendar calendar = Calendar.getInstance();
225 calendar.setTimeInMillis(time);
226 Date date = calendar.getTime();
227 DateFormat dateFormat = new SimpleDateFormat(KewApiConstants.TIMESTAMP_DATE_FORMAT_PATTERN2);
228 return dateFormat.format(date);
229 }
230
231
232
233
234
235 public String getFormattedCreateDate() {
236 long time = getDocCreationDate().getTime();
237 Calendar calendar = Calendar.getInstance();
238 calendar.setTimeInMillis(time);
239 Date date = calendar.getTime();
240 DateFormat dateFormat = RiceConstants.getDefaultDateFormat();
241 return dateFormat.format(date);
242 }
243
244
245
246
247
248 public void setDocId(final String docId) {
249 this.docId = docId;
250 }
251
252
253
254
255
256 public List<Fields> getFields() {
257 return fields;
258 }
259
260
261
262
263
264 public void setFields(final List<Fields> fields) {
265 this.fields = fields;
266 }
267
268
269
270
271
272
273 public static DumpDTO to(Dump dump) {
274 if (dump == null) {
275 return null;
276 }
277 DumpDTO dumpDTO = new DumpDTO();
278 dumpDTO.setDocCreationDate(dump.getDocCreationDate());
279 dumpDTO.setDocCurrentNodeName(dump.getDocCurrentNodeName());
280 dumpDTO.setDocDescription(dump.getDocDescription());
281 dumpDTO.setDocId(dump.getDocId());
282 dumpDTO.setDocInitiatorId(dump.getDocInitiatorId());
283 dumpDTO.setDocModificationDate(dump.getDocModificationDate());
284 dumpDTO.setDocRouteStatusCode(dump.getDocRouteStatusCode());
285 dumpDTO.setDocTypeName(dump.getDocTypeName());
286 dumpDTO.setLockVerNbr(dump.getLockVerNbr());
287 List<FieldDTO> fields = new ArrayList<FieldDTO>();
288 for (Fields field : dump.getFields()) {
289 fields.add(Fields.to(field));
290 }
291 dumpDTO.setFields(fields);
292 return dumpDTO;
293 }
294
295
296
297
298
299
300 public static Dump from(DumpDTO dumpDTO) {
301 if (dumpDTO == null) {
302 return null;
303 }
304 Dump dump = new Dump();
305 dump.setDocCreationDate(dumpDTO.getDocCreationDate());
306 dump.setDocCurrentNodeName(dumpDTO.getDocCurrentNodeName());
307 dump.setDocDescription(dumpDTO.getDocDescription());
308 dump.setDocId(dumpDTO.getDocId());
309 dump.setDocInitiatorId(dumpDTO.getDocInitiatorId());
310 dump.setDocModificationDate(dumpDTO.getDocModificationDate());
311 dump.setDocRouteStatusCode(dumpDTO.getDocRouteStatusCode());
312 dump.setDocTypeName(dumpDTO.getDocTypeName());
313 dump.setLockVerNbr(dumpDTO.getLockVerNbr());
314 List<Fields> fields = new ArrayList<Fields>();
315 for (FieldDTO fieldDTO : dumpDTO.getFields()) {
316 fields.add(Fields.from(fieldDTO, dump));
317 }
318 dump.setFields(fields);
319 return dump;
320 }
321 }
322