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 | |
|
33 | |
private DictionaryModel model; |
34 | |
private ModelFinder finder; |
35 | |
|
36 | |
public OrchestrationModelValidator (DictionaryModel model) |
37 | 0 | { |
38 | 0 | this.model = model; |
39 | 0 | this.finder = new ModelFinder (model); |
40 | 0 | } |
41 | |
|
42 | |
List<String> errors; |
43 | |
|
44 | |
@Override |
45 | |
public Collection<String> validate () |
46 | |
{ |
47 | 0 | errors = new ArrayList (); |
48 | 0 | validateOrchObjs (); |
49 | 0 | errors.addAll (new DictionaryModelValidator (model).validate ()); |
50 | 0 | return errors; |
51 | |
} |
52 | |
|
53 | |
private void validateOrchObjs () |
54 | |
{ |
55 | 0 | if (model.getOrchObjs ().size () == 0) |
56 | |
{ |
57 | 0 | addError ("No orchestration objects found"); |
58 | |
} |
59 | 0 | for (OrchObj orch : model.getOrchObjs ()) |
60 | |
{ |
61 | 0 | OrchObjValidator cv = new OrchObjValidator (orch); |
62 | 0 | errors.addAll (cv.validate ()); |
63 | 0 | } |
64 | 0 | } |
65 | |
|
66 | |
private void addError (String msg) |
67 | |
{ |
68 | 0 | String error = "Error in orchestration dictionary spreadsheet: " + msg; |
69 | 0 | if ( ! errors.contains (error)) |
70 | |
{ |
71 | 0 | errors.add (error); |
72 | |
} |
73 | 0 | } |
74 | |
|
75 | |
} |