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