Skip to content

Package: ConnectionStatementExecutor

ConnectionStatementExecutor

nameinstructionbranchcomplexitylinemethod
ConnectionStatementExecutor(RepositoryConnection)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
executeBooleanQuery(String)
M: 6 C: 7
54%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 1
33%
M: 0 C: 1
100%
executeSelectQuery(String)
M: 6 C: 14
70%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 2
50%
M: 0 C: 1
100%
executeUpdate(String)
M: 16 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

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: }