Skip to content

Package: Rdf4jProperties

Rdf4jProperties

nameinstructionbranchcomplexitylinemethod
Rdf4jProperties(Rdf4jAdapter, Procedure, Procedure)
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
addProperties(NamedResource, URI, Map)
M: 0 C: 16
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: 15
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: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.ontodriver.rdf4j;
19:
20: import cz.cvut.kbss.ontodriver.Properties;
21: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
22: import cz.cvut.kbss.ontodriver.model.Assertion;
23: import cz.cvut.kbss.ontodriver.model.Axiom;
24: import cz.cvut.kbss.ontodriver.model.NamedResource;
25: import cz.cvut.kbss.ontodriver.model.Value;
26: import cz.cvut.kbss.ontodriver.rdf4j.config.RuntimeConfiguration;
27: import cz.cvut.kbss.ontodriver.rdf4j.connector.RepoConnection;
28: import cz.cvut.kbss.ontodriver.rdf4j.exception.Rdf4jDriverException;
29:
30: import java.net.URI;
31: import java.util.Collection;
32: import java.util.Map;
33: import java.util.Set;
34:
35: class Rdf4jProperties implements Properties {
36:
37: private final RepoConnection connector;
38: private final RuntimeConfiguration config;
39:
40: private final Procedure beforeCallback;
41: private final Procedure afterChangeCallback;
42:
43: public Rdf4jProperties(Rdf4jAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
44: this.connector = adapter.getConnector();
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 Rdf4jDriverException {
53: beforeCallback.execute();
54: return new AxiomLoader(connector, 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).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, connector.getValueFactory()).remove(individual, properties, context);
69: afterChangeCallback.execute();
70: }
71: }