Skip to content

Package: OwlapiTypes

OwlapiTypes

nameinstructionbranchcomplexitylinemethod
OwlapiTypes(OwlapiConnection, OwlapiAdapter)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
addTypes(NamedResource, URI, Set)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
ensureValidity(NamedResource, Set)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getTypes(NamedResource, URI, boolean)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
removeTypes(NamedResource, URI, Set)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 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.ontodriver.owlapi;
16:
17: import cz.cvut.kbss.ontodriver.Types;
18: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
19: import cz.cvut.kbss.ontodriver.model.Axiom;
20: import cz.cvut.kbss.ontodriver.model.NamedResource;
21:
22: import java.net.URI;
23: import java.util.Objects;
24: import java.util.Set;
25:
26: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.npxMessage;
27:
28: public class OwlapiTypes implements Types {
29:
30: private final OwlapiConnection connection;
31:
32: private final OwlapiAdapter adapter;
33:
34: public OwlapiTypes(OwlapiConnection connection, OwlapiAdapter adapter) {
35: this.connection = connection;
36: this.adapter = adapter;
37: }
38:
39: @Override
40: public Set<Axiom<URI>> getTypes(NamedResource individual, URI context, boolean includeInferred)
41: throws OntoDriverException {
42: Objects.requireNonNull(individual, npxMessage("individual"));
43: connection.ensureOpen();
44: return adapter.getTypesHandler().getTypes(individual, context, includeInferred);
45: }
46:
47: @Override
48: public void addTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
49: ensureValidity(individual, types);
50:• if (!types.isEmpty()) {
51: adapter.getTypesHandler().addTypes(individual, context, types);
52: }
53: connection.commitIfAuto();
54: }
55:
56: private void ensureValidity(NamedResource individual, Set<URI> types) {
57: Objects.requireNonNull(individual, npxMessage("individual"));
58: Objects.requireNonNull(types, npxMessage("types"));
59: connection.ensureOpen();
60: }
61:
62: @Override
63: public void removeTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
64: ensureValidity(individual, types);
65:• if (!types.isEmpty()) {
66: adapter.getTypesHandler().removeTypes(individual, context, types);
67: }
68: connection.commitIfAuto();
69: }
70: }