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.*; |
20 |
| |
21 |
| import org.omwg.logicalexpression.*; |
22 |
| import org.omwg.ontology.*; |
23 |
| import org.wsmo.common.*; |
24 |
| import org.wsmo.common.exception.*; |
25 |
| import org.wsmo.factory.LogicalExpressionFactory; |
26 |
| import org.wsmo.validator.ValidationError; |
27 |
| import org.wsmo.validator.ValidationWarning; |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| public class WsmlCoreValidator |
44 |
| extends WsmlDLValidator { |
45 |
| |
46 |
| private WsmlFlightValidator flightVal; |
47 |
| |
48 |
0
| public WsmlCoreValidator(LogicalExpressionFactory leFactory) {
|
49 |
0
| super(leFactory);
|
50 |
0
| flightVal = new WsmlFlightValidator(leFactory);
|
51 |
| } |
52 |
| |
53 |
0
| private void setup(){
|
54 |
0
| flightVal.setErrors(this.errors);
|
55 |
0
| flightVal.setWarnings(this.warnings);
|
56 |
| } |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
0
| protected void visitAxiom(Axiom axiom) {
|
64 |
0
| setup();
|
65 |
0
| WsmlCoreExpressionValidator coreExprVal = new WsmlCoreExpressionValidator(axiom, leFactory, errors, this);
|
66 |
0
| WsmlDLExpressionValidator dlExprVal = new WsmlDLExpressionValidator(axiom, leFactory, errors, this);
|
67 |
0
| WsmlFlightExpressionValidator flightExprVal = new WsmlFlightExpressionValidator(axiom, leFactory, errors, this);
|
68 |
0
| WsmlRuleExpressionValidator ruleExprVal = new WsmlRuleExpressionValidator(axiom, errors, this);
|
69 |
0
| WsmlFullExpressionValidator fullExprVal = new WsmlFullExpressionValidator(axiom, errors);
|
70 |
0
| FunctionSymbolHelper fsHelper = new FunctionSymbolHelper(axiom, errors, WSML.WSML_CORE, this);
|
71 |
0
| IDCollectHelper idHelper = new IDCollectHelper();
|
72 |
0
| Iterator axioms = axiom.listDefinitions().iterator();
|
73 |
0
| while (axioms.hasNext()){
|
74 |
0
| LogicalExpression le = (LogicalExpression) axioms.next();
|
75 |
| |
76 |
0
| le.accept(idHelper);
|
77 |
| |
78 |
0
| idConcepts.addAll(idHelper.getConceptIds());
|
79 |
0
| idInstances.addAll(idHelper.getInstanceIds());
|
80 |
0
| idRelations.addAll(idHelper.getRelationIds());
|
81 |
0
| idAbstractRelations.addAll(idHelper.getIdAbstractRelations());
|
82 |
0
| idConcreteRelations.addAll(idHelper.getIdConcreteRelations());
|
83 |
| |
84 |
0
| le.accept(fsHelper);
|
85 |
| |
86 |
0
| le.accept(fullExprVal);
|
87 |
0
| ruleExprVal.setup();
|
88 |
0
| le.accept(ruleExprVal);
|
89 |
0
| flightExprVal.setup();
|
90 |
0
| le.accept(flightExprVal);
|
91 |
0
| dlExprVal.setup();
|
92 |
0
| le.accept(dlExprVal);
|
93 |
0
| coreExprVal.setup();
|
94 |
0
| le.accept(coreExprVal);
|
95 |
| } |
96 |
| } |
97 |
| |
98 |
| |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
0
| protected void visitConcept(Concept concept) {
|
104 |
0
| super.visitConcept(concept);
|
105 |
| |
106 |
| |
107 |
| } |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
0
| protected void visitInstance(Instance instance) {
|
115 |
0
| super.visitInstance(instance);
|
116 |
| |
117 |
| |
118 |
| } |
119 |
| |
120 |
| |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
0
| protected void visitRelation(Relation relation) {
|
126 |
0
| super.visitRelation(relation);
|
127 |
| |
128 |
| |
129 |
| } |
130 |
| |
131 |
| |
132 |
| |
133 |
| |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
0
| protected void visitRelationInstance(RelationInstance relationInstance)
|
139 |
| throws SynchronisationException, InvalidModelException { |
140 |
0
| super.visitRelationInstance(relationInstance);
|
141 |
| |
142 |
| |
143 |
| } |
144 |
| |
145 |
0
| public boolean isValid(LogicalExpression logExpr, List <ValidationError> errorMessages, List <ValidationWarning> warningMessages) {
|
146 |
0
| super.isValid(logExpr, errorMessages, warningMessages);
|
147 |
0
| errors = errorMessages;
|
148 |
0
| warnings = warningMessages;
|
149 |
0
| setup();
|
150 |
0
| WsmlCoreExpressionValidator coreExprVal = new WsmlCoreExpressionValidator(null, leFactory, errors, this);
|
151 |
0
| WsmlDLExpressionValidator dlExprVal = new WsmlDLExpressionValidator(null, leFactory, errors, this);
|
152 |
0
| WsmlFlightExpressionValidator flightExprVal = new WsmlFlightExpressionValidator(null, leFactory, errors, this);
|
153 |
0
| WsmlRuleExpressionValidator ruleExprVal = new WsmlRuleExpressionValidator(null, errors, this);
|
154 |
0
| WsmlFullExpressionValidator fullExprVal = new WsmlFullExpressionValidator(null, errors);
|
155 |
0
| FunctionSymbolHelper fsHelper = new FunctionSymbolHelper(
|
156 |
| null, errors, WSML.WSML_CORE, this); |
157 |
0
| IDCollectHelper idHelper = new IDCollectHelper();
|
158 |
| |
159 |
0
| logExpr.accept(idHelper);
|
160 |
| |
161 |
0
| idConcepts.addAll(idHelper.getConceptIds());
|
162 |
0
| idInstances.addAll(idHelper.getInstanceIds());
|
163 |
0
| idRelations.addAll(idHelper.getRelationIds());
|
164 |
0
| idAbstractRelations.addAll(idHelper.getIdAbstractRelations());
|
165 |
0
| idConcreteRelations.addAll(idHelper.getIdConcreteRelations());
|
166 |
| |
167 |
0
| logExpr.accept(fsHelper);
|
168 |
| |
169 |
0
| logExpr.accept(fullExprVal);
|
170 |
0
| ruleExprVal.setup();
|
171 |
0
| logExpr.accept(ruleExprVal);
|
172 |
0
| flightExprVal.setup();
|
173 |
0
| logExpr.accept(flightExprVal);
|
174 |
0
| dlExprVal.setup();
|
175 |
0
| logExpr.accept(dlExprVal);
|
176 |
0
| coreExprVal.setup();
|
177 |
0
| logExpr.accept(coreExprVal);
|
178 |
| |
179 |
0
| return (errors.isEmpty());
|
180 |
| } |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
0
| protected void addError(Entity ent, String msg) {
|
186 |
0
| ValidationErrorImpl ve = new ValidationErrorImpl(ent, msg, WSML.WSML_CORE);
|
187 |
0
| if (!errors.contains(ve)) {
|
188 |
0
| errors.add(ve);
|
189 |
| } |
190 |
| } |
191 |
| } |