1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.datadictionary; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Iterator; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.kuali.student.common.dto.ValidationResultInfo; |
23 | |
import org.kuali.student.common.infc.ValidationResult; |
24 | |
|
25 | |
import org.kuali.rice.kns.datadictionary.validation.ErrorLevel; |
26 | |
import org.kuali.rice.kns.datadictionary.validation.result.DictionaryValidationResult; |
27 | |
import org.kuali.rice.kns.datadictionary.validation.result.ConstraintValidationResult; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class Rice2ValidationResultConverter { |
34 | |
|
35 | 0 | private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(Rice2ValidationResultConverter.class); |
36 | |
|
37 | |
public List<ValidationResultInfo> convert(DictionaryValidationResult riceResult) { |
38 | 0 | List<ValidationResultInfo> vrs = new ArrayList<ValidationResultInfo>(); |
39 | 0 | Iterator<ConstraintValidationResult> it = riceResult.iterator(); |
40 | 0 | while (it.hasNext()) { |
41 | 0 | ValidationResultInfo vr = null; |
42 | 0 | ConstraintValidationResult cvr = it.next(); |
43 | 0 | switch (cvr.getStatus()) { |
44 | |
case OK: |
45 | 0 | continue; |
46 | |
case NOCONSTRAINT: |
47 | 0 | continue; |
48 | |
case INAPPLICABLE: |
49 | 0 | continue; |
50 | |
case ERROR: |
51 | 0 | ValidationResultInfo.Builder vrBuilder = new ValidationResultInfo.Builder(); |
52 | 0 | vrBuilder.setElement(cvr.getAttributeName()); |
53 | 0 | vrBuilder.setError(cvr.getErrorKey()); |
54 | 0 | vrs.add(vrBuilder.build()); |
55 | |
case WARN: |
56 | 0 | LOG.debug("Skipping warning " + cvr.getEntryName() |
57 | |
+ "." + cvr.getAttributeName() + " " + |
58 | |
cvr.getErrorKey() + " " + cvr.getConstraintName()); |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
} |
64 | 0 | } |
65 | 0 | return vrs; |
66 | |
} |
67 | |
} |