public ClosableIterator<OOQueryRow> iterator() { return new SparqlIterator(this, this.resultTable.iterator()); }
public List<String> getVariables() { return this.resultTable.getVariables(); }
@Override public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException { QueryResultTable table = sparqlSelect(query); ClosableIterator<QueryRow> it = table.iterator(); boolean result = it.hasNext(); it.close(); return result; }
public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException { QueryResultTable table = sparqlSelect(query); ClosableIterator<QueryRow> it = table.iterator(); boolean result = it.hasNext(); it.close(); return result; }
public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException { QueryResultTable table = sparqlSelect(query); ClosableIterator<QueryRow> it = table.iterator(); boolean result = it.hasNext(); it.close(); return result; }
@Override public boolean sparqlAsk(String query) throws ModelRuntimeException, MalformedQueryException { QueryResultTable table = sparqlSelect(query); ClosableIterator<QueryRow> it = table.iterator(); boolean result = it.hasNext(); it.close(); return result; }
/** * Use a SPARQL query on the model and wrap the result in a * SparlSingleVariableIterator, to ensure that only single elements are * included in the result. Assume 'x' as variable name. * * @param m - the underlying RDF2Go model * @param returnType - the desired Java return type * @param sparqlSelectQuery - the SPARQL query string * @return SparqlSingleVariableIterator wrapper around the SPARQL query * result * @throws ModelRuntimeException ... */ @SuppressWarnings("unchecked") public static Iterator<? extends Object> getSparqlSelectSingleVariable(Model m, Class<?> returnType, String sparqlSelectQuery) throws ModelRuntimeException { ClosableIterator<QueryRow> it = m.sparqlSelect(sparqlSelectQuery).iterator(); return new ObjectResultIterator(m, new ExtractingIterator(m, it, "x"), returnType); }
/** * Return all instances of the given class as a SubjectResultIterator * object. * * @param model - * underlying RDF2Go model * @param javaClass - * the java class representing the class the instances which * should be returned * @param classURI - * URI of the (RDFS/OWL) class. currently not used * @return SubjectResultIterator over the resulting instances */ @SuppressWarnings("unchecked") public static Iterator<?> getAllInstancesAsIterator(Model model, Class javaClass, URI classURI) { ClosableIterator<QueryRow> it; try { // it = model.findStatements(Variable.ANY, RDF.type, // getClassURI(javaClass)).iterator(); it = model.sparqlSelect( "SELECT ?x WHERE { ?x <" + RDF.type + "> <" + classURI + ">}").iterator(); return new ObjectResultIterator(model, new ExtractingIterator( model, it, "x"), javaClass); } catch (Exception e) { throw new RuntimeException(e); } }
public Collection<Resource> getAllReificationsOf(Statement statement) { QueryResultTable table = this.sparqlSelect("SELECT ?res WHERE { " + " ?res " + RDF.type.toSPARQL() + " " + RDF.Statement + " ." + " ?res " + RDF.subject.toSPARQL() + " " + statement.getSubject().toSPARQL() + " ." + " ?res " + RDF.predicate.toSPARQL() + " " + statement.getPredicate().toSPARQL() + " ." + " ?res " + RDF.object.toSPARQL() + " " + statement.getObject().toSPARQL() + " ." + " }"); LinkedList<Resource> result = new LinkedList<Resource>(); ClosableIterator<QueryRow> it = table.iterator(); while (it.hasNext()) { Resource res = it.next().getValue("res").asResource(); result.add(res); } it.close(); return result; }
public Collection<Resource> getAllReificationsOf(Statement statement) { QueryResultTable table = this.sparqlSelect("SELECT ?res WHERE { " + " ?res " + RDF.type.toSPARQL() + " " + RDF.Statement + " ." + " ?res " + RDF.subject.toSPARQL() + " " + statement.getSubject().toSPARQL() + " ." + " ?res " + RDF.predicate.toSPARQL() + " " + statement.getPredicate().toSPARQL() + " ." + " ?res " + RDF.object.toSPARQL() + " " + statement.getObject().toSPARQL() + " ." + " }"); LinkedList<Resource> result = new LinkedList<Resource>(); ClosableIterator<QueryRow> it = table.iterator(); while (it.hasNext()) { Resource res = it.next().getValue("res").asResource(); result.add(res); } it.close(); return result; }
@Override public Collection<Resource> getAllReificationsOf(Statement statement) { QueryResultTable table = this.sparqlSelect("SELECT ?res WHERE { " + " ?res " + RDF.type.toSPARQL() + " " + RDF.Statement.toSPARQL() + " ." + " ?res " + RDF.subject.toSPARQL() + " " + statement.getSubject().toSPARQL() + " ." + " ?res " + RDF.predicate.toSPARQL() + " " + statement.getPredicate().toSPARQL() + " ." + " ?res " + RDF.object.toSPARQL() + " " + statement.getObject().toSPARQL() + " ." + " }"); LinkedList<Resource> result = new LinkedList<Resource>(); ClosableIterator<QueryRow> it = table.iterator(); while(it.hasNext()) { Resource res = it.next().getValue("res").asResource(); result.add(res); } it.close(); return result; }
@Override public Collection<Resource> getAllReificationsOf(Statement statement) { QueryResultTable table = this.sparqlSelect("SELECT ?res WHERE { \n" + " ?res " + RDF.type.toSPARQL() + " " + RDF.Statement.toSPARQL() + " ." + " ?res " + RDF.subject.toSPARQL() + " " + statement.getSubject().toSPARQL() + " ." + " ?res " + RDF.predicate.toSPARQL() + " " + statement.getPredicate().toSPARQL() + " ." + " ?res " + RDF.object.toSPARQL() + " " + statement.getObject().toSPARQL() + " ." + " }"); LinkedList<Resource> result = new LinkedList<Resource>(); ClosableIterator<QueryRow> it = table.iterator(); while (it.hasNext()) { Resource res = it.next().getValue("res").asResource(); result.add(res); } it.close(); return result; }
QueryResultTable result = new QueryResultTableImpl(exec); return Long .parseLong(result.iterator().next().getLiteralValue("count"));