Skip to content

Package: OwlapiProperties

OwlapiProperties

nameinstructionbranchcomplexitylinemethod
OwlapiProperties(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%
addProperties(NamedResource, URI, Map)
M: 0 C: 17
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
ensureValidity(NamedResource, Map)
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%
getProperties(NamedResource, URI, boolean)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
removeProperties(NamedResource, URI, Map)
M: 0 C: 17
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.Properties;
18: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
19: import cz.cvut.kbss.ontodriver.model.Assertion;
20: import cz.cvut.kbss.ontodriver.model.Axiom;
21: import cz.cvut.kbss.ontodriver.model.NamedResource;
22: import cz.cvut.kbss.ontodriver.model.Value;
23:
24: import java.net.URI;
25: import java.util.Collection;
26: import java.util.Map;
27: import java.util.Objects;
28: import java.util.Set;
29:
30: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.npxMessage;
31:
32: public class OwlapiProperties implements Properties {
33:
34: private final OwlapiConnection connection;
35:
36: private final OwlapiAdapter adapter;
37:
38: public OwlapiProperties(OwlapiConnection connection, OwlapiAdapter adapter) {
39: this.connection = connection;
40: this.adapter = adapter;
41: }
42:
43: @Override
44: public Collection<Axiom<?>> getProperties(NamedResource individual, URI context, boolean includeInferred)
45: throws OntoDriverException {
46: Objects.requireNonNull(individual, npxMessage("individual"));
47: connection.ensureOpen();
48: return adapter.getPropertiesHandler().getProperties(individual, includeInferred);
49: }
50:
51: @Override
52: public void addProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties)
53: throws OntoDriverException {
54: ensureValidity(individual, properties);
55:• if (!properties.isEmpty()) {
56: adapter.getPropertiesHandler().addProperties(individual, properties);
57: }
58: connection.commitIfAuto();
59: }
60:
61: private void ensureValidity(NamedResource individual, Map<Assertion, Set<Value<?>>> properties) {
62: Objects.requireNonNull(individual, npxMessage("individual"));
63: Objects.requireNonNull(properties, npxMessage("properties"));
64: connection.ensureOpen();
65: }
66:
67: @Override
68: public void removeProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties)
69: throws OntoDriverException {
70: ensureValidity(individual, properties);
71:• if (!properties.isEmpty()) {
72: adapter.getPropertiesHandler().removeProperties(individual, properties);
73: }
74: connection.commitIfAuto();
75: }
76: }