|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.deri.wsmo4j.validator; |
|
17 |
| |
|
18 |
| |
|
19 |
| import java.util.Iterator; |
|
20 |
| import java.util.List; |
|
21 |
| |
|
22 |
| import org.omwg.logicalexpression.LogicalExpression; |
|
23 |
| import org.omwg.ontology.Axiom; |
|
24 |
| import org.omwg.ontology.Concept; |
|
25 |
| import org.omwg.ontology.Instance; |
|
26 |
| import org.omwg.ontology.Relation; |
|
27 |
| import org.omwg.ontology.RelationInstance; |
|
28 |
| import org.wsmo.common.exception.InvalidModelException; |
|
29 |
| import org.wsmo.common.exception.SynchronisationException; |
|
30 |
| import org.wsmo.factory.LogicalExpressionFactory; |
|
31 |
| import org.wsmo.validator.ValidationError; |
|
32 |
| import org.wsmo.validator.ValidationWarning; |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| public class WsmlRuleValidator |
|
49 |
| extends WsmlFullValidator { |
|
50 |
| |
|
51 |
0
| public WsmlRuleValidator(LogicalExpressionFactory leFactory) {
|
|
52 |
0
| super(leFactory);
|
|
53 |
| } |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
0
| protected void visitAxiom(Axiom axiom) {
|
|
61 |
0
| WsmlRuleExpressionValidator ruleExprVal = new WsmlRuleExpressionValidator(axiom, errors, this);
|
|
62 |
0
| WsmlFullExpressionValidator fullExprVal = new WsmlFullExpressionValidator(axiom, errors);
|
|
63 |
0
| Iterator axioms = axiom.listDefinitions().iterator();
|
|
64 |
0
| while (axioms.hasNext()) {
|
|
65 |
0
| LogicalExpression le = (LogicalExpression) axioms.next();
|
|
66 |
0
| le.accept(fullExprVal);
|
|
67 |
0
| ruleExprVal.setup();
|
|
68 |
0
| le.accept(ruleExprVal);
|
|
69 |
| } |
|
70 |
| } |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
0
| protected void visitConcept(Concept concept) {
|
|
78 |
0
| super.visitConcept(concept);
|
|
79 |
| } |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
0
| protected void visitInstance(Instance instance) {
|
|
87 |
0
| super.visitInstance(instance);
|
|
88 |
| } |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
0
| protected void visitRelation(Relation relation) {
|
|
96 |
0
| super.visitRelation(relation);
|
|
97 |
| } |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
0
| protected void visitRelationInstance(RelationInstance relationInstance)
|
|
107 |
| throws SynchronisationException, InvalidModelException { |
|
108 |
0
| super.visitRelationInstance(relationInstance);
|
|
109 |
| } |
|
110 |
| |
|
111 |
0
| public boolean isValid(LogicalExpression logExpr, List <ValidationError> errorMessages, List <ValidationWarning> warningMessages) {
|
|
112 |
0
| super.isValid(logExpr, errorMessages, warningMessages);
|
|
113 |
0
| errors = errorMessages;
|
|
114 |
0
| warnings = warningMessages;
|
|
115 |
0
| WsmlRuleExpressionValidator ruleExprVal = new WsmlRuleExpressionValidator(null, errors, this);
|
|
116 |
0
| WsmlFullExpressionValidator fullExprVal = new WsmlFullExpressionValidator(null, errors);
|
|
117 |
0
| logExpr.accept(fullExprVal);
|
|
118 |
0
| ruleExprVal.setup();
|
|
119 |
0
| logExpr.accept(ruleExprVal);
|
|
120 |
0
| return (errors.isEmpty());
|
|
121 |
| } |
|
122 |
| |
|
123 |
| } |