Package: OwlapiTypes
OwlapiTypes
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OwlapiTypes(OwlapiAdapter, Procedure, Procedure) |
|
|
|
|
|
||||||||||||||||||||
addTypes(NamedResource, URI, Set) |
|
|
|
|
|
||||||||||||||||||||
ensureValidity(NamedResource, Set) |
|
|
|
|
|
||||||||||||||||||||
getTypes(NamedResource, Collection, boolean) |
|
|
|
|
|
||||||||||||||||||||
removeTypes(NamedResource, URI, Set) |
|
|
|
|
|
Coverage
1: /**
2: * Copyright (C) 2022 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: import cz.cvut.kbss.ontodriver.owlapi.exception.OwlapiDriverException;
22: import cz.cvut.kbss.ontodriver.owlapi.util.Procedure;
23:
24: import java.net.URI;
25: import java.util.Collection;
26: import java.util.Objects;
27: import java.util.Set;
28:
29: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.getNPXMessageSupplier;
30:
31: public class OwlapiTypes implements Types {
32:
33: private final OwlapiAdapter adapter;
34:
35: private final Procedure beforeCallback;
36: private final Procedure afterChangeCallback;
37:
38: public OwlapiTypes(OwlapiAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
39: this.adapter = adapter;
40: this.beforeCallback = beforeCallback;
41: this.afterChangeCallback = afterChangeCallback;
42: }
43:
44: @Override
45: public Set<Axiom<URI>> getTypes(NamedResource individual, Collection<URI> contexts, boolean includeInferred)
46: throws OntoDriverException {
47: Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
48: beforeCallback.execute();
49: return adapter.getTypesHandler().getTypes(individual, contexts, includeInferred);
50: }
51:
52: @Override
53: public void addTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
54: ensureValidity(individual, types);
55:• if (!types.isEmpty()) {
56: adapter.getTypesHandler().addTypes(individual, context, types);
57: }
58: afterChangeCallback.execute();
59: }
60:
61: private void ensureValidity(NamedResource individual, Set<URI> types) throws OwlapiDriverException {
62: Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
63: Objects.requireNonNull(types, getNPXMessageSupplier("types"));
64: beforeCallback.execute();
65: }
66:
67: @Override
68: public void removeTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
69: ensureValidity(individual, types);
70:• if (!types.isEmpty()) {
71: adapter.getTypesHandler().removeTypes(individual, context, types);
72: }
73: afterChangeCallback.execute();
74: }
75: }