Package: OwlapiProperties
OwlapiProperties
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OwlapiProperties(OwlapiAdapter, Procedure, Procedure) |
|
|
|
|
|
||||||||||||||||||||
addProperties(NamedResource, URI, Map) |
|
|
|
|
|
||||||||||||||||||||
ensureValidity(NamedResource, Map) |
|
|
|
|
|
||||||||||||||||||||
getProperties(NamedResource, URI, boolean) |
|
|
|
|
|
||||||||||||||||||||
removeProperties(NamedResource, URI, Map) |
|
|
|
|
|
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: import cz.cvut.kbss.ontodriver.owlapi.exception.OwlapiDriverException;
24: import cz.cvut.kbss.ontodriver.owlapi.util.Procedure;
25:
26: import java.net.URI;
27: import java.util.Collection;
28: import java.util.Map;
29: import java.util.Objects;
30: import java.util.Set;
31:
32: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.getNPXMessageSupplier;
33:
34: public class OwlapiProperties implements Properties {
35:
36: private final OwlapiAdapter adapter;
37:
38: private final Procedure beforeCallback;
39: private final Procedure afterChangeCallback;
40:
41: public OwlapiProperties(OwlapiAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
42: this.afterChangeCallback = afterChangeCallback;
43: this.beforeCallback = beforeCallback;
44: this.adapter = adapter;
45: }
46:
47: @Override
48: public Collection<Axiom<?>> getProperties(NamedResource individual, URI context, boolean includeInferred)
49: throws OntoDriverException {
50: Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
51: beforeCallback.execute();
52: return adapter.getPropertiesHandler().getProperties(individual, includeInferred);
53: }
54:
55: @Override
56: public void addProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties)
57: throws OntoDriverException {
58: ensureValidity(individual, properties);
59:• if (!properties.isEmpty()) {
60: adapter.getPropertiesHandler().addProperties(individual, properties);
61: }
62: afterChangeCallback.execute();
63: }
64:
65: private void ensureValidity(NamedResource individual, Map<Assertion, Set<Value<?>>> properties)
66: throws OwlapiDriverException {
67: Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
68: Objects.requireNonNull(properties, getNPXMessageSupplier("properties"));
69: beforeCallback.execute();
70: }
71:
72: @Override
73: public void removeProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties)
74: throws OntoDriverException {
75: ensureValidity(individual, properties);
76:• if (!properties.isEmpty()) {
77: adapter.getPropertiesHandler().removeProperties(individual, properties);
78: }
79: afterChangeCallback.execute();
80: }
81: }