1 |
|
package org.kuali.rice.krms.api.repository; |
2 |
|
|
3 |
|
import java.io.Serializable; |
4 |
|
import java.util.ArrayList; |
5 |
|
import java.util.Arrays; |
6 |
|
import java.util.Collection; |
7 |
|
import java.util.Collections; |
8 |
|
import java.util.List; |
9 |
|
|
10 |
|
import javax.xml.bind.annotation.XmlAccessType; |
11 |
|
import javax.xml.bind.annotation.XmlAccessorType; |
12 |
|
import javax.xml.bind.annotation.XmlAnyElement; |
13 |
|
import javax.xml.bind.annotation.XmlElement; |
14 |
|
import javax.xml.bind.annotation.XmlRootElement; |
15 |
|
import javax.xml.bind.annotation.XmlType; |
16 |
|
|
17 |
|
import org.apache.commons.lang.StringUtils; |
18 |
|
import org.apache.commons.lang.builder.EqualsBuilder; |
19 |
|
import org.apache.commons.lang.builder.HashCodeBuilder; |
20 |
|
import org.apache.commons.lang.builder.ToStringBuilder; |
21 |
|
import org.kuali.rice.core.api.CoreConstants; |
22 |
|
import org.kuali.rice.core.api.mo.ModelBuilder; |
23 |
|
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
24 |
|
|
25 |
|
import org.kuali.rice.krms.api.LogicalOperator; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@see |
43 |
|
|
44 |
|
@see |
45 |
|
@see |
46 |
|
|
47 |
|
@XmlRootElement(name = Proposition.Constants.ROOT_ELEMENT_NAME) |
48 |
|
@XmlAccessorType(XmlAccessType.NONE) |
49 |
|
@XmlType(name = Proposition.Constants.TYPE_NAME, propOrder = { |
50 |
|
Proposition.Elements.PROP_ID, |
51 |
|
Proposition.Elements.DESC, |
52 |
|
Proposition.Elements.TYPE_ID, |
53 |
|
Proposition.Elements.PROP_TYPE_CODE, |
54 |
|
"parameters", |
55 |
|
Proposition.Elements.CMPND_OP_CODE, |
56 |
|
"compoundComponents", |
57 |
|
CoreConstants.CommonElements.FUTURE_ELEMENTS |
58 |
|
}) |
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 13 |
Complexity Density: 0.42 |
|
59 |
|
public final class Proposition implements PropositionContract, ModelObjectComplete{ |
60 |
|
private static final long serialVersionUID = 2783959459503209577L; |
61 |
|
|
62 |
|
@XmlElement(name = Elements.PROP_ID, required=true) |
63 |
|
private String propId; |
64 |
|
|
65 |
|
@XmlElement(name = Elements.DESC, required=true) |
66 |
|
private String description; |
67 |
|
|
68 |
|
@XmlElement(name = Elements.TYPE_ID, required=true) |
69 |
|
private String typeId; |
70 |
|
|
71 |
|
@XmlElement(name = Elements.PROP_TYPE_CODE, required=true) |
72 |
|
private String propositionTypeCode; |
73 |
|
|
74 |
|
@XmlElement(name = Elements.PARAMETERS, required=false) |
75 |
|
private List<PropositionParameter> parameters; |
76 |
|
|
77 |
|
@XmlElement(name = Elements.CMPND_OP_CODE, required=false) |
78 |
|
private String compoundOpCode; |
79 |
|
|
80 |
|
@XmlElement(name = Elements.CMPND_COMPONENTS, required=false) |
81 |
|
private List<Proposition> compoundComponents; |
82 |
|
|
83 |
|
@SuppressWarnings("unused") |
84 |
|
@XmlAnyElement |
85 |
|
private final Collection<org.w3c.dom.Element> _futureElements = null; |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
91 |
0
|
private Proposition() {... |
92 |
0
|
this.propId = null; |
93 |
0
|
this.description = null; |
94 |
0
|
this.typeId = null; |
95 |
0
|
this.propositionTypeCode = null; |
96 |
0
|
this.parameters = null; |
97 |
0
|
this.compoundOpCode = null; |
98 |
0
|
this.compoundComponents = null; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
@param |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 2 |
Complexity Density: 0.14 |
|
107 |
0
|
private Proposition(Builder builder) {... |
108 |
0
|
this.propId = builder.getPropId(); |
109 |
0
|
this.description = builder.getDescription(); |
110 |
0
|
this.typeId = builder.getTypeId(); |
111 |
0
|
this.propositionTypeCode = builder.getPropositionTypeCode(); |
112 |
|
|
113 |
|
|
114 |
0
|
List<PropositionParameter> paramList = new ArrayList<PropositionParameter>(); |
115 |
0
|
for (PropositionParameter.Builder b : builder.parameters){ |
116 |
0
|
paramList.add(b.build()); |
117 |
|
} |
118 |
0
|
this.parameters = Collections.unmodifiableList(paramList); |
119 |
|
|
120 |
|
|
121 |
0
|
this.compoundOpCode = builder.getCompoundOpCode(); |
122 |
0
|
List <Proposition> componentList = new ArrayList<Proposition>(); |
123 |
0
|
if (builder.compoundComponents != null){ |
124 |
0
|
for (Proposition.Builder b : builder.compoundComponents){ |
125 |
0
|
componentList.add(b.build()); |
126 |
|
} |
127 |
|
} |
128 |
0
|
this.compoundComponents = Collections.unmodifiableList(componentList); |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0
|
@Override... |
132 |
|
public String getPropId() { |
133 |
0
|
return this.propId; |
134 |
|
} |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
0
|
@Override... |
137 |
|
public String getDescription() { |
138 |
0
|
return this.description; |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0
|
@Override... |
142 |
|
public String getTypeId() { |
143 |
0
|
return this.typeId; |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0
|
@Override... |
147 |
|
public String getPropositionTypeCode() { |
148 |
0
|
return this.propositionTypeCode; |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0
|
@Override... |
152 |
|
public List<PropositionParameter> getParameters() { |
153 |
0
|
return this.parameters; |
154 |
|
} |
155 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
0
|
@Override... |
157 |
|
public String getCompoundOpCode() { |
158 |
0
|
return this.compoundOpCode; |
159 |
|
} |
160 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
161 |
0
|
@Override... |
162 |
|
public List<Proposition> getCompoundComponents() { |
163 |
0
|
return this.compoundComponents; |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
@link |
168 |
|
|
|
|
| 0% |
Uncovered Elements: 107 (107) |
Complexity: 35 |
Complexity Density: 0.57 |
|
169 |
|
public static class Builder implements PropositionContract, ModelBuilder, Serializable { |
170 |
|
private static final long serialVersionUID = -6889320709850568900L; |
171 |
|
|
172 |
|
private String propId; |
173 |
|
private String description; |
174 |
|
private String typeId; |
175 |
|
private String propositionTypeCode; |
176 |
|
private List<PropositionParameter.Builder> parameters; |
177 |
|
private String compoundOpCode; |
178 |
|
private List<Proposition.Builder> compoundComponents; |
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
183 |
0
|
private Builder(String propId, String desc, String typeId, String propTypeCode, List<PropositionParameter.Builder> parameters) {... |
184 |
0
|
setPropId(propId); |
185 |
0
|
setDescription(desc); |
186 |
0
|
setTypeId(typeId); |
187 |
0
|
setPropositionTypeCode(propTypeCode); |
188 |
0
|
setParameters(parameters); |
189 |
|
} |
190 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
191 |
0
|
public Builder compoundOpCode(String opCode){... |
192 |
0
|
setCompoundOpCode(opCode); |
193 |
0
|
return this; |
194 |
|
} |
195 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
196 |
0
|
public Builder compoundComponents (List<Proposition.Builder> components){... |
197 |
0
|
setCompoundComponents(components); |
198 |
0
|
return this; |
199 |
|
} |
200 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
201 |
0
|
public static Builder create(String propId, String desc, String typeId, String propTypeCode, List<PropositionParameter.Builder> parameters){... |
202 |
0
|
return new Builder(propId, desc, typeId, propTypeCode, parameters); |
203 |
|
} |
204 |
|
|
205 |
|
@link |
206 |
|
|
207 |
|
@param |
208 |
|
@return |
209 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
210 |
0
|
public static Builder create(PropositionContract contract) {... |
211 |
0
|
if (contract == null) { |
212 |
0
|
throw new IllegalArgumentException("contract is null"); |
213 |
|
} |
214 |
0
|
List <PropositionParameter.Builder> paramBuilderList = new ArrayList<PropositionParameter.Builder>(); |
215 |
0
|
if (contract.getParameters() != null){ |
216 |
0
|
for (PropositionParameterContract paramContract : contract.getParameters()){ |
217 |
0
|
PropositionParameter.Builder myBuilder = PropositionParameter.Builder.create(paramContract); |
218 |
0
|
paramBuilderList.add(myBuilder); |
219 |
|
} |
220 |
|
} |
221 |
0
|
List <Proposition.Builder> componentBuilderList = new ArrayList<Proposition.Builder>(); |
222 |
0
|
if (contract.getCompoundComponents() != null) { |
223 |
0
|
for (PropositionContract cContract : contract.getCompoundComponents()){ |
224 |
0
|
Proposition.Builder pBuilder = Proposition.Builder.create(cContract); |
225 |
0
|
componentBuilderList.add(pBuilder); |
226 |
|
} |
227 |
|
} |
228 |
0
|
Builder builder = new Builder(contract.getPropId(), contract.getDescription(), |
229 |
|
contract.getTypeId(), contract.getPropositionTypeCode(), paramBuilderList) |
230 |
|
.compoundOpCode(contract.getCompoundOpCode()) |
231 |
|
.compoundComponents(componentBuilderList); |
232 |
0
|
return builder; |
233 |
|
} |
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
@param |
239 |
|
@throws |
240 |
|
|
241 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
242 |
0
|
public void setPropId(String propId) {... |
243 |
0
|
if (StringUtils.isBlank(propId)) { |
244 |
0
|
throw new IllegalArgumentException("propId is blank"); |
245 |
|
} |
246 |
0
|
this.propId = propId; |
247 |
|
} |
248 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
249 |
0
|
public void setDescription(String desc) {... |
250 |
0
|
if (StringUtils.isBlank(desc)) { |
251 |
0
|
throw new IllegalArgumentException("description is blank"); |
252 |
|
} |
253 |
0
|
this.description = desc; |
254 |
|
} |
255 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
256 |
0
|
public void setTypeId(String typeId) {... |
257 |
0
|
if (StringUtils.isBlank(typeId)) { |
258 |
0
|
throw new IllegalArgumentException("KRMS type id is blank"); |
259 |
|
} |
260 |
|
|
261 |
0
|
this.typeId = typeId; |
262 |
|
} |
263 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
264 |
0
|
public void setPropositionTypeCode(String propTypeCode) {... |
265 |
0
|
if (StringUtils.isBlank(propTypeCode)) { |
266 |
0
|
throw new IllegalArgumentException("proposition type code is blank"); |
267 |
|
} |
268 |
0
|
if (!PropositionTypes.VALID_TYPE_CODES.contains(propTypeCode)) { |
269 |
0
|
throw new IllegalArgumentException("invalid proposition type code"); |
270 |
|
} |
271 |
0
|
this.propositionTypeCode = propTypeCode; |
272 |
|
} |
273 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
274 |
0
|
public void setParameters(List<PropositionParameter.Builder> parameters){... |
275 |
|
|
276 |
|
|
277 |
0
|
if (parameters == null || parameters.isEmpty()){ |
278 |
0
|
if (PropositionTypes.COMPOUND.code().equals( this.propositionTypeCode)){ |
279 |
0
|
this.parameters = Collections.unmodifiableList(new ArrayList<PropositionParameter.Builder>()); |
280 |
0
|
return; |
281 |
|
} else { |
282 |
0
|
throw new IllegalArgumentException("no proposition parameters are specified"); |
283 |
|
} |
284 |
|
} |
285 |
0
|
this.parameters = Collections.unmodifiableList(parameters); |
286 |
|
} |
287 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
288 |
0
|
public void setCompoundOpCode(String opCode){... |
289 |
0
|
if (StringUtils.isBlank(opCode)){ return; } |
290 |
0
|
if (!LogicalOperator.OP_CODES.contains(opCode)){ |
291 |
0
|
throw new IllegalArgumentException("invalid opCode value"); |
292 |
|
} |
293 |
0
|
this.compoundOpCode = opCode; |
294 |
|
} |
295 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
296 |
0
|
public void setCompoundComponents(List<Proposition.Builder> components){... |
297 |
0
|
if (components == null || components.isEmpty()){ |
298 |
0
|
this.compoundComponents = Collections.unmodifiableList(new ArrayList<Proposition.Builder>()); |
299 |
0
|
return; |
300 |
|
} |
301 |
0
|
this.compoundComponents = Collections.unmodifiableList(components); |
302 |
|
} |
303 |
|
|
304 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
305 |
0
|
@Override... |
306 |
|
public String getPropId() { |
307 |
0
|
return propId; |
308 |
|
} |
309 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
310 |
0
|
@Override... |
311 |
|
public String getDescription() { |
312 |
0
|
return description; |
313 |
|
} |
314 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
315 |
0
|
@Override... |
316 |
|
public String getTypeId() { |
317 |
0
|
return typeId; |
318 |
|
} |
319 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
320 |
0
|
@Override... |
321 |
|
public String getPropositionTypeCode() { |
322 |
0
|
return propositionTypeCode; |
323 |
|
} |
324 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
325 |
0
|
@Override... |
326 |
|
public List<PropositionParameter.Builder> getParameters() { |
327 |
0
|
return parameters; |
328 |
|
} |
329 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
330 |
0
|
@Override... |
331 |
|
public String getCompoundOpCode() { |
332 |
0
|
return compoundOpCode; |
333 |
|
} |
334 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
335 |
0
|
@Override... |
336 |
|
public List<Proposition.Builder> getCompoundComponents() { |
337 |
0
|
return compoundComponents; |
338 |
|
} |
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
@return |
344 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
345 |
0
|
@Override... |
346 |
|
public Proposition build() { |
347 |
0
|
return new Proposition(this); |
348 |
|
} |
349 |
|
|
350 |
|
} |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
351 |
0
|
@Override... |
352 |
|
public int hashCode() { |
353 |
0
|
return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
354 |
|
} |
355 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
356 |
0
|
@Override... |
357 |
|
public boolean equals(Object obj) { |
358 |
0
|
return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
359 |
|
} |
360 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
361 |
0
|
@Override... |
362 |
|
public String toString() { |
363 |
0
|
return ToStringBuilder.reflectionToString(this); |
364 |
|
} |
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
369 |
|
static class Constants { |
370 |
|
final static String ROOT_ELEMENT_NAME = "Proposition"; |
371 |
|
final static String TYPE_NAME = "PropositionType"; |
372 |
|
final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
373 |
|
} |
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
379 |
|
public static class Elements { |
380 |
|
final static String PROP_ID = "propId"; |
381 |
|
final static String DESC = "description"; |
382 |
|
final static String TYPE_ID = "typeId"; |
383 |
|
final static String PROP_TYPE_CODE = "propositionTypeCode"; |
384 |
|
final static String PARAMETERS = "parameter"; |
385 |
|
final static String CMPND_OP_CODE = "compoundOpCode"; |
386 |
|
final static String CMPND_COMPONENTS = "proposition"; |
387 |
|
} |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
397 |
|
public enum PropositionTypes { |
398 |
|
SIMPLE("S"), |
399 |
|
PARAMETERIZED("P"), |
400 |
|
COMPOUND("C"); |
401 |
|
|
402 |
|
private final String code; |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
403 |
0
|
private PropositionTypes(String code){... |
404 |
0
|
this.code = code; |
405 |
|
} |
406 |
|
public static final Collection<Proposition.PropositionTypes> VALID_TYPES = |
407 |
|
Collections.unmodifiableCollection(Arrays.asList(SIMPLE, PARAMETERIZED, COMPOUND)); |
408 |
|
|
409 |
|
public static final Collection<String> VALID_TYPE_CODES = |
410 |
|
Collections.unmodifiableCollection(Arrays.asList(SIMPLE.code(), PARAMETERIZED.code(), COMPOUND.code())); |
411 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
412 |
0
|
public String code(){... |
413 |
0
|
return code; |
414 |
|
} |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
415 |
0
|
@Override... |
416 |
|
public String toString() { |
417 |
0
|
return code; |
418 |
|
} |
419 |
|
} |
420 |
|
} |