Skip to content

Package: SesameProperties

SesameProperties

nameinstructionbranchcomplexitylinemethod
SesameProperties(SesameAdapter, Procedure, Procedure)
M: 0 C: 21
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
addProperties(NamedResource, URI, Map)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getProperties(NamedResource, URI, boolean)
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
removeProperties(NamedResource, URI, Map)
M: 0 C: 15
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) 2020 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.Properties;
18: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
19: import cz.cvut.kbss.ontodriver.model.Assertion;
20: import cz.cvut.kbss.ontodriver.model.Axiom;
21: import cz.cvut.kbss.ontodriver.model.NamedResource;
22: import cz.cvut.kbss.ontodriver.model.Value;
23: import cz.cvut.kbss.ontodriver.sesame.config.RuntimeConfiguration;
24: import cz.cvut.kbss.ontodriver.sesame.connector.Connector;
25: import cz.cvut.kbss.ontodriver.sesame.exceptions.SesameDriverException;
26: import org.eclipse.rdf4j.model.ValueFactory;
27:
28: import java.net.URI;
29: import java.util.Collection;
30: import java.util.Map;
31: import java.util.Set;
32:
33: class SesameProperties implements Properties {
34:
35: private final Connector connector;
36: private final ValueFactory valueFactory;
37: private final RuntimeConfiguration config;
38:
39: private final Procedure beforeCallback;
40: private final Procedure afterChangeCallback;
41:
42: public SesameProperties(SesameAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
43: this.connector = adapter.getConnector();
44: this.valueFactory = adapter.getValueFactory();
45: this.config = adapter.getConfig();
46: this.beforeCallback = beforeCallback;
47: this.afterChangeCallback = afterChangeCallback;
48: }
49:
50: @Override
51: public Collection<Axiom<?>> getProperties(NamedResource individual, URI context, boolean includeInferred)
52: throws SesameDriverException {
53: beforeCallback.execute();
54: return new AxiomLoader(connector, valueFactory, config).loadAxioms(individual, includeInferred, context);
55: }
56:
57: @Override
58: public void addProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties)
59: throws OntoDriverException {
60: beforeCallback.execute();
61: new AxiomSaver(connector, valueFactory).persistAxioms(individual, properties, context);
62: afterChangeCallback.execute();
63: }
64:
65: @Override
66: public void removeProperties(NamedResource individual, URI context, Map<Assertion, Set<Value<?>>> properties)
67: throws OntoDriverException {
68: new EpistemicAxiomRemover(connector, valueFactory).remove(individual, properties, context);
69: afterChangeCallback.execute();
70: }
71: }