Skip to content

Package: OwlapiLists

OwlapiLists

nameinstructionbranchcomplexitylinemethod
OwlapiLists(OwlapiAdapter, 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%
ensureStateAndArgumentValid(Object)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
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%

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.list;
16:
17: import cz.cvut.kbss.ontodriver.Lists;
18: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptor;
19: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListValueDescriptor;
20: import cz.cvut.kbss.ontodriver.descriptor.SimpleListDescriptor;
21: import cz.cvut.kbss.ontodriver.descriptor.SimpleListValueDescriptor;
22: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
23: import cz.cvut.kbss.ontodriver.model.Axiom;
24: import cz.cvut.kbss.ontodriver.model.NamedResource;
25: import cz.cvut.kbss.ontodriver.owlapi.OwlapiAdapter;
26: import cz.cvut.kbss.ontodriver.owlapi.exception.OwlapiDriverException;
27: import cz.cvut.kbss.ontodriver.owlapi.util.Procedure;
28:
29: import java.util.List;
30: import java.util.Objects;
31:
32: /**
33: * Public access point the simple and referenced list handling in the OWLAPI driver.
34: */
35: public class OwlapiLists implements Lists {
36:
37: private final OwlapiAdapter adapter;
38:
39: private final Procedure beforeCallback;
40: private final Procedure afterChangeCallback;
41:
42: public OwlapiLists(OwlapiAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
43: this.adapter = adapter;
44: this.beforeCallback = beforeCallback;
45: this.afterChangeCallback = afterChangeCallback;
46: }
47:
48: @Override
49: public List<Axiom<NamedResource>> loadSimpleList(SimpleListDescriptor descriptor) throws OntoDriverException {
50: ensureStateAndArgumentValid(descriptor);
51: return adapter.getSimpleListHandler().loadList(descriptor);
52: }
53:
54: private void ensureStateAndArgumentValid(Object argument) throws OwlapiDriverException {
55: beforeCallback.execute();
56: Objects.requireNonNull(argument);
57: }
58:
59: @Override
60: public void persistSimpleList(SimpleListValueDescriptor descriptor) throws OntoDriverException {
61: ensureStateAndArgumentValid(descriptor);
62: adapter.getSimpleListHandler().persistList(descriptor);
63: afterChangeCallback.execute();
64: }
65:
66: @Override
67: public void updateSimpleList(SimpleListValueDescriptor descriptor) throws OntoDriverException {
68: ensureStateAndArgumentValid(descriptor);
69: adapter.getSimpleListHandler().updateList(descriptor);
70: afterChangeCallback.execute();
71: }
72:
73: @Override
74: public List<Axiom<NamedResource>> loadReferencedList(ReferencedListDescriptor descriptor)
75: throws OntoDriverException {
76: ensureStateAndArgumentValid(descriptor);
77: return adapter.getReferencedListHandler().loadList(descriptor);
78: }
79:
80: @Override
81: public void persistReferencedList(ReferencedListValueDescriptor descriptor) throws OntoDriverException {
82: ensureStateAndArgumentValid(descriptor);
83: adapter.getReferencedListHandler().persistList(descriptor);
84: afterChangeCallback.execute();
85: }
86:
87: @Override
88: public void updateReferencedList(ReferencedListValueDescriptor descriptor) throws OntoDriverException {
89: ensureStateAndArgumentValid(descriptor);
90: adapter.getReferencedListHandler().updateList(descriptor);
91: afterChangeCallback.execute();
92: }
93: }