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