Skip to content

Package: IntegrityConstraintParser

IntegrityConstraintParser

nameinstructionbranchcomplexitylinemethod
IntegrityConstraintParser()
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getClassIntegrityConstraintSet()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$processSubClassConstraintCandidate$0(OWLObjectProperty, OWLEntity)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$processSubClassConstraintCandidate$1(OWLDataProperty, OWLEntity)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
notSupported(OWLObject)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
processSubClassConstraintCandidate(OWLClass, OWLClassExpression)
M: 8 C: 72
90%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 1 C: 13
93%
M: 0 C: 1
100%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
visit(OWLAnnotationAssertionAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLAnnotationPropertyDomainAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLAnnotationPropertyRangeAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLAsymmetricObjectPropertyAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLClassAssertionAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLDataPropertyAssertionAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLDataPropertyDomainAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLDataPropertyRangeAxiom)
M: 0 C: 21
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
visit(OWLDatatypeDefinitionAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLDeclarationAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLDifferentIndividualsAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLDisjointClassesAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLDisjointDataPropertiesAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLDisjointObjectPropertiesAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLDisjointUnionAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLEquivalentClassesAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLEquivalentDataPropertiesAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLEquivalentObjectPropertiesAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLFunctionalDataPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLFunctionalObjectPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLHasKeyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLInverseFunctionalObjectPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLInverseObjectPropertiesAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLIrreflexiveObjectPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLNegativeDataPropertyAssertionAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLNegativeObjectPropertyAssertionAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLObjectPropertyAssertionAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLObjectPropertyDomainAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLObjectPropertyRangeAxiom)
M: 3 C: 18
86%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 5
71%
M: 0 C: 1
100%
visit(OWLReflexiveObjectPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLSameIndividualAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLSubAnnotationPropertyOfAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLSubClassOfAxiom)
M: 3 C: 16
84%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 2 C: 5
71%
M: 0 C: 1
100%
visit(OWLSubDataPropertyOfAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLSubObjectPropertyOfAxiom)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
visit(OWLSubPropertyChainOfAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLSymmetricObjectPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(OWLTransitiveObjectPropertyAxiom)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
visit(SWRLRule)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.owl2java;
19:
20: import cz.cvut.kbss.jopa.owl2java.exception.UnsupportedICException;
21: import org.semanticweb.owlapi.apibinding.OWLManager;
22: import org.semanticweb.owlapi.model.*;
23: import org.slf4j.Logger;
24: import org.slf4j.LoggerFactory;
25:
26: import java.util.HashMap;
27: import java.util.Map;
28:
29: public class IntegrityConstraintParser implements OWLAxiomVisitor {
30:
31: private static final Logger LOG = LoggerFactory.getLogger(OWL2JavaTransformer.class);
32:
33: private final IntegrityConstraintSet integrityConstraintSet = new IntegrityConstraintSet();
34:
35: private final Map<OWLObjectProperty, OWLClass> opRanges = new HashMap<>();
36: private final Map<OWLDataProperty, OWLDatatype> dpRanges = new HashMap<>();
37:
38: @Override
39: public void visit(OWLAnnotationPropertyRangeAxiom axiom) {
40: notSupported(axiom);
41: }
42:
43: @Override
44: public void visit(OWLAnnotationPropertyDomainAxiom axiom) {
45: notSupported(axiom);
46: }
47:
48: @Override
49: public void visit(OWLSubAnnotationPropertyOfAxiom axiom) {
50: notSupported(axiom);
51: }
52:
53: @Override
54: public void visit(OWLAnnotationAssertionAxiom axiom) {
55: notSupported(axiom);
56: }
57:
58: @Override
59: public void visit(SWRLRule axiom) {
60: notSupported(axiom);
61: }
62:
63: @Override
64: public void visit(OWLDatatypeDefinitionAxiom axiom) {
65: notSupported(axiom);
66: }
67:
68: @Override
69: public void visit(OWLHasKeyAxiom axiom) {
70: notSupported(axiom);
71: }
72:
73: @Override
74: public void visit(OWLInverseObjectPropertiesAxiom axiom) {
75: notSupported(axiom);
76: }
77:
78: @Override
79: public void visit(OWLSubPropertyChainOfAxiom axiom) {
80: notSupported(axiom);
81: }
82:
83: @Override
84: public void visit(OWLSameIndividualAxiom axiom) {
85: notSupported(axiom);
86: }
87:
88: @Override
89: public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) {
90: notSupported(axiom);
91: }
92:
93: @Override
94: public void visit(OWLSubDataPropertyOfAxiom axiom) {
95: notSupported(axiom);
96: }
97:
98: @Override
99: public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) {
100: notSupported(axiom);
101: }
102:
103: @Override
104: public void visit(OWLTransitiveObjectPropertyAxiom axiom) {
105: notSupported(axiom);
106: }
107:
108: @Override
109: public void visit(OWLDataPropertyAssertionAxiom axiom) {
110: notSupported(axiom);
111: }
112:
113: @Override
114: public void visit(OWLEquivalentClassesAxiom axiom) {
115: notSupported(axiom);
116: }
117:
118: @Override
119: public void visit(OWLClassAssertionAxiom axiom) {
120: notSupported(axiom);
121: }
122:
123: @Override
124: public void visit(OWLEquivalentDataPropertiesAxiom axiom) {
125: notSupported(axiom);
126: }
127:
128: @Override
129: public void visit(OWLFunctionalDataPropertyAxiom axiom) {
130: // ic.addAll(processParticipationConstraint(f.getOWLThing(), f
131: // .getOWLDataMaxCardinality(1, axiom.getProperty())));
132:
133: // processParticipationConstraint(f.getOWLThing(), f
134: // .getOWLDataMaxCardinality(1, axiom.getProperty()));
135: notSupported(axiom);
136: }
137:
138: @Override
139: public void visit(OWLDataPropertyRangeAxiom axiom) {
140: try {
141: OWLDataProperty op = Utils.ensureDataProperty(axiom.getProperty());
142: OWLDatatype clz = Utils.ensureDatatype(axiom.getRange());
143:
144: dpRanges.put(op, clz);
145: } catch (UnsupportedICException e) {
146: notSupported(axiom);
147: }
148: }
149:
150: @Override
151: public void visit(OWLSymmetricObjectPropertyAxiom axiom) {
152: notSupported(axiom);
153: }
154:
155: @Override
156: public void visit(OWLDisjointUnionAxiom axiom) {
157: notSupported(axiom);
158: }
159:
160: @Override
161: public void visit(OWLSubObjectPropertyOfAxiom axiom) {
162: notSupported(axiom);
163: }
164:
165: @Override
166: public void visit(OWLFunctionalObjectPropertyAxiom axiom) {
167: // ic.addAll(processParticipationConstraint(f.getOWLThing(), f
168: // .getOWLObjectMaxCardinality(1, axiom.getProperty())));
169:
170: // processParticipationConstraint(f.getOWLThing(), f
171: // .getOWLObjectMaxCardinality(1, axiom.getProperty()));
172: notSupported(axiom);
173: }
174:
175: @Override
176: public void visit(OWLObjectPropertyAssertionAxiom axiom) {
177: notSupported(axiom);
178: }
179:
180: @Override
181: public void visit(OWLObjectPropertyRangeAxiom axiom) {
182: try {
183: OWLObjectProperty op = Utils.ensureObjectProperty(axiom.getProperty());
184: OWLClass clz = Utils.ensureClass(axiom.getRange());
185:
186: opRanges.put(op, clz);
187: // processSubClassConstraintCandidate(f.getOWLThing(),
188: // OWLManager.getOWLDataFactory().getOWLObjectAllValuesFrom(op, clz));
189: } catch (UnsupportedICException e) {
190: notSupported(axiom);
191: }
192: }
193:
194: @Override
195: public void visit(OWLDisjointObjectPropertiesAxiom axiom) {
196: notSupported(axiom);
197: }
198:
199: @Override
200: public void visit(OWLDisjointDataPropertiesAxiom axiom) {
201: notSupported(axiom);
202: }
203:
204: @Override
205: public void visit(OWLDifferentIndividualsAxiom axiom) {
206: notSupported(axiom);
207: }
208:
209: @Override
210: public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) {
211: notSupported(axiom);
212: }
213:
214: @Override
215: public void visit(OWLEquivalentObjectPropertiesAxiom axiom) {
216: notSupported(axiom);
217: }
218:
219: @Override
220: public void visit(OWLObjectPropertyDomainAxiom axiom) {
221: // OWLObjectProperty op = ensureObjectProperty(axiom.getProperty());
222: // OWLClass clz = ensureClass(axiom.getDomain());
223: // Set<ObjectDomainConstraint> c = odConstraints.get(op);
224: // if (c == null) {
225: // c = new HashSet<ObjectDomainConstraint>();
226: // odConstraints.put(op, c);
227: // }
228: //
229: // c.add(IntegrityConstraintFactoryImpl
230: // .ObjectPropertyDomainConstraint(op, clz));
231: notSupported(axiom);
232: }
233:
234: @Override
235: public void visit(OWLDataPropertyDomainAxiom axiom) {
236: // OWLDataProperty op = ensureDataProperty(axiom.getProperty());
237: // OWLClass clz = ensureClass(axiom.getDomain());
238: // Set<DataDomainConstraint> c = ddConstraints.get(op);
239: // if (c == null) {
240: // c = new HashSet<DataDomainConstraint>();
241: // ddConstraints.put(op, c);
242: // }
243: //
244: // c.add(IntegrityConstraintFactoryImpl.DataPropertyDomainConstraint(op,
245: // clz));
246: notSupported(axiom);
247: }
248:
249: @Override
250: public void visit(OWLDisjointClassesAxiom axiom) {
251: notSupported(axiom);
252: }
253:
254: @Override
255: public void visit(OWLReflexiveObjectPropertyAxiom axiom) {
256: notSupported(axiom);
257: }
258:
259: @Override
260: public void visit(OWLAsymmetricObjectPropertyAxiom axiom) {
261: notSupported(axiom);
262: }
263:
264: @Override
265: public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) {
266: notSupported(axiom);
267: }
268:
269: @Override
270: public void visit(OWLSubClassOfAxiom axiom) {
271: try {
272:• if (!axiom.getSubClass().isAnonymous()) {
273: processSubClassConstraintCandidate(axiom.getSubClass().asOWLClass(), axiom.getSuperClass());
274: } else {
275: notSupported(axiom);
276: }
277: } catch (UnsupportedICException e) {
278: notSupported(axiom);
279: }
280: }
281:
282: @Override
283: public void visit(final OWLDeclarationAxiom axiom) {
284: notSupported(axiom);
285: // axiom.getEntity().accept(new OWLEntityVisitor() {
286: //
287: // public void visit(OWLAnnotationProperty property) {
288: // ctx.annotationProperties.add(property);
289: // }
290: //
291: // public void visit(OWLDatatype datatype) {
292: // notSupported(axiom);
293: // }
294: //
295: // public void visit(OWLNamedIndividual individual) {
296: // notSupported(axiom);
297: // }
298: //
299: // public void visit(OWLDataProperty property) {
300: // ctx.dataProperties.add(property);
301: // }
302: //
303: // public void visit(OWLObjectProperty property) {
304: // ctx.objectProperties.add(property);
305: // }
306: //
307: // public void visit(OWLClass cls) {
308: // ctx.classes.add(cls);
309: // }
310: // });
311: }
312:
313: private static void notSupported(final OWLObject o) {
314: LOG.info("Ignoring Unsupported Axiom : {}", o);
315: }
316:
317: private void processSubClassConstraintCandidate(final OWLClass subjClass,
318: final OWLClassExpression superClass) {
319: final IntegrityConstraintClassParser icp = new IntegrityConstraintClassParser(subjClass);
320: superClass.accept(icp);
321:
322:• for (Map.Entry<OWLObjectProperty, OWLClass> entry : opRanges.entrySet()) {
323: final OWLObjectProperty property = entry.getKey();
324:• if (superClass.signature().anyMatch(e -> e.equals(property))) {
325: OWLManager.getOWLDataFactory().getOWLObjectAllValuesFrom(property, entry.getValue()).accept(icp);
326: }
327: }
328:• for (Map.Entry<OWLDataProperty, OWLDatatype> entry : dpRanges.entrySet()) {
329: final OWLDataProperty property = entry.getKey();
330:• if (superClass.signature().anyMatch(e -> e.equals(property))) {
331: OWLManager.getOWLDataFactory().getOWLDataAllValuesFrom(property, entry.getValue()).accept(icp);
332: }
333: }
334: icp.getIntegrityConstraints().forEach(integrityConstraintSet::addIntegrityConstraint);
335: }
336:
337: public IntegrityConstraintSet getClassIntegrityConstraintSet() {
338: return integrityConstraintSet;
339: }
340: }