1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository;
17
18 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
19 import org.kuali.rice.krms.api.repository.proposition.PropositionParameter;
20 import org.kuali.rice.krms.api.repository.proposition.PropositionParameterContract;
21 import org.kuali.rice.krms.api.repository.term.TermDefinition;
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.GeneratedValue;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.ManyToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Transient;
33 import javax.persistence.Version;
34 import java.io.Serializable;
35 import java.util.ArrayList;
36 import java.util.Collections;
37 import java.util.List;
38
39 @Entity
40 @Table(name = "KRMS_PROP_PARM_T")
41 public class PropositionParameterBo implements PropositionParameterContract, Serializable {
42
43 private static final long serialVersionUID = 1l;
44
45 @PortableSequenceGenerator(name = "KRMS_PROP_PARM_S")
46 @GeneratedValue(generator = "KRMS_PROP_PARM_S")
47 @Id
48 @Column(name = "PROP_PARM_ID")
49 private String id;
50
51 @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.PERSIST })
52 @JoinColumn(name = "PROP_ID")
53 private PropositionBo proposition;
54
55 @Column(name = "PARM_VAL")
56 private String value;
57
58 @Column(name = "PARM_TYP_CD")
59 private String parameterType;
60
61 @Column(name = "SEQ_NO")
62 private Integer sequenceNumber;
63
64 @Transient
65 private TermDefinition termValue;
66
67 @Column(name = "VER_NBR")
68 private Long versionNumber = 0l;
69
70 public TermDefinition getTermValue() {
71 return termValue;
72 }
73
74 public void setTermValue(TermDefinition termValue) {
75 if (termValue != null) {
76 value = termValue.getId();
77 }
78
79 this.termValue = termValue;
80 }
81
82
83
84
85
86
87
88 public static PropositionParameter to(PropositionParameterBo bo) {
89 if (bo == null) {
90 return null;
91 }
92
93 return PropositionParameter.Builder.create(bo).build();
94 }
95
96
97
98
99
100
101
102 public static List<PropositionParameter> to(List<PropositionParameterBo> bos) {
103 if (bos == null) {
104 return null;
105 }
106
107 List<PropositionParameter> parms = new ArrayList<PropositionParameter>();
108
109 for (PropositionParameterBo p : bos) {
110 parms.add(PropositionParameter.Builder.create(p).build());
111 }
112
113 return Collections.unmodifiableList(parms);
114 }
115
116
117
118
119
120
121
122 public static PropositionParameterBo from(PropositionParameter im) {
123 if (im == null) {
124 return null;
125 }
126
127 PropositionParameterBo bo = new PropositionParameterBo();
128 bo.id = im.getId();
129
130
131
132 bo.value = im.getValue();
133 bo.setTermValue(im.getTermValue());
134 bo.parameterType = im.getParameterType();
135 bo.sequenceNumber = im.getSequenceNumber();
136
137 if (im.getVersionNumber() == null) {
138 bo.setVersionNumber(0l);
139 } else {
140 bo.setVersionNumber(im.getVersionNumber());
141 }
142
143 return bo;
144 }
145
146 public static List<PropositionParameterBo> from(List<PropositionParameter> ims) {
147 if (ims == null) {
148 return null;
149 }
150
151 List<PropositionParameterBo> bos = new ArrayList<PropositionParameterBo>();
152 for (PropositionParameter im : ims) {
153 PropositionParameterBo bo = new PropositionParameterBo();
154 bo.id = im.getId();
155
156
157
158 bo.value = im.getValue();
159 bo.parameterType = im.getParameterType();
160 bo.sequenceNumber = im.getSequenceNumber();
161 bo.setVersionNumber(im.getVersionNumber());
162 bos.add(bo);
163 }
164
165 return Collections.unmodifiableList(bos);
166 }
167
168 public String getId() {
169 return id;
170 }
171
172 public void setId(String id) {
173 this.id = id;
174 }
175
176 public String getPropId() {
177 if (proposition != null) {
178 return proposition.getId();
179 }
180
181 return null;
182 }
183
184 public PropositionBo getProposition() {
185 return proposition;
186 }
187
188 public void setProposition(PropositionBo proposition) {
189 this.proposition = proposition;
190 }
191
192 public String getValue() {
193 return value;
194 }
195
196 public void setValue(String value) {
197 this.value = value;
198 }
199
200 public String getParameterType() {
201 return parameterType;
202 }
203
204 public void setParameterType(String parameterType) {
205 this.parameterType = parameterType;
206 }
207
208 public Integer getSequenceNumber() {
209 return sequenceNumber;
210 }
211
212 public void setSequenceNumber(Integer sequenceNumber) {
213 this.sequenceNumber = sequenceNumber;
214 }
215
216 public Long getVersionNumber() {
217 return versionNumber;
218 }
219
220 public void setVersionNumber(Long versionNumber) {
221 this.versionNumber = versionNumber;
222 }
223 }