Skip to content

Package: SnapshotStorageConnectorWithInference

SnapshotStorageConnectorWithInference

nameinstructionbranchcomplexitylinemethod
SnapshotStorageConnectorWithInference(AbstractStorageConnector, Map)
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%
contains(Resource, Property, RDFNode, String)
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
containsWithInference(Resource, Property, RDFNode, String)
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
find(Resource, Property, RDFNode, String)
M: 0 C: 25
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
findWithInference(Resource, Property, RDFNode, String)
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
isConsistent(String)
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%
snapshotCentralDataset()
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
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.jena.connector;
16:
17: import org.apache.jena.rdf.model.Property;
18: import org.apache.jena.rdf.model.RDFNode;
19: import org.apache.jena.rdf.model.Resource;
20: import org.apache.jena.rdf.model.Statement;
21:
22: import java.util.List;
23: import java.util.Map;
24:
25: /**
26: * This connector implementation supports proper inference.
27: */
28: class SnapshotStorageConnectorWithInference extends SnapshotStorageConnector implements InferredStorageConnector {
29:
30: // private SnapshotStorageWithInference storage;
31: private final Map<String, String> reasonerConfig;
32:
33: SnapshotStorageConnectorWithInference(AbstractStorageConnector centralConnector,
34: Map<String, String> reasonerConfig) {
35: super(centralConnector);
36: this.reasonerConfig = reasonerConfig;
37: }
38:
39: @Override
40: void snapshotCentralDataset() {
41: final SnapshotStorageWithInference s = new SnapshotStorageWithInference(configuration, reasonerConfig);
42: s.initialize();
43: s.addCentralData(centralConnector.getStorage().getDataset());
44: this.storage = s;
45: }
46:
47: @Override
48: public List<Statement> find(Resource subject, Property property, RDFNode value, String context) {
49: ensureTransactionalState();
50:• if (context != null) {
51: return ((SnapshotStorageWithInference) storage).getRawNamedGraph(context)
52: .listStatements(subject, property, value).toList();
53: } else {
54: return ((SnapshotStorageWithInference) storage).getRawDefaultGraph()
55: .listStatements(subject, property, value).toList();
56: }
57: }
58:
59: @Override
60: public boolean contains(Resource subject, Property property, RDFNode value, String context) {
61: ensureTransactionalState();
62:• if (context != null) {
63: return ((SnapshotStorageWithInference) storage).getRawNamedGraph(context)
64: .contains(subject, property, value);
65: } else {
66: return ((SnapshotStorageWithInference) storage).getRawDefaultGraph().contains(subject, property, value);
67: }
68: }
69:
70: @Override
71: public List<Statement> findWithInference(Resource subject, Property property, RDFNode value, String context) {
72: ensureTransactionalState();
73:• if (context != null) {
74: return storage.getNamedGraph(context).listStatements(subject, property, value).toList();
75: } else {
76: return storage.getDefaultGraph().listStatements(subject, property, value).toList();
77: }
78: }
79:
80: @Override
81: public boolean containsWithInference(Resource subject, Property property, RDFNode value, String context) {
82: ensureTransactionalState();
83:• if (context != null) {
84: return storage.getNamedGraph(context).contains(subject, property, value);
85: } else {
86: return storage.getDefaultGraph().contains(subject, property, value);
87: }
88: }
89:
90: @Override
91: public boolean isConsistent(String context) {
92: ensureTransactionalState();
93: return ((SnapshotStorageWithInference) storage).checkConsistency(context).isValid();
94: }
95: }