1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.edl.impl.extract; |
18 | |
|
19 | |
import java.sql.Timestamp; |
20 | |
import java.text.DateFormat; |
21 | |
import java.text.SimpleDateFormat; |
22 | |
import java.util.ArrayList; |
23 | |
import java.util.Calendar; |
24 | |
import java.util.Date; |
25 | |
import java.util.List; |
26 | |
|
27 | |
import javax.persistence.CascadeType; |
28 | |
import javax.persistence.Column; |
29 | |
import javax.persistence.Entity; |
30 | |
import javax.persistence.FetchType; |
31 | |
import javax.persistence.Id; |
32 | |
import javax.persistence.OneToMany; |
33 | |
import javax.persistence.Table; |
34 | |
import javax.persistence.Version; |
35 | |
|
36 | |
import org.hibernate.annotations.Fetch; |
37 | |
import org.hibernate.annotations.FetchMode; |
38 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
39 | |
import org.kuali.rice.core.util.RiceConstants; |
40 | |
import org.kuali.rice.edl.framework.extract.DumpDTO; |
41 | |
import org.kuali.rice.edl.framework.extract.FieldDTO; |
42 | |
import org.kuali.rice.kew.util.KEWConstants; |
43 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
@Entity |
53 | |
@Table(name="KREW_EDL_DMP_T") |
54 | |
|
55 | 0 | public class Dump { |
56 | |
|
57 | |
private static final long serialVersionUID = -6136544551121011531L; |
58 | |
|
59 | |
@Id |
60 | |
@Column(name="DOC_HDR_ID") |
61 | |
private String docId; |
62 | |
@Column(name="DOC_TYP_NM") |
63 | |
private String docTypeName; |
64 | |
@Column(name="DOC_HDR_STAT_CD") |
65 | |
private String docRouteStatusCode; |
66 | |
@Column(name="DOC_HDR_MDFN_DT") |
67 | |
private Timestamp docModificationDate; |
68 | |
@Column(name="DOC_HDR_CRTE_DT") |
69 | |
private Timestamp docCreationDate; |
70 | |
@Column(name="DOC_HDR_TTL") |
71 | |
private String docDescription; |
72 | |
@Column(name="DOC_HDR_INITR_PRNCPL_ID") |
73 | |
private String docInitiatorId; |
74 | |
@Column(name="CRNT_NODE_NM") |
75 | |
private String docCurrentNodeName; |
76 | |
@Version |
77 | |
@Column(name="VER_NBR") |
78 | |
private Integer lockVerNbr; |
79 | |
|
80 | 0 | @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE},mappedBy="dump") |
81 | |
@Fetch(value = FetchMode.SELECT) |
82 | |
private List<Fields> fields = new ArrayList<Fields>(); |
83 | |
|
84 | |
|
85 | |
public void beforeInsert(){ |
86 | 0 | OrmUtils.populateAutoIncValue(this, KNSServiceLocator.getEntityManagerFactory().createEntityManager()); |
87 | 0 | } |
88 | |
|
89 | |
|
90 | |
public Timestamp getDocCreationDate() { |
91 | 0 | return docCreationDate; |
92 | |
} |
93 | |
public void setDocCreationDate(final Timestamp docCreationDate) { |
94 | 0 | this.docCreationDate = docCreationDate; |
95 | 0 | } |
96 | |
public String getDocCurrentNodeName() { |
97 | 0 | return docCurrentNodeName; |
98 | |
} |
99 | |
public void setDocCurrentNodeName(final String docCurrentNodeName) { |
100 | 0 | this.docCurrentNodeName = docCurrentNodeName; |
101 | 0 | } |
102 | |
public String getDocDescription() { |
103 | 0 | return docDescription; |
104 | |
} |
105 | |
public void setDocDescription(final String docDescription) { |
106 | 0 | this.docDescription = docDescription; |
107 | 0 | } |
108 | |
public String getDocId() { |
109 | 0 | return docId; |
110 | |
} |
111 | |
public String getDocInitiatorId() { |
112 | 0 | return docInitiatorId; |
113 | |
} |
114 | |
public void setDocInitiatorId(final String docInitiatorId) { |
115 | 0 | this.docInitiatorId = docInitiatorId; |
116 | 0 | } |
117 | |
public Timestamp getDocModificationDate() { |
118 | 0 | return docModificationDate; |
119 | |
} |
120 | |
public void setDocModificationDate(final Timestamp docModificationDate) { |
121 | 0 | this.docModificationDate = docModificationDate; |
122 | 0 | } |
123 | |
public String getDocRouteStatusCode() { |
124 | 0 | return docRouteStatusCode; |
125 | |
} |
126 | |
public void setDocRouteStatusCode(final String docRouteStatusCode) { |
127 | 0 | this.docRouteStatusCode = docRouteStatusCode; |
128 | 0 | } |
129 | |
public String getDocTypeName() { |
130 | 0 | return docTypeName; |
131 | |
} |
132 | |
public void setDocTypeName(final String docTypeName) { |
133 | 0 | this.docTypeName = docTypeName; |
134 | 0 | } |
135 | |
public Integer getLockVerNbr() { |
136 | 0 | return lockVerNbr; |
137 | |
} |
138 | |
public void setLockVerNbr(final Integer lockVerNbr) { |
139 | 0 | this.lockVerNbr = lockVerNbr; |
140 | 0 | } |
141 | |
public String getFormattedCreateDateTime() { |
142 | 0 | long time = getDocCreationDate().getTime(); |
143 | 0 | Calendar calendar = Calendar.getInstance(); |
144 | 0 | calendar.setTimeInMillis(time); |
145 | 0 | Date date = calendar.getTime(); |
146 | 0 | DateFormat dateFormat = new SimpleDateFormat(KEWConstants.TIMESTAMP_DATE_FORMAT_PATTERN2); |
147 | 0 | return dateFormat.format(date); |
148 | |
} |
149 | |
|
150 | |
public String getFormattedCreateDate() { |
151 | 0 | long time = getDocCreationDate().getTime(); |
152 | 0 | Calendar calendar = Calendar.getInstance(); |
153 | 0 | calendar.setTimeInMillis(time); |
154 | 0 | Date date = calendar.getTime(); |
155 | 0 | DateFormat dateFormat = RiceConstants.getDefaultDateFormat(); |
156 | 0 | return dateFormat.format(date); |
157 | |
} |
158 | |
public void setDocId(final String docId) { |
159 | 0 | this.docId = docId; |
160 | 0 | } |
161 | |
|
162 | |
|
163 | |
public List<Fields> getFields() { |
164 | 0 | return fields; |
165 | |
} |
166 | |
|
167 | |
public void setFields(final List<Fields> fields) { |
168 | 0 | this.fields = fields; |
169 | 0 | } |
170 | |
|
171 | |
public static DumpDTO to(Dump dump) { |
172 | 0 | if (dump == null) { |
173 | 0 | return null; |
174 | |
} |
175 | 0 | DumpDTO dumpDTO = new DumpDTO(); |
176 | 0 | dumpDTO.setDocCreationDate(dump.getDocCreationDate()); |
177 | 0 | dumpDTO.setDocCurrentNodeName(dump.getDocCurrentNodeName()); |
178 | 0 | dumpDTO.setDocDescription(dump.getDocDescription()); |
179 | 0 | dumpDTO.setDocId(dump.getDocId()); |
180 | 0 | dumpDTO.setDocInitiatorId(dump.getDocInitiatorId()); |
181 | 0 | dumpDTO.setDocModificationDate(dump.getDocModificationDate()); |
182 | 0 | dumpDTO.setDocRouteStatusCode(dump.getDocRouteStatusCode()); |
183 | 0 | dumpDTO.setDocTypeName(dump.getDocTypeName()); |
184 | 0 | dumpDTO.setLockVerNbr(dump.getLockVerNbr()); |
185 | 0 | List<FieldDTO> fields = new ArrayList<FieldDTO>(); |
186 | 0 | for (Fields field : dump.getFields()) { |
187 | 0 | fields.add(Fields.to(field)); |
188 | |
} |
189 | 0 | dumpDTO.setFields(fields); |
190 | 0 | return dumpDTO; |
191 | |
} |
192 | |
|
193 | |
public static Dump from(DumpDTO dumpDTO) { |
194 | 0 | if (dumpDTO == null) { |
195 | 0 | return null; |
196 | |
} |
197 | 0 | Dump dump = new Dump(); |
198 | 0 | dump.setDocCreationDate(dumpDTO.getDocCreationDate()); |
199 | 0 | dump.setDocCurrentNodeName(dumpDTO.getDocCurrentNodeName()); |
200 | 0 | dump.setDocDescription(dumpDTO.getDocDescription()); |
201 | 0 | dump.setDocId(dumpDTO.getDocId()); |
202 | 0 | dump.setDocInitiatorId(dumpDTO.getDocInitiatorId()); |
203 | 0 | dump.setDocModificationDate(dumpDTO.getDocModificationDate()); |
204 | 0 | dump.setDocRouteStatusCode(dumpDTO.getDocRouteStatusCode()); |
205 | 0 | dump.setDocTypeName(dumpDTO.getDocTypeName()); |
206 | 0 | dump.setLockVerNbr(dumpDTO.getLockVerNbr()); |
207 | 0 | List<Fields> fields = new ArrayList<Fields>(); |
208 | 0 | for (FieldDTO fieldDTO : dumpDTO.getFields()) { |
209 | 0 | fields.add(Fields.from(fieldDTO, dump)); |
210 | |
} |
211 | 0 | dump.setFields(fields); |
212 | 0 | return dump; |
213 | |
} |
214 | |
|
215 | |
} |
216 | |
|