1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.impl.parameter;
17
18
19 import javax.persistence.Column;
20 import javax.persistence.Entity;
21 import javax.persistence.FetchType;
22 import javax.persistence.Id;
23 import javax.persistence.IdClass;
24 import javax.persistence.JoinColumn;
25 import javax.persistence.JoinColumns;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.OneToOne;
28 import javax.persistence.Table;
29
30 import org.kuali.rice.coreservice.api.parameter.EvaluationOperator;
31 import org.kuali.rice.coreservice.framework.parameter.ParameterEbo;
32 import org.kuali.rice.coreservice.impl.component.ComponentBo;
33 import org.kuali.rice.coreservice.impl.component.DerivedComponentBo;
34 import org.kuali.rice.coreservice.impl.namespace.NamespaceBo;
35 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
36 import org.kuali.rice.krad.data.jpa.DisableVersioning;
37 import org.kuali.rice.krad.data.jpa.RemoveMapping;
38 import org.kuali.rice.krad.data.jpa.RemoveMappings;
39
40 @IdClass(ParameterId.class)
41 @Entity
42 @Table(name = "KRCR_PARM_T")
43 @DisableVersioning
44 @RemoveMappings({
45 @RemoveMapping(name = "versionNumber")
46 })
47 public class ParameterBo extends PersistableBusinessObjectBase implements ParameterEbo {
48
49 private static final long serialVersionUID = 1L;
50
51 @Id
52 @Column(name = "NMSPC_CD")
53 private String namespaceCode;
54
55 @Id
56 @Column(name = "CMPNT_CD")
57 private String componentCode;
58
59 @Id
60 @Column(name = "PARM_NM")
61 private String name;
62
63 @Id
64 @Column(name = "APPL_ID")
65 private String applicationId;
66
67 @Column(name = "VAL")
68 private String value;
69
70 @Column(name = "PARM_DESC_TXT", length = 2048)
71 private String description;
72
73 @Column(name = "PARM_TYP_CD")
74 private String parameterTypeCode;
75
76 @Column(name = "EVAL_OPRTR_CD")
77 private String evaluationOperatorCode;
78
79 @ManyToOne(fetch = FetchType.LAZY)
80 @JoinColumn(name = "NMSPC_CD", insertable = false, updatable = false)
81 private NamespaceBo namespace;
82
83 @OneToOne(fetch = FetchType.LAZY)
84 @JoinColumn(name = "PARM_TYP_CD", insertable = false, updatable = false)
85 private ParameterTypeBo parameterType;
86
87 @OneToOne(targetEntity = ComponentBo.class, fetch = FetchType.LAZY)
88 @JoinColumns({@JoinColumn(name = "NMSPC_CD", referencedColumnName="NMSPC_CD", insertable = false, updatable = false),
89 @JoinColumn(name = "CMPNT_CD", referencedColumnName="CMPNT_CD",insertable = false, updatable = false)})
90 private ComponentBo component;
91
92 @OneToOne(fetch = FetchType.LAZY)
93 @JoinColumns({@JoinColumn(name = "NMSPC_CD", referencedColumnName="NMSPC_CD", insertable = false, updatable = false),
94 @JoinColumn(name = "CMPNT_CD", referencedColumnName="CMPNT_CD",insertable = false, updatable = false)})
95 private DerivedComponentBo derivedComponent;
96
97
98
99
100
101
102 public static org.kuali.rice.coreservice.api.parameter.Parameter to(ParameterBo bo) {
103 if (bo == null) {
104 return null;
105 }
106
107 return org.kuali.rice.coreservice.api.parameter.Parameter.Builder.create(bo).build();
108 }
109
110
111
112
113
114
115 public static ParameterBo from(org.kuali.rice.coreservice.api.parameter.Parameter im) {
116 if (im == null) {
117 return null;
118 }
119
120 ParameterBo bo = new ParameterBo();
121 bo.setNamespaceCode(im.getNamespaceCode());
122 bo.setComponentCode(im.getComponentCode());
123 bo.setName(im.getName());
124 bo.setApplicationId(im.getApplicationId());
125 bo.setValue(im.getValue());
126 bo.setDescription(im.getDescription());
127 bo.setParameterTypeCode(im.getParameterType().getCode());
128 if(null != im.getEvaluationOperator()){
129 bo.setEvaluationOperatorCode(im.getEvaluationOperator().getCode());
130 }
131 bo.setParameterType(ParameterTypeBo.from(im.getParameterType()));
132 bo.setVersionNumber(im.getVersionNumber());
133 bo.setObjectId(im.getObjectId());
134 return bo;
135 }
136
137 @Override
138 public ParameterTypeBo getParameterType() {
139 return this.parameterType;
140 }
141
142 @Override
143 public EvaluationOperator getEvaluationOperator() {
144 return EvaluationOperator.fromCode(evaluationOperatorCode);
145 }
146
147 @Override
148 public String getNamespaceCode() {
149 return namespaceCode;
150 }
151
152 public void setNamespaceCode(String namespaceCode) {
153 this.namespaceCode = namespaceCode;
154 }
155
156 @Override
157 public String getComponentCode() {
158 return componentCode;
159 }
160
161 public void setComponentCode(String componentCode) {
162 this.componentCode = componentCode;
163 }
164
165 @Override
166 public String getName() {
167 return name;
168 }
169
170 public void setName(String name) {
171 this.name = name;
172 }
173
174 @Override
175 public String getApplicationId() {
176 return applicationId;
177 }
178
179 public void setApplicationId(String applicationId) {
180 this.applicationId = applicationId;
181 }
182
183 @Override
184 public String getValue() {
185 return value;
186 }
187
188 public void setValue(String value) {
189 this.value = value;
190 }
191
192 @Override
193 public String getDescription() {
194 return description;
195 }
196
197 public void setDescription(String description) {
198 this.description = description;
199 }
200
201 public String getParameterTypeCode() {
202 return parameterTypeCode;
203 }
204
205 public void setParameterTypeCode(String parameterTypeCode) {
206 this.parameterTypeCode = parameterTypeCode;
207 }
208
209 public void setParameterType(ParameterTypeBo parameterType) {
210 this.parameterType = parameterType;
211 }
212
213
214
215
216
217
218
219
220 public String getEvaluationOperatorCode() {
221 return evaluationOperatorCode;
222 }
223
224 public void setEvaluationOperatorCode(String evaluationOperatorCode) {
225 this.evaluationOperatorCode = evaluationOperatorCode;
226 }
227
228 public NamespaceBo getNamespace() {
229 return namespace;
230 }
231
232 public void setNamespace(NamespaceBo namespace) {
233 this.namespace = namespace;
234 }
235
236 public ComponentBo getComponent() {
237 return component;
238 }
239
240 public void setComponent(ComponentBo component) {
241 this.component = component;
242 }
243
244 public DerivedComponentBo getDerivedComponent() {
245 return derivedComponent;
246 }
247
248 public void setDerivedComponent(DerivedComponentBo derivedComponent) {
249 this.derivedComponent = derivedComponent;
250 }
251
252 public ParameterId getParameterId() {
253 return new ParameterId(this.namespaceCode, this.componentCode, this.name, this.applicationId);
254 }
255
256 }
257