1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.contract.model.validation; |
17 | |
|
18 | |
import org.kuali.student.contract.model.DictionaryModel; |
19 | |
import org.kuali.student.contract.model.OrchObj; |
20 | |
import org.kuali.student.contract.model.util.ModelFinder; |
21 | |
|
22 | |
import java.util.ArrayList; |
23 | |
import java.util.Collection; |
24 | |
import java.util.List; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class OrchestrationModelValidator implements ModelValidator { |
31 | |
|
32 | |
private DictionaryModel model; |
33 | |
private ModelFinder finder; |
34 | |
|
35 | 0 | public OrchestrationModelValidator(DictionaryModel model) { |
36 | 0 | this.model = model; |
37 | 0 | this.finder = new ModelFinder(model); |
38 | 0 | } |
39 | |
List<String> errors; |
40 | |
|
41 | |
@Override |
42 | |
public Collection<String> validate() { |
43 | 0 | errors = new ArrayList(); |
44 | 0 | validateOrchObjs(); |
45 | 0 | errors.addAll(new DictionaryModelValidator(model).validate()); |
46 | 0 | return errors; |
47 | |
} |
48 | |
|
49 | |
private void validateOrchObjs() { |
50 | 0 | if (model.getOrchObjs().size() == 0) { |
51 | 0 | addError("No orchestration objects found"); |
52 | |
} |
53 | 0 | for (OrchObj orch : model.getOrchObjs()) { |
54 | 0 | OrchObjValidator cv = new OrchObjValidator(orch); |
55 | 0 | errors.addAll(cv.validate()); |
56 | 0 | } |
57 | 0 | } |
58 | |
|
59 | |
private void addError(String msg) { |
60 | 0 | String error = "Error in orchestration dictionary spreadsheet: " + msg; |
61 | 0 | if (!errors.contains(error)) { |
62 | 0 | errors.add(error); |
63 | |
} |
64 | 0 | } |
65 | |
} |