Skip to content

Package: SesameLists

SesameLists

nameinstructionbranchcomplexitylinemethod
SesameLists(SesameAdapter, 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: 10
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: 10
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: 13
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: 13
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: 13
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: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
verifyArgs(ListDescriptor, String)
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) 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.sesame;
16:
17: import cz.cvut.kbss.ontodriver.Lists;
18: import cz.cvut.kbss.ontodriver.descriptor.*;
19: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
20: import cz.cvut.kbss.ontodriver.model.Axiom;
21: import cz.cvut.kbss.ontodriver.model.NamedResource;
22: import cz.cvut.kbss.ontodriver.sesame.exceptions.SesameDriverException;
23:
24: import java.util.List;
25: import java.util.Objects;
26:
27: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.npxMessage;
28:
29: class SesameLists implements Lists {
30:
31: private final SesameAdapter adapter;
32:
33: private final Procedure beforeCallback;
34: private final Procedure afterChangeCallback;
35:
36: SesameLists(SesameAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
37: this.adapter = adapter;
38: this.beforeCallback = beforeCallback;
39: this.afterChangeCallback = afterChangeCallback;
40: }
41:
42: @Override
43: public List<Axiom<NamedResource>> loadSimpleList(SimpleListDescriptor descriptor)
44: throws OntoDriverException {
45: verifyArgs(descriptor, "descriptor");
46: return adapter.getSimpleListHandler().loadList(descriptor);
47: }
48:
49: private void verifyArgs(ListDescriptor descriptor, String argName) throws SesameDriverException {
50: beforeCallback.execute();
51: Objects.requireNonNull(descriptor, npxMessage(argName));
52: }
53:
54: @Override
55: public void persistSimpleList(SimpleListValueDescriptor descriptor) throws OntoDriverException {
56: verifyArgs(descriptor, "descriptor");
57: adapter.getSimpleListHandler().persistList(descriptor);
58: afterChangeCallback.execute();
59: }
60:
61: @Override
62: public void updateSimpleList(SimpleListValueDescriptor descriptor) throws OntoDriverException {
63: verifyArgs(descriptor, "descriptor");
64: adapter.getSimpleListHandler().updateList(descriptor);
65: afterChangeCallback.execute();
66: }
67:
68: @Override
69: public List<Axiom<NamedResource>> loadReferencedList(ReferencedListDescriptor descriptor)
70: throws OntoDriverException {
71: verifyArgs(descriptor, "descriptor");
72: return adapter.getReferencedListHandler().loadList(descriptor);
73: }
74:
75: @Override
76: public void persistReferencedList(ReferencedListValueDescriptor descriptor)
77: throws OntoDriverException {
78: verifyArgs(descriptor, "descriptor");
79: adapter.getReferencedListHandler().persistList(descriptor);
80: afterChangeCallback.execute();
81: }
82:
83: @Override
84: public void updateReferencedList(ReferencedListValueDescriptor descriptor)
85: throws OntoDriverException {
86: verifyArgs(descriptor, "descriptor");
87: adapter.getReferencedListHandler().updateList(descriptor);
88: afterChangeCallback.execute();
89: }
90: }