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 javax.persistence.CascadeType; |
20 | |
import javax.persistence.Column; |
21 | |
import javax.persistence.Entity; |
22 | |
import javax.persistence.FetchType; |
23 | |
import javax.persistence.GeneratedValue; |
24 | |
import javax.persistence.Id; |
25 | |
import javax.persistence.JoinColumn; |
26 | |
import javax.persistence.ManyToOne; |
27 | |
import javax.persistence.Table; |
28 | |
import javax.persistence.Version; |
29 | |
|
30 | |
import org.hibernate.annotations.GenericGenerator; |
31 | |
import org.hibernate.annotations.Parameter; |
32 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
33 | |
import org.kuali.rice.edl.framework.extract.FieldDTO; |
34 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@Entity |
44 | |
@Table(name="KREW_EDL_FLD_DMP_T") |
45 | |
|
46 | 0 | public class Fields { |
47 | |
|
48 | |
private static final long serialVersionUID = -6136544551121011531L; |
49 | |
|
50 | |
@Id |
51 | |
@GeneratedValue(generator="KREW_EDL_FLD_DMP_S") |
52 | |
@GenericGenerator(name="KREW_EDL_FLD_DMP_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
53 | |
@Parameter(name="sequence_name",value="KREW_EDL_FLD_DMP_S"), |
54 | |
@Parameter(name="value_column",value="id") |
55 | |
}) |
56 | |
@Column(name="EDL_FIELD_DMP_ID") |
57 | |
private Long fieldId; |
58 | |
@Column(name="DOC_HDR_ID") |
59 | |
private String docId; |
60 | |
@Column(name="FLD_NM") |
61 | |
private String fieldName; |
62 | |
@Column(name="FLD_VAL") |
63 | |
private String fieldValue; |
64 | |
@Version |
65 | |
@Column(name="VER_NBR") |
66 | |
private Integer lockVerNbr; |
67 | |
|
68 | |
@ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST}) |
69 | |
@JoinColumn(name="DOC_HDR_ID", insertable=false, updatable=false) |
70 | |
private Dump dump; |
71 | |
|
72 | |
|
73 | |
public void beforeInsert(){ |
74 | 0 | OrmUtils.populateAutoIncValue(this, KNSServiceLocator.getEntityManagerFactory().createEntityManager()); |
75 | 0 | } |
76 | |
|
77 | |
|
78 | |
public Long getFieldId() { |
79 | 0 | return fieldId; |
80 | |
} |
81 | |
public String getDocId() { |
82 | 0 | return docId; |
83 | |
} |
84 | |
public void setDocId(final String docId) { |
85 | 0 | this.docId = docId; |
86 | 0 | } |
87 | |
public String getFieldValue() { |
88 | 0 | return fieldValue; |
89 | |
} |
90 | |
public void setFieldValue(final String fieldValue) { |
91 | 0 | this.fieldValue = fieldValue; |
92 | 0 | } |
93 | |
public String getFiledName() { |
94 | 0 | return fieldName; |
95 | |
} |
96 | |
public void setFieldName(final String filedName) { |
97 | 0 | this.fieldName = filedName; |
98 | 0 | } |
99 | |
public Integer getLockVerNbr() { |
100 | 0 | return lockVerNbr; |
101 | |
} |
102 | |
public void setLockVerNbr(final Integer lockVerNbr) { |
103 | 0 | this.lockVerNbr = lockVerNbr; |
104 | 0 | } |
105 | |
public Dump getDump() { |
106 | 0 | return dump; |
107 | |
} |
108 | |
public void setDump(final Dump dump) { |
109 | 0 | this.dump = dump; |
110 | 0 | } |
111 | |
|
112 | |
public static FieldDTO to(Fields field) { |
113 | 0 | if (field == null) { |
114 | 0 | return null; |
115 | |
} |
116 | 0 | FieldDTO fieldDTO = new FieldDTO(); |
117 | 0 | fieldDTO.setDocId(field.getDocId()); |
118 | 0 | fieldDTO.setFieldName(field.getFiledName()); |
119 | 0 | fieldDTO.setFieldValue(field.getFieldValue()); |
120 | 0 | fieldDTO.setLockVerNbr(field.getLockVerNbr()); |
121 | 0 | return fieldDTO; |
122 | |
} |
123 | |
|
124 | |
public static Fields from(FieldDTO fieldDTO, Dump dump) { |
125 | 0 | if (fieldDTO == null) { |
126 | 0 | return null; |
127 | |
} |
128 | 0 | Fields fields = new Fields(); |
129 | 0 | fields.setDump(dump); |
130 | 0 | fields.setDocId(fieldDTO.getDocId()); |
131 | 0 | fields.setFieldName(fieldDTO.getFiledName()); |
132 | 0 | fields.setFieldValue(fieldDTO.getFieldValue()); |
133 | 0 | fields.setLockVerNbr(fieldDTO.getLockVerNbr()); |
134 | 0 | return fields; |
135 | |
} |
136 | |
} |
137 | |
|