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: * 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.ic.api.ObjectParticipationConstraint;
21: import cz.cvut.kbss.jopa.ic.api.ObjectRangeConstraint;
22: import cz.cvut.kbss.jopa.model.SequencesVocabulary;
23: import org.semanticweb.owlapi.apibinding.OWLManager;
24: import org.semanticweb.owlapi.model.*;
25: import org.semanticweb.owlapi.search.EntitySearcher;
26:
27: import java.util.Set;
28: import java.util.stream.Collectors;
29:
30: public class ClassObjectPropertyComputer extends ClassPropertyComputer<ObjectParticipationConstraint, OWLClass> {
31:
32: public ClassObjectPropertyComputer(final OWLClass clazz,
33: final OWLObjectProperty prop,
34: final IntegrityConstraintSet set,
35: final OWLOntology merged
36: ) {
37: boolean hasFiller = true;
38: set.getClassObjectIntegrityConstraints(clazz, prop).forEach(ic -> {
39:• if (ic instanceof ObjectParticipationConstraint) {
40: constraints.add((ObjectParticipationConstraint) ic);
41:• } else if (ic instanceof ObjectRangeConstraint) {
42: filler = ((ObjectRangeConstraint) ic).getRange();
43: }
44: });
45:
46:• if (filler == null) {
47: hasFiller = false;
48: filler = merged.getOWLOntologyManager().getOWLDataFactory().getOWLThing();
49: }
50:
51:• if (constraints.isEmpty() && !hasFiller) {
52: card = Card.NO;
53: } else {
54: final OWLDataFactory f = merged.getOWLOntologyManager().getOWLDataFactory();
55:
56: final OWLClass object = filler;
57: final Set<OWLClassExpression> superClasses = EntitySearcher.getSuperClasses(object, merged).collect(
58: Collectors.toSet());
59:
60:• if (superClasses.contains(f.getOWLClass(IRI.create(SequencesVocabulary.c_List)))) {
61: this.filler = new ClassObjectPropertyComputer(object,
62: f.getOWLObjectProperty(IRI.create(SequencesVocabulary.p_element)), set, merged).getFiller();
63: card = Card.LIST;
64:• } else if (superClasses.contains(f.getOWLClass(IRI.create(SequencesVocabulary.c_OWLSimpleList)))) {
65: this.filler = new ClassObjectPropertyComputer(object,
66: f.getOWLObjectProperty(IRI.create(SequencesVocabulary.p_hasNext)), set, merged).getFiller();
67: card = Card.SIMPLELIST; // TODO referenced
68: } else {
69: card = Card.MULTIPLE;
70:• for (ObjectParticipationConstraint opc : constraints) {
71: OWLClass dt2 = opc.getObject();
72:• if ((filler.equals(dt2) || dt2.equals(OWLManager.getOWLDataFactory().getOWLThing())) &&
73:• opc.getMax() == 1) {
74: card = Card.ONE;
75: break;
76: }
77: }
78: }
79: }
80: }
81: }