Skip to contentMethod: begin(IsolationLevel)
1: /*
2: * JOPA
3: * Copyright (C) 2023 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.connector;
19:
20:
21: import org.eclipse.rdf4j.common.iteration.Iteration;
22: import org.eclipse.rdf4j.common.transaction.IsolationLevel;
23: import org.eclipse.rdf4j.model.*;
24: import org.eclipse.rdf4j.query.*;
25: import org.eclipse.rdf4j.repository.Repository;
26: import org.eclipse.rdf4j.repository.RepositoryConnection;
27: import org.eclipse.rdf4j.repository.RepositoryResult;
28: import org.eclipse.rdf4j.rio.ParserConfig;
29: import org.eclipse.rdf4j.rio.RDFFormat;
30: import org.eclipse.rdf4j.rio.RDFHandler;
31:
32: import java.io.File;
33: import java.io.IOException;
34: import java.io.InputStream;
35: import java.io.Reader;
36: import java.net.URL;
37:
38: /**
39: * Wraps a standard RFD4J {@link RepositoryConnection} and prevents its closing.
40: * <p>
41: * This is because the connector will handle closing when a transaction finishes or the connector is closed.
42: *
43: * @see PoolingStorageConnector
44: */
45: class TransactionalRepositoryConnection implements RepositoryConnection {
46:
47: private final RepositoryConnection wrappedConnection;
48:
49: TransactionalRepositoryConnection(RepositoryConnection wrappedConnection) {
50: this.wrappedConnection = wrappedConnection;
51: }
52:
53: @Override
54: public Repository getRepository() {
55: return wrappedConnection.getRepository();
56: }
57:
58: @Override
59: public void setParserConfig(ParserConfig config) {
60: wrappedConnection.setParserConfig(config);
61: }
62:
63: @Override
64: public ParserConfig getParserConfig() {
65: return wrappedConnection.getParserConfig();
66: }
67:
68: @Override
69: public ValueFactory getValueFactory() {
70: return wrappedConnection.getValueFactory();
71: }
72:
73: @Override
74: public boolean isOpen() {
75: return wrappedConnection.isOpen();
76: }
77:
78: @Override
79: public void close() {
80: // Do nothing !!!
81: }
82:
83: @Override
84: public Query prepareQuery(QueryLanguage ql, String query) {
85: return wrappedConnection.prepareQuery(ql, query);
86: }
87:
88: @Override
89: public Query prepareQuery(QueryLanguage ql, String query, String baseURI) {
90: return wrappedConnection.prepareQuery(ql, query, baseURI);
91: }
92:
93: @Override
94: public TupleQuery prepareTupleQuery(QueryLanguage ql, String query) {
95: return wrappedConnection.prepareTupleQuery(ql, query);
96: }
97:
98: @Override
99: public TupleQuery prepareTupleQuery(QueryLanguage ql, String query, String baseURI) {
100: return wrappedConnection.prepareTupleQuery(ql, query, baseURI);
101: }
102:
103: @Override
104: public GraphQuery prepareGraphQuery(QueryLanguage ql, String query) {
105: return wrappedConnection.prepareGraphQuery(ql, query);
106: }
107:
108: @Override
109: public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI) {
110: return wrappedConnection.prepareGraphQuery(ql, query, baseURI);
111: }
112:
113: @Override
114: public BooleanQuery prepareBooleanQuery(QueryLanguage ql, String query) {
115: return wrappedConnection.prepareBooleanQuery(ql, query);
116: }
117:
118: @Override
119: public BooleanQuery prepareBooleanQuery(QueryLanguage ql, String query, String baseURI) {
120: return wrappedConnection.prepareBooleanQuery(ql, query, baseURI);
121: }
122:
123: @Override
124: public Update prepareUpdate(QueryLanguage ql, String update) {
125: return wrappedConnection.prepareUpdate(ql, update);
126: }
127:
128: @Override
129: public Update prepareUpdate(QueryLanguage ql, String update, String baseURI) {
130: return wrappedConnection.prepareUpdate(ql, update, baseURI);
131: }
132:
133: @Override
134: public RepositoryResult<Resource> getContextIDs() {
135: return wrappedConnection.getContextIDs();
136: }
137:
138: @Override
139: public RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred,
140: Resource... contexts) {
141: return wrappedConnection.getStatements(subj, pred, obj, includeInferred, contexts);
142: }
143:
144: @Override
145: public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) {
146: return wrappedConnection.hasStatement(subj, pred, obj, includeInferred, contexts);
147: }
148:
149: @Override
150: public boolean hasStatement(Statement st, boolean includeInferred, Resource... contexts) {
151: return wrappedConnection.hasStatement(st, includeInferred, contexts);
152: }
153:
154: @Override
155: public void exportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler,
156: Resource... contexts) {
157: wrappedConnection.exportStatements(subj, pred, obj, includeInferred, handler, contexts);
158: }
159:
160: @Override
161: public void export(RDFHandler handler, Resource... contexts) {
162: wrappedConnection.export(handler, contexts);
163: }
164:
165: @Override
166: public long size(Resource... contexts) {
167: return wrappedConnection.size(contexts);
168: }
169:
170: @Override
171: public boolean isEmpty() {
172: return wrappedConnection.isEmpty();
173: }
174:
175: @Deprecated
176: @Override
177: public void setAutoCommit(boolean autoCommit) {
178: wrappedConnection.setAutoCommit(autoCommit);
179: }
180:
181: @Deprecated
182: @Override
183: public boolean isAutoCommit() {
184: return wrappedConnection.isAutoCommit();
185: }
186:
187: @Override
188: public boolean isActive() {
189: return wrappedConnection.isActive();
190: }
191:
192: @Override
193: public void setIsolationLevel(IsolationLevel level) {
194: wrappedConnection.setIsolationLevel(level);
195: }
196:
197: @Override
198: public IsolationLevel getIsolationLevel() {
199: return wrappedConnection.getIsolationLevel();
200: }
201:
202: @Override
203: public void begin() {
204: wrappedConnection.begin();
205: }
206:
207: @Override
208: public void begin(IsolationLevel level) {
209: wrappedConnection.begin(level);
210: }
211:
212: @Override
213: public void commit() {
214: wrappedConnection.commit();
215: }
216:
217: @Override
218: public void rollback() {
219: wrappedConnection.rollback();
220: }
221:
222: @Override
223: public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts)
224: throws IOException {
225: wrappedConnection.add(in, baseURI, dataFormat, contexts);
226: }
227:
228: @Override
229: public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts)
230: throws IOException {
231: wrappedConnection.add(reader, baseURI, dataFormat, contexts);
232: }
233:
234: @Override
235: public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts)
236: throws IOException {
237: wrappedConnection.add(url, baseURI, dataFormat, contexts);
238: }
239:
240: @Override
241: public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts)
242: throws IOException {
243: wrappedConnection.add(file, baseURI, dataFormat, contexts);
244: }
245:
246: @Override
247: public void add(Resource subject, IRI predicate, Value object, Resource... contexts) {
248: wrappedConnection.add(subject, predicate, object, contexts);
249: }
250:
251: @Override
252: public void add(Statement st, Resource... contexts) {
253: wrappedConnection.add(st, contexts);
254: }
255:
256: @Override
257: public void add(Iterable<? extends Statement> statements, Resource... contexts) {
258: wrappedConnection.add(statements, contexts);
259: }
260:
261: @Override
262: public <E extends Exception> void add(Iteration<? extends Statement, E> statements, Resource... contexts) throws E {
263: wrappedConnection.add(statements, contexts);
264: }
265:
266: @Override
267: public void remove(Resource subject, IRI predicate, Value object, Resource... contexts) {
268: wrappedConnection.remove(subject, predicate, object, contexts);
269: }
270:
271: @Override
272: public void remove(Statement st, Resource... contexts) {
273: wrappedConnection.remove(st, contexts);
274: }
275:
276: @Override
277: public void remove(Iterable<? extends Statement> statements, Resource... contexts) {
278: wrappedConnection.remove(statements, contexts);
279: }
280:
281: @Override
282: public <E extends Exception> void remove(Iteration<? extends Statement, E> statements, Resource... contexts)
283: throws E {
284: wrappedConnection.remove(statements, contexts);
285: }
286:
287: @Override
288: public void clear(Resource... contexts) {
289: wrappedConnection.clear(contexts);
290: }
291:
292: @Override
293: public RepositoryResult<Namespace> getNamespaces() {
294: return wrappedConnection.getNamespaces();
295: }
296:
297: @Override
298: public String getNamespace(String prefix) {
299: return wrappedConnection.getNamespace(prefix);
300: }
301:
302: @Override
303: public void setNamespace(String prefix, String name) {
304: wrappedConnection.setNamespace(prefix, name);
305: }
306:
307: @Override
308: public void removeNamespace(String prefix) {
309: wrappedConnection.removeNamespace(prefix);
310: }
311:
312: @Override
313: public void clearNamespaces() {
314: wrappedConnection.clearNamespaces();
315: }
316: }