Skip to content

Package: Rdf4jLists

Rdf4jLists

nameinstructionbranchcomplexitylinemethod
Rdf4jLists(Rdf4jAdapter, Procedure, Procedure)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
loadReferencedList(ReferencedListDescriptor)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
loadSimpleList(SimpleListDescriptor)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
persistReferencedList(ReferencedListValueDescriptor)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
persistSimpleList(SimpleListValueDescriptor)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
updateReferencedList(ReferencedListValueDescriptor)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
updateSimpleList(SimpleListValueDescriptor)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
verifyArgs(ListDescriptor)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.ontodriver.rdf4j;
14:
15: import cz.cvut.kbss.ontodriver.Lists;
16: import cz.cvut.kbss.ontodriver.descriptor.*;
17: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
18: import cz.cvut.kbss.ontodriver.model.Axiom;
19: import cz.cvut.kbss.ontodriver.model.NamedResource;
20: import cz.cvut.kbss.ontodriver.rdf4j.exception.Rdf4jDriverException;
21:
22: import java.util.List;
23: import java.util.Objects;
24:
25: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.getNPXMessageSupplier;
26:
27: class Rdf4jLists implements Lists {
28:
29: private final Rdf4jAdapter adapter;
30:
31: private final Procedure beforeCallback;
32: private final Procedure afterChangeCallback;
33:
34: Rdf4jLists(Rdf4jAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
35: this.adapter = adapter;
36: this.beforeCallback = beforeCallback;
37: this.afterChangeCallback = afterChangeCallback;
38: }
39:
40: @Override
41: public List<Axiom<NamedResource>> loadSimpleList(SimpleListDescriptor descriptor)
42: throws OntoDriverException {
43: verifyArgs(descriptor);
44: return adapter.getSimpleListHandler().loadList(descriptor);
45: }
46:
47: private void verifyArgs(ListDescriptor descriptor) throws Rdf4jDriverException {
48: beforeCallback.execute();
49: Objects.requireNonNull(descriptor, getNPXMessageSupplier("descriptor"));
50: }
51:
52: @Override
53: public void persistSimpleList(SimpleListValueDescriptor descriptor) throws OntoDriverException {
54: verifyArgs(descriptor);
55: adapter.getSimpleListHandler().persistList(descriptor);
56: afterChangeCallback.execute();
57: }
58:
59: @Override
60: public void updateSimpleList(SimpleListValueDescriptor descriptor) throws OntoDriverException {
61: verifyArgs(descriptor);
62: adapter.getSimpleListHandler().updateList(descriptor);
63: afterChangeCallback.execute();
64: }
65:
66: @Override
67: public List<Axiom<NamedResource>> loadReferencedList(ReferencedListDescriptor descriptor)
68: throws OntoDriverException {
69: verifyArgs(descriptor);
70: return adapter.getReferencedListHandler().loadList(descriptor);
71: }
72:
73: @Override
74: public void persistReferencedList(ReferencedListValueDescriptor descriptor)
75: throws OntoDriverException {
76: verifyArgs(descriptor);
77: adapter.getReferencedListHandler().persistList(descriptor);
78: afterChangeCallback.execute();
79: }
80:
81: @Override
82: public void updateReferencedList(ReferencedListValueDescriptor descriptor)
83: throws OntoDriverException {
84: verifyArgs(descriptor);
85: adapter.getReferencedListHandler().updateList(descriptor);
86: afterChangeCallback.execute();
87: }
88: }