private GraphOWLResultSet executeGraph(GraphSPARQLQuery query) throws OntopQueryEvaluationException, OntopConnectionException, OntopReformulationException, OntopResultConversionException { SimpleGraphResultSet resultSet = st.execute(query); return new OntopGraphOWLResultSet(resultSet); }
@Override public void close() throws OntopOWLException { try { st.close(); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
public void setFetchSize(int rows) throws OntopOWLException { try { st.setFetchSize(rows); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
tmpStatement.close(); } catch (OntopConnectionException e) { LOGGER.warn("Non-critical exception while closing the statement: " + e); tmpStatement = ontopConnection.createStatement(); if (doStreamResults) { tmpStatement.setFetchSize(FETCH_SIZE); tmpGraphResultSet = tmpStatement.execute(query);
@Override public TupleQueryResult evaluate() throws QueryEvaluationException { TupleResultSet res; OntopStatement stm; long start = System.currentTimeMillis(); try { stm = conn.createStatement(); if(this.queryTimeout > 0) stm.setQueryTimeout(this.queryTimeout); try { SelectQuery inputQuery = factory.createSelectQuery(getQueryString(), getParsedQuery()); res = stm.execute(inputQuery); } catch (OntopQueryAnsweringException e) { long end = System.currentTimeMillis(); if (this.queryTimeout > 0 && (end - start) >= this.queryTimeout * 1000){ throw new QueryEvaluationException("OntopTupleQuery timed out. More than " + this.queryTimeout + " seconds passed", e); } else throw e; } List<String> signature = res.getSignature(); return new OntopTupleQueryResult(res, signature); } catch (QueryEvaluationException e) { throw e; } catch (Exception e) { throw new QueryEvaluationException(e); } }
public void setQueryTimeout(int seconds) throws OntopOWLException { try { st.setQueryTimeout(seconds); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
public void getMoreResults() throws OntopOWLException { try { st.getMoreResults(); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
public void cancel() throws OntopOWLException { try { st.cancel(); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
public int getFetchSize() throws OntopOWLException { try { return st.getFetchSize(); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
public int getMaxRows() throws OntopOWLException { try { return st.getMaxRows(); } catch (OntopConnectionException e) { throw new OntopOWLException(e); } }
public ExecutableQuery getExecutableQuery(String query) throws OntopOWLException { try { return st.getExecutableQuery(parseQueryString(query)); } catch (OntopReformulationException e) { throw new OntopOWLException(e); } }
@Override public TupleQueryResult evaluate() throws QueryEvaluationException { TupleResultSet res; OntopStatement stm; long start = System.currentTimeMillis(); try { stm = conn.createStatement(); if(this.queryTimeout > 0) stm.setQueryTimeout(this.queryTimeout); try { SelectQuery inputQuery = factory.createSelectQuery(getQueryString(), getParsedQuery()); res = stm.execute(inputQuery); } catch (OntopQueryAnsweringException e) { long end = System.currentTimeMillis(); if (this.queryTimeout > 0 && (end - start) >= this.queryTimeout * 1000){ throw new QueryEvaluationException("OntopTupleQuery timed out. More than " + this.queryTimeout + " seconds passed", e); } else throw e; } List<String> signature = res.getSignature(); return new OntopTupleQueryResult(res, signature); } catch (QueryEvaluationException e) { throw e; } catch (Exception e) { throw new QueryEvaluationException(e); } }
@Override public BooleanOWLResultSet executeAskQuery(String inputQuery) throws OntopOWLException { try { AskQuery query = inputQueryFactory.createAskQuery(inputQuery); BooleanResultSet resultSet = st.execute(query); return new OntopBooleanOWLResultSet(resultSet); } catch (OntopQueryEngineException e) { throw new OntopOWLException(e); } }
/** * Releases all the connection resources */ public void close() throws OntopConnectionException { if (tmpStatement != null) { tmpStatement.close(); } if (ontopConnection != null) { ontopConnection.close(); } }
@Override public TupleOWLResultSet executeSelectQuery(String inputQuery) throws OntopOWLException { try { SelectQuery query = inputQueryFactory.createSelectQuery(inputQuery); TupleResultSet resultSet = st.execute(query); return new OntopTupleOWLResultSet(resultSet); } catch (OntopQueryEngineException e) { throw new OntopOWLException(e); } }
@Override public boolean evaluate() throws QueryEvaluationException { AskQuery query = factory.createAskQuery(getQueryString(), getParsedQuery()); try (OntopStatement stm = conn.createStatement(); BooleanResultSet rs = stm.execute(query)) { return rs.getValue(); } catch (OntopConnectionException | OntopQueryAnsweringException e) { throw new QueryEvaluationException(e); } }
@Override public boolean evaluate() throws QueryEvaluationException { AskQuery query = factory.createAskQuery(getQueryString(), getParsedQuery()); try (OntopStatement stm = conn.createStatement(); BooleanResultSet rs = stm.execute(query)) { return rs.getValue(); } catch (OntopConnectionException | OntopQueryAnsweringException e) { throw new QueryEvaluationException(e); } }
private boolean executeConsistencyQuery(String strQuery) throws OWLException { try (OntopConnection connection = queryEngine.getConnection(); OntopStatement st = connection.createStatement()) { AskQuery query = inputQueryFactory.createAskQuery(strQuery); BooleanResultSet trs = st.execute(query); if (trs != null) { boolean b = trs.getValue(); trs.close(); if (b) return false; } return true; } catch (Exception e) { throw new OWLException(e); } }
@Override public GraphQueryResult evaluate() throws QueryEvaluationException { ParsedQuery parsedQuery = getParsedQuery(); GraphSPARQLQuery query = isConstruct ? inputQueryFactory.createConstructQuery(getQueryString(), parsedQuery) : inputQueryFactory.createDescribeQuery(getQueryString(), parsedQuery); try ( OntopStatement stm = conn.createStatement(); SimpleGraphResultSet res = stm.execute(query) ){ Map<String, String> namespaces = new HashMap<>(); List<Statement> results = new LinkedList<>(); if (res != null) { while (res.hasNext()) { Assertion as = res.next(); Statement st = createStatement(as); if (st!=null) results.add(st); } } //return new GraphQueryResultImpl(namespaces, results.iterator()); return new GraphQueryResultImpl(namespaces, new CollectionIteration<>(results)); } catch (Exception e) { throw new QueryEvaluationException(e); } }
@Override public GraphQueryResult evaluate() throws QueryEvaluationException { ParsedQuery parsedQuery = getParsedQuery(); GraphSPARQLQuery query = isConstruct ? inputQueryFactory.createConstructQuery(getQueryString(), parsedQuery) : inputQueryFactory.createDescribeQuery(getQueryString(), parsedQuery); try ( OntopStatement stm = conn.createStatement(); SimpleGraphResultSet res = stm.execute(query) ){ Map<String, String> namespaces = new HashMap<>(); List<Statement> results = new LinkedList<>(); if (res != null) { while (res.hasNext()) { Assertion as = res.next(); Statement st = createStatement(as); if (st!=null) results.add(st); } } //return new GraphQueryResultImpl(namespaces, results.iterator()); return new GraphQueryResultImpl(namespaces, new CollectionIteration<>(results)); } catch (Exception e) { throw new QueryEvaluationException(e); } }