Skip to content

Package: ClassObjectPropertyComputer

ClassObjectPropertyComputer

nameinstructionbranchcomplexitylinemethod
ClassObjectPropertyComputer(OWLClass, OWLObjectProperty, IntegrityConstraintSet, OWLOntology)
M: 34 C: 100
75%
M: 3 C: 15
83%
M: 3 C: 7
70%
M: 6 C: 23
79%
M: 0 C: 1
100%
lambda$new$0(IntegrityConstraint)
M: 0 C: 19
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.owl2java;
16:
17: import cz.cvut.kbss.jopa.ic.api.ObjectParticipationConstraint;
18: import cz.cvut.kbss.jopa.ic.api.ObjectRangeConstraint;
19: import cz.cvut.kbss.jopa.model.SequencesVocabulary;
20: import org.semanticweb.owlapi.apibinding.OWLManager;
21: import org.semanticweb.owlapi.model.*;
22: import org.semanticweb.owlapi.search.EntitySearcher;
23:
24: import java.util.Set;
25: import java.util.stream.Collectors;
26:
27: public class ClassObjectPropertyComputer extends ClassPropertyComputer<ObjectParticipationConstraint, OWLClass> {
28:
29: public ClassObjectPropertyComputer(final OWLClass clazz,
30: final OWLObjectProperty prop,
31: final IntegrityConstraintSet set,
32: final OWLOntology merged
33: ) {
34: boolean hasFiller = true;
35: set.getClassObjectIntegrityConstraints(clazz, prop).forEach(ic -> {
36:• if (ic instanceof ObjectParticipationConstraint) {
37: constraints.add((ObjectParticipationConstraint) ic);
38:• } else if (ic instanceof ObjectRangeConstraint) {
39: filler = ((ObjectRangeConstraint) ic).getRange();
40: }
41: });
42:
43:• if (filler == null) {
44: hasFiller = false;
45: filler = merged.getOWLOntologyManager().getOWLDataFactory().getOWLThing();
46: }
47:
48:• if (constraints.isEmpty() && !hasFiller) {
49: card = Card.NO;
50: } else {
51: final OWLDataFactory f = merged.getOWLOntologyManager().getOWLDataFactory();
52:
53: final OWLClass object = filler;
54: final Set<OWLClassExpression> superClasses = EntitySearcher.getSuperClasses(object, merged).collect(
55: Collectors.toSet());
56:
57:• if (superClasses.contains(f.getOWLClass(IRI.create(SequencesVocabulary.c_List)))) {
58: this.filler = new ClassObjectPropertyComputer(object,
59: f.getOWLObjectProperty(IRI.create(SequencesVocabulary.p_element)), set, merged).getFiller();
60: card = Card.LIST;
61:• } else if (superClasses.contains(f.getOWLClass(IRI.create(SequencesVocabulary.c_OWLSimpleList)))) {
62: this.filler = new ClassObjectPropertyComputer(object,
63: f.getOWLObjectProperty(IRI.create(SequencesVocabulary.p_hasNext)), set, merged).getFiller();
64: card = Card.SIMPLELIST; // TODO referenced
65: } else {
66: card = Card.MULTIPLE;
67:• for (ObjectParticipationConstraint opc : constraints) {
68: OWLClass dt2 = opc.getObject();
69:• if ((filler.equals(dt2) || dt2.equals(OWLManager.getOWLDataFactory().getOWLThing())) &&
70:• opc.getMax() == 1) {
71: card = Card.ONE;
72: break;
73: }
74: }
75: }
76: }
77: }
78: }