1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.processor;
17
18 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
19 import org.kuali.rice.krad.datadictionary.validation.AttributeValueReader;
20 import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint;
21 import org.kuali.rice.krad.datadictionary.validation.constraint.SimpleConstraint;
22 import org.kuali.rice.krad.datadictionary.validation.result.ConstraintValidationResult;
23 import org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult;
24 import org.kuali.rice.krad.datadictionary.validation.result.ProcessorResult;
25
26 import java.util.ArrayList;
27 import java.util.List;
28
29
30
31
32
33 public class SimpleConstraintProcessor extends MandatoryElementConstraintProcessor<SimpleConstraint> {
34
35 private static final String CONSTRAINT_NAME = "simple constraint";
36
37 RangeConstraintProcessor rangeConstraintProcessor = new RangeConstraintProcessor();
38 LengthConstraintProcessor lengthConstraintProcessor = new LengthConstraintProcessor();
39 ExistenceConstraintProcessor existenceConstraintProcessor = new ExistenceConstraintProcessor();
40 DataTypeConstraintProcessor dataTypeConstraintProcessor = new DataTypeConstraintProcessor();
41
42
43
44
45
46
47
48
49
50
51
52 @Override
53 public ProcessorResult process(DictionaryValidationResult result, Object value, final SimpleConstraint constraint,
54 AttributeValueReader attributeValueReader) throws AttributeValidationException {
55
56 ProcessorResult dataTypePR = dataTypeConstraintProcessor.process(result, value, constraint,
57 attributeValueReader);
58 ProcessorResult existencePR = existenceConstraintProcessor.process(result, value, constraint,
59 attributeValueReader);
60 ProcessorResult rangePR = rangeConstraintProcessor.process(result, value, constraint, attributeValueReader);
61 ProcessorResult lengthPR = lengthConstraintProcessor.process(result, value, constraint, attributeValueReader);
62 List<ConstraintValidationResult> cvrList = new ArrayList<ConstraintValidationResult>();
63 cvrList.addAll(existencePR.getConstraintValidationResults());
64 cvrList.addAll(rangePR.getConstraintValidationResults());
65 cvrList.addAll(lengthPR.getConstraintValidationResults());
66 cvrList.addAll(dataTypePR.getConstraintValidationResults());
67 return new ProcessorResult(cvrList);
68 }
69
70 @Override
71 public String getName() {
72 return CONSTRAINT_NAME;
73 }
74
75 @Override
76 public Class<? extends Constraint> getConstraintType() {
77 return SimpleConstraint.class;
78 }
79 }