-
Notifications
You must be signed in to change notification settings - Fork 14
/
SnapshotStorageConnectorWithInference.java
86 lines (70 loc) · 3.1 KB
/
SnapshotStorageConnectorWithInference.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package cz.cvut.kbss.ontodriver.jena.connector;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import java.util.List;
class SnapshotStorageConnectorWithInference extends SnapshotStorageConnector implements InferredStorageConnector {
private SnapshotStorageWithInference storage;
SnapshotStorageConnectorWithInference(AbstractStorageConnector centralConnector) {
super(centralConnector);
}
@Override
void snapshotCentralDataset() {
final SnapshotStorageWithInference s = new SnapshotStorageWithInference(configuration);
s.initialize();
s.addCentralData(centralConnector.getStorage().getDataset());
this.storage = s;
super.storage = s; // So that we don't have to override the inherited modification methods
}
@Override
public List<Statement> find(Resource subject, Property property, RDFNode value) {
ensureTransactionalState();
return storage.getRawDefaultGraph().listStatements(subject, property, value).toList();
}
@Override
public List<Statement> find(Resource subject, Property property, RDFNode value, String context) {
ensureTransactionalState();
return storage.getRawNamedGraph(context).listStatements(subject, property, value).toList();
}
@Override
public boolean contains(Resource subject, Property property, RDFNode value) {
ensureTransactionalState();
return storage.getRawDefaultGraph().contains(subject, property, value);
}
@Override
public boolean contains(Resource subject, Property property, RDFNode value, String context) {
ensureTransactionalState();
return storage.getRawNamedGraph(context).contains(subject, property, value);
}
@Override
public List<Statement> findWithInference(Resource subject, Property property, RDFNode value) {
ensureTransactionalState();
return storage.getDefaultGraph().listStatements(subject, property, value).toList();
}
@Override
public List<Statement> findWithInference(Resource subject, Property property, RDFNode value, String context) {
ensureTransactionalState();
return storage.getNamedGraph(context).listStatements(subject, property, value).toList();
}
@Override
public boolean containsWithInference(Resource subject, Property property, RDFNode value) {
ensureTransactionalState();
return storage.getDefaultGraph().contains(subject, property, value);
}
@Override
public boolean containsWithInference(Resource subject, Property property, RDFNode value, String context) {
ensureTransactionalState();
return storage.getNamedGraph(context).contains(subject, property, value);
}
@Override
public boolean isConsistent() {
ensureTransactionalState();
return storage.checkConsistency().isValid();
}
@Override
public boolean isConsistent(String context) {
ensureTransactionalState();
return storage.checkConsistency(context).isValid();
}
}