-
Notifications
You must be signed in to change notification settings - Fork 14
/
StorageConnector.java
129 lines (113 loc) · 4.19 KB
/
StorageConnector.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package cz.cvut.kbss.ontodriver.jena.connector;
import cz.cvut.kbss.ontodriver.Closeable;
import cz.cvut.kbss.ontodriver.Wrapper;
import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
import cz.cvut.kbss.ontodriver.jena.exception.JenaDriverException;
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.Collection;
import java.util.List;
public interface StorageConnector extends Closeable, Wrapper {
/**
* Begins a transaction.
*/
void begin();
/**
* Commits the current transaction.
*/
void commit() throws JenaDriverException;
/**
* Rolls back the current transaction.
*/
void rollback();
/**
* Retrieves statements corresponding to the specified criteria.
* <p>
* All the parameters are optional, their absence signifies that any value in that position is acceptable.
*
* @param subject Statement subject, optional
* @param property Property, optional
* @param value Value, optional
* @return Collection of matching statements
*/
Collection<Statement> find(Resource subject, Property property, RDFNode value);
/**
* Retrieves statements corresponding to the specified criteria from the specified named graph.
* <p>
* The first three parameters are optional, their absence signifies that any value in that position is acceptable.
*
* @param subject Statement subject, optional
* @param property Property, optional
* @param value Value, optional
* @param context Named graph URI
* @return Collection of matching statements
*/
Collection<Statement> find(Resource subject, Property property, RDFNode value, String context);
/**
* Checks whether the storage contains any statements matching the specified criteria.
* <p>
* All the parameters are optional, their absence signifies that any value in that position is acceptable.
*
* @param subject Subject, optional
* @param property Property, optional
* @param value Value, optional
* @return {@code true} if at least one statement matches the criteria, {@code false} otherwise
*/
boolean contains(Resource subject, Property property, RDFNode value);
/**
* Checks whether the specified context (named graph) contains any statements matching the specified criteria.
* <p>
* The first three parameters are optional, their absence signifies that any value in that position is acceptable.
*
* @param subject Subject, optional
* @param property Property, optional
* @param value Value, optional
* @param context Named graph URI
* @return {@code true} if at least one statement matches the criteria, {@code false} otherwise
*/
boolean contains(Resource subject, Property property, RDFNode value, String context);
/**
* Lists all contexts (named graph) in the repository (including the transactional ones).
*
* @return List of named graph URIs
*/
List<String> getContexts();
/**
* Adds the specified statements to the storage.
* <p>
* Requires an active transaction.
*
* @param statements Statements to add
*/
void add(List<Statement> statements);
/**
* Adds the specified statements to the specified context in the storage.
* <p>
* Requires an active transaction.
*
* @param statements Statements to add
* @param context Target context
*/
void add(List<Statement> statements, String context);
/**
* Removes the specified statements from the storage.
* <p>
* Requires an active transaction.
*
* @param statements Statements to remove
*/
void remove(List<Statement> statements);
/**
* Removes the specified statements from the specified context in the storage.
* <p>
* Requires an active transaction.
*
* @param statements Statements to remove
* @param context Target context
*/
void remove(List<Statement> statements, String context);
@Override
void close() throws JenaDriverException;
}