-
Notifications
You must be signed in to change notification settings - Fork 14
/
TransactionalRepositoryConnection.java
323 lines (266 loc) · 11 KB
/
TransactionalRepositoryConnection.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.ontodriver.sesame.connector;
import org.eclipse.rdf4j.IsolationLevel;
import org.eclipse.rdf4j.common.iteration.Iteration;
import org.eclipse.rdf4j.model.*;
import org.eclipse.rdf4j.query.*;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.repository.RepositoryResult;
import org.eclipse.rdf4j.rio.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
/**
* Wraps a standard Sesame {@link RepositoryConnection} and prevents its closing.
* <p>
* This is because the connector will handle closing when a transaction finishes or the connector is closed.
*
* @see PoolingStorageConnector
*/
class TransactionalRepositoryConnection implements RepositoryConnection {
private final RepositoryConnection wrappedConnection;
TransactionalRepositoryConnection(RepositoryConnection wrappedConnection) {
this.wrappedConnection = wrappedConnection;
}
@Override
public Repository getRepository() {
return wrappedConnection.getRepository();
}
@Override
public void setParserConfig(ParserConfig config) {
wrappedConnection.setParserConfig(config);
}
@Override
public ParserConfig getParserConfig() {
return wrappedConnection.getParserConfig();
}
@Override
public ValueFactory getValueFactory() {
return wrappedConnection.getValueFactory();
}
@Override
public boolean isOpen() throws RepositoryException {
return wrappedConnection.isOpen();
}
@Override
public void close() throws RepositoryException {
// Do nothing !!!
}
@Override
public Query prepareQuery(QueryLanguage ql, String query) throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareQuery(ql, query);
}
@Override
public Query prepareQuery(QueryLanguage ql, String query, String baseURI)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareQuery(ql, query, baseURI);
}
@Override
public TupleQuery prepareTupleQuery(QueryLanguage ql, String query)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareTupleQuery(ql, query);
}
@Override
public TupleQuery prepareTupleQuery(QueryLanguage ql, String query, String baseURI)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareTupleQuery(ql, query, baseURI);
}
@Override
public GraphQuery prepareGraphQuery(QueryLanguage ql, String query)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareGraphQuery(ql, query);
}
@Override
public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareGraphQuery(ql, query, baseURI);
}
@Override
public BooleanQuery prepareBooleanQuery(QueryLanguage ql, String query)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareBooleanQuery(ql, query);
}
@Override
public BooleanQuery prepareBooleanQuery(QueryLanguage ql, String query, String baseURI)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareBooleanQuery(ql, query, baseURI);
}
@Override
public Update prepareUpdate(QueryLanguage ql, String update) throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareUpdate(ql, update);
}
@Override
public Update prepareUpdate(QueryLanguage ql, String update, String baseURI)
throws RepositoryException, MalformedQueryException {
return wrappedConnection.prepareUpdate(ql, update, baseURI);
}
@Override
public RepositoryResult<Resource> getContextIDs() throws RepositoryException {
return wrappedConnection.getContextIDs();
}
@Override
public RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred,
Resource... contexts) throws RepositoryException {
return wrappedConnection.getStatements(subj, pred, obj, includeInferred, contexts);
}
@Override
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts)
throws RepositoryException {
return wrappedConnection.hasStatement(subj, pred, obj, includeInferred, contexts);
}
@Override
public boolean hasStatement(Statement st, boolean includeInferred, Resource... contexts)
throws RepositoryException {
return wrappedConnection.hasStatement(st, includeInferred, contexts);
}
@Override
public void exportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler,
Resource... contexts) throws RepositoryException, RDFHandlerException {
wrappedConnection.exportStatements(subj, pred, obj, includeInferred, handler, contexts);
}
@Override
public void export(RDFHandler handler, Resource... contexts) throws RepositoryException, RDFHandlerException {
wrappedConnection.export(handler, contexts);
}
@Override
public long size(Resource... contexts) throws RepositoryException {
return wrappedConnection.size(contexts);
}
@Override
public boolean isEmpty() throws RepositoryException {
return wrappedConnection.isEmpty();
}
@Deprecated
@Override
public void setAutoCommit(boolean autoCommit) throws RepositoryException {
wrappedConnection.setAutoCommit(autoCommit);
}
@Deprecated
@Override
public boolean isAutoCommit() throws RepositoryException {
return wrappedConnection.isAutoCommit();
}
@Override
public boolean isActive() throws RepositoryException {
return wrappedConnection.isActive();
}
@Override
public void setIsolationLevel(IsolationLevel level) throws IllegalStateException {
wrappedConnection.setIsolationLevel(level);
}
@Override
public IsolationLevel getIsolationLevel() {
return wrappedConnection.getIsolationLevel();
}
@Override
public void begin() throws RepositoryException {
wrappedConnection.begin();
}
@Override
public void begin(IsolationLevel level) throws RepositoryException {
wrappedConnection.begin(level);
}
@Override
public void commit() throws RepositoryException {
wrappedConnection.commit();
}
@Override
public void rollback() throws RepositoryException {
wrappedConnection.rollback();
}
@Override
public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts)
throws IOException, RDFParseException, RepositoryException {
wrappedConnection.add(in, baseURI, dataFormat, contexts);
}
@Override
public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts)
throws IOException, RDFParseException, RepositoryException {
wrappedConnection.add(reader, baseURI, dataFormat, contexts);
}
@Override
public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts)
throws IOException, RDFParseException, RepositoryException {
wrappedConnection.add(url, baseURI, dataFormat, contexts);
}
@Override
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts)
throws IOException, RDFParseException, RepositoryException {
wrappedConnection.add(file, baseURI, dataFormat, contexts);
}
@Override
public void add(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
wrappedConnection.add(subject, predicate, object, contexts);
}
@Override
public void add(Statement st, Resource... contexts) throws RepositoryException {
wrappedConnection.add(st, contexts);
}
@Override
public void add(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException {
wrappedConnection.add(statements, contexts);
}
@Override
public <E extends Exception> void add(Iteration<? extends Statement, E> statements, Resource... contexts)
throws RepositoryException, E {
wrappedConnection.add(statements, contexts);
}
@Override
public void remove(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
wrappedConnection.remove(subject, predicate, object, contexts);
}
@Override
public void remove(Statement st, Resource... contexts) throws RepositoryException {
wrappedConnection.remove(st, contexts);
}
@Override
public void remove(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException {
wrappedConnection.remove(statements, contexts);
}
@Override
public <E extends Exception> void remove(Iteration<? extends Statement, E> statements, Resource... contexts)
throws RepositoryException, E {
wrappedConnection.remove(statements, contexts);
}
@Override
public void clear(Resource... contexts) throws RepositoryException {
wrappedConnection.clear(contexts);
}
@Override
public RepositoryResult<Namespace> getNamespaces() throws RepositoryException {
return wrappedConnection.getNamespaces();
}
@Override
public String getNamespace(String prefix) throws RepositoryException {
return wrappedConnection.getNamespace(prefix);
}
@Override
public void setNamespace(String prefix, String name) throws RepositoryException {
wrappedConnection.setNamespace(prefix, name);
}
@Override
public void removeNamespace(String prefix) throws RepositoryException {
wrappedConnection.removeNamespace(prefix);
}
@Override
public void clearNamespaces() throws RepositoryException {
wrappedConnection.clearNamespaces();
}
}