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 @Override
52 public ProcessorResult process(DictionaryValidationResult result, Object value, final SimpleConstraint constraint,
53 AttributeValueReader attributeValueReader) throws AttributeValidationException {
54
55 ProcessorResult dataTypePR = dataTypeConstraintProcessor.process(result, value, constraint,
56 attributeValueReader);
57 ProcessorResult existencePR = existenceConstraintProcessor.process(result, value, constraint,
58 attributeValueReader);
59 ProcessorResult rangePR = rangeConstraintProcessor.process(result, value, constraint, attributeValueReader);
60 ProcessorResult lengthPR = lengthConstraintProcessor.process(result, value, constraint, attributeValueReader);
61 List<ConstraintValidationResult> cvrList = new ArrayList<ConstraintValidationResult>();
62 cvrList.addAll(existencePR.getConstraintValidationResults());
63 cvrList.addAll(rangePR.getConstraintValidationResults());
64 cvrList.addAll(lengthPR.getConstraintValidationResults());
65 cvrList.addAll(dataTypePR.getConstraintValidationResults());
66 return new ProcessorResult(cvrList);
67 }
68
69 @Override
70 public String getName() {
71 return CONSTRAINT_NAME;
72 }
73
74 @Override
75 public Class<? extends Constraint> getConstraintType() {
76 return SimpleConstraint.class;
77 }
78 }