Package: ConnectionStatementExecutor
ConnectionStatementExecutor
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ConnectionStatementExecutor(RepositoryConnection) |
|
|
|
|
|
||||||||||||||||||||
executeBooleanQuery(String) |
|
|
|
|
|
||||||||||||||||||||
executeSelectQuery(String) |
|
|
|
|
|
||||||||||||||||||||
executeUpdate(String) |
|
|
|
|
|
Coverage
1: package cz.cvut.kbss.ontodriver.sesame.connector;
2:
3:
4: import cz.cvut.kbss.ontodriver.sesame.config.SesameOntoDriverProperties;
5: import cz.cvut.kbss.ontodriver.sesame.exceptions.SesameDriverException;
6: import org.openrdf.query.*;
7: import org.openrdf.repository.RepositoryConnection;
8: import org.openrdf.repository.RepositoryException;
9:
10: /**
11: * Actual implementation of statement processing.
12: */
13: class ConnectionStatementExecutor implements StatementExecutor {
14:
15: private final RepositoryConnection connection;
16:
17: ConnectionStatementExecutor(RepositoryConnection connection) {
18: this.connection = connection;
19: }
20:
21: @Override
22: public TupleQueryResult executeSelectQuery(String query) throws SesameDriverException {
23: try {
24: final TupleQuery tq = connection.prepareTupleQuery(QueryLanguage.SPARQL, query);
25: return new QueryResult(tq.evaluate(), connection);
26: } catch (MalformedQueryException | QueryEvaluationException | RepositoryException e) {
27: throw new SesameDriverException(e);
28: }
29: }
30:
31: @Override
32: public boolean executeBooleanQuery(String query) throws SesameDriverException {
33: try {
34: return connection.prepareBooleanQuery(QueryLanguage.SPARQL, query).evaluate();
35: } catch (MalformedQueryException | QueryEvaluationException | RepositoryException e) {
36: throw new SesameDriverException(e);
37: }
38: }
39:
40: @Override
41: public void executeUpdate(String query) throws SesameDriverException {
42: try {
43: final Update u = connection.prepareUpdate(QueryLanguage.SPARQL, query);
44: u.execute();
45: } catch (MalformedQueryException | UpdateExecutionException | RepositoryException e) {
46: throw new SesameDriverException(e);
47: }
48: }
49: }