@Override protected boolean matchesSPARQL(RepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException { final BooleanQuery booleanQuery = con.prepareBooleanQuery(QueryLanguage.SPARQL, query, baseUri); return booleanQuery.evaluate(); }
@Override protected boolean matchesSPARQL(RepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException { final BooleanQuery booleanQuery = con.prepareBooleanQuery(QueryLanguage.SPARQL, query, baseUri); return booleanQuery.evaluate(); }
public static BooleanQuery getQuery(RepositoryConnection connection, ParsedBooleanQuery booleanQueryModel, boolean includeInferred) { try { QUERY_HOLDER.set(booleanQueryModel); BooleanQuery booleanQuery = connection.prepareBooleanQuery(DirectQuery.DIRECTQUERY, ""); booleanQuery.setIncludeInferred(includeInferred); return booleanQuery; } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (org.openrdf.repository.RepositoryException e) { throw new RepositoryException(e); } }
public static BooleanQuery getQuery(RepositoryConnection connection, BooleanQueryModel booleanQueryModel, boolean includeInferred) { try { QUERY_HOLDER.set(booleanQueryModel); BooleanQuery booleanQuery = connection.prepareBooleanQuery(DirectQuery.DIRECTQUERY, ""); booleanQuery.setIncludeInferred(includeInferred); return booleanQuery; } catch (StoreException e) { throw new RepositoryException(e); } catch (MalformedQueryException e) { throw new RepositoryException(e); } }
public static BooleanQuery getQuery(RepositoryConnection connection, BooleanQueryModel booleanQueryModel, boolean includeInferred) { try { QUERY_HOLDER.set(booleanQueryModel); BooleanQuery booleanQuery = connection.prepareBooleanQuery(DirectQuery.DIRECTQUERY, ""); booleanQuery.setIncludeInferred(includeInferred); return booleanQuery; } catch (StoreException e) { throw new RepositoryException(e); } catch (MalformedQueryException e) { throw new RepositoryException(e); } }
public void test10() throws Exception { populate(10); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test1000() throws Exception { populate(1000); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test100000() throws Exception { populate(100000); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test10000() throws Exception { populate(10000); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test100() throws Exception { populate(100); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
@Override public boolean sparqlAsk(String queryString) throws ModelRuntimeException { this.assertModel(); BooleanQuery booleanQuery; try { booleanQuery = this.connection.prepareBooleanQuery(QueryLanguage.SPARQL, queryString); boolean result = booleanQuery.evaluate(); return result; } catch(OpenRDFException e) { throw new ModelRuntimeException(e); } }
@Override public boolean sparqlAsk(String queryString) throws ModelRuntimeException { this.assertModel(); BooleanQuery booleanQuery; try { booleanQuery = this.connection.prepareBooleanQuery( QueryLanguage.SPARQL, queryString); boolean result = booleanQuery.evaluate(); return result; } catch (OpenRDFException e) { throw new ModelRuntimeException(e); } }
Model model = ...; // your model // create and initialize a temporary in-memory store Repository rep = new SailRepository(new MemoryStore()); rep.initialize(); try (RepositoryConnection conn = rep.getConnection()) { // load the model into the repository conn.add(model); // execute the query String query = "ASK WHERE { :s (:p1|:p2|:p3)+ :o . }"; boolean pathExists = conn.prepareBooleanQuery(query).evaluate(); }
/** * Executes a given ASK query against a given dataset. * * @param data the mistery guest containing test data (query and dataset) * @throws Exception never, otherwise the test fails. */ protected void askTest(final MisteryGuest data) throws Exception { load(data); final String queryString = queryString(data.query); final BooleanQuery localQuery = localConnection.prepareBooleanQuery(QueryLanguage.SPARQL, queryString); final BooleanQuery cumulusQuery = cumulusConnection.prepareBooleanQuery(QueryLanguage.SPARQL, queryString); assertEquals(localQuery.evaluate(), cumulusQuery.evaluate()); }
public void test10() throws Exception { populate(10); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test100() throws Exception { populate(100); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test10000() throws Exception { populate(10000); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test1000() throws Exception { populate(1000); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
public void test100000() throws Exception { populate(100000); String sparql = "ASK { <urn:test:root> <urn:test:hasChild>* <urn:test:node-end> }"; assertTrue(con.prepareBooleanQuery(QueryLanguage.SPARQL, sparql).evaluate()); }
@Test public void testSimpleBooleanQuery() throws Exception { testCon.add(alice, name, nameAlice, context2); testCon.add(alice, mbox, mboxAlice, context2); testCon.add(context2, publisher, nameAlice); testCon.add(bob, name, nameBob, context1); testCon.add(bob, mbox, mboxBob, context1); testCon.add(context1, publisher, nameBob); StringBuilder queryBuilder = new StringBuilder(64); queryBuilder.append(PREFIX_FOAF + FOAF_NS + "> "); queryBuilder.append(ASK); queryBuilder.append("{ ?p foaf:name ?name }"); boolean exists = testCon.prepareBooleanQuery(QueryLanguage.SPARQL, queryBuilder.toString()).evaluate(); assertThat(exists, is(equalTo(true))); }