Skip to content

Package: ClassDataPropertyComputer

ClassDataPropertyComputer

nameinstructionbranchcomplexitylinemethod
ClassDataPropertyComputer(OWLClass, OWLDataProperty, IntegrityConstraintSet, OWLOntology)
M: 5 C: 66
93%
M: 3 C: 11
79%
M: 2 C: 6
75%
M: 0 C: 17
100%
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.DataParticipationConstraint;
18: import cz.cvut.kbss.jopa.ic.api.DataRangeConstraint;
19: import org.semanticweb.owlapi.apibinding.OWLManager;
20: import org.semanticweb.owlapi.model.OWLClass;
21: import org.semanticweb.owlapi.model.OWLDataProperty;
22: import org.semanticweb.owlapi.model.OWLDatatype;
23: import org.semanticweb.owlapi.model.OWLOntology;
24:
25: public class ClassDataPropertyComputer extends ClassPropertyComputer<DataParticipationConstraint, OWLDatatype> {
26:
27: public ClassDataPropertyComputer(
28: final OWLClass clazz,
29: final OWLDataProperty prop,
30: final IntegrityConstraintSet set,
31: final OWLOntology ontology
32: ) {
33: boolean hasFiller = true;
34: set.getClassDataIntegrityConstraints(clazz, prop).forEach(integrityConstraint -> {
35:• if (integrityConstraint instanceof DataParticipationConstraint) {
36: constraints.add((DataParticipationConstraint) integrityConstraint);
37:• } else if (integrityConstraint instanceof DataRangeConstraint) {
38: this.filler = ((DataRangeConstraint) integrityConstraint).getRange();
39: }
40: });
41:
42:• if (filler == null) {
43: hasFiller = false;
44: this.filler = ontology.getOWLOntologyManager().getOWLDataFactory().getRDFPlainLiteral();
45: }
46:
47:• if (constraints.isEmpty() && !hasFiller) {
48: this.card = Card.NO;
49: } else {
50: this.card = Card.MULTIPLE;
51:• for (final DataParticipationConstraint opc : constraints) {
52: final OWLDatatype dt2 = opc.getObject();
53:• if ((getFiller().equals(dt2) ||
54:• dt2.equals(OWLManager.getOWLDataFactory().getTopDatatype())) && opc.getMax() == 1) {
55: this.card = Card.ONE;
56: return;
57: }
58: }
59: }
60: }
61: }