public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException { List<BindingSet> list1 = Iterations.asList(tqr1); List<BindingSet> list2 = Iterations.asList(tqr2); // Compare the number of statements in both sets if (list1.size() > list2.size()) { return false; } return matchBindingSets(list1, list2); }
/** * Compares two graph query results and returns {@code true} if they are * equal. Two graph query results are considered equal if they are isomorphic * graphs. Note that the method consumes both query results fully. * * @param result1 * the first query result to compare * @param result2 * the second query result to compare. * @return {@code true} iff the supplied graph query results are isomorphic * graphs, {@code false} otherwise. * @throws QueryEvaluationException * @see {@link Models#isomorphic(Iterable, Iterable)} */ public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException { Set<? extends Statement> graph1 = Iterations.asSet(result1); Set<? extends Statement> graph2 = Iterations.asSet(result2); return Models.isomorphic(graph1, graph2); }
public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames, Iteration<? extends BindingSet, E> bindingSetIter) throws E { this.bindingNames.addAll(bindingNames); Iterations.addAll(bindingSetIter, this.bindingSets); }
Iterations.asList(conn.getStatements(annotationIdUri, RDF.TYPE, OasConstants.TAGGING_TAGGING, true, annotationManagementGraph)); if(checkQuery.size() != 1) Iterations.addAll(conn.getStatements(annotationIdUri, null, null, true, annotationIdUri), statements); Iterations.asList(conn.getStatements(annotationIdUri, OasConstants.TAGGING_TAGGED_RESOURCE, null, true, annotationIdUri)); Iterations.addAll( conn.getStatements((URI)nextTaggedResource.getObject(), null, null, true, annotationIdUri), statements); Iterations.asList(conn.getStatements(annotationIdUri, OasConstants.MOAT_TAG_MEANING, null, true, annotationIdUri)); Iterations.addAll( conn.getStatements((URI)nextTermResource.getObject(), null, null, true, annotationIdUri), statements);
@Override protected void handleClose() throws QueryEvaluationException { Iterations.closeCloseable(currentIter); super.handleClose(); }
Iterations.addAll(conn.getStatements(nextSubject, null, null, true), statements); Iterations.asList(conn.getStatements(nextSubject, OasConstants.TAGGING_TAGGED_RESOURCE, null, true)); Iterations.addAll(conn.getStatements((URI)nextTaggedResource.getObject(), null, null, true), statements); Iterations.asList(conn .getStatements(nextSubject, OasConstants.MOAT_TAG_MEANING, null, true)); Iterations.addAll(conn.getStatements((URI)nextTermResource.getObject(), null, null, true), statements);
private int countElements(Iteration<?, ?> iter) throws Exception { int count = 0; try { while (iter.hasNext()) { iter.next(); count++; } } finally { Iterations.closeCloseable(iter); } return count; }
@Override public List<Statement> getLdpTypes(RepositoryConnection connection, URI resource) throws RepositoryException { return Iterations.asList(new FilterIteration<Statement, RepositoryException>(connection.getStatements(resource, RDF.TYPE, null, false, ldpContext)) { @Override protected boolean accept(Statement statement) { final Value object = statement.getObject(); return object instanceof URI && object.stringValue().startsWith(LDP.NAMESPACE); } }); //FIXME }
/** * Helper method prints the contents of the given context of a Repository */ public static void printContexts(final RepositoryConnection conn) throws RepositoryException { System.out.println("=================================================="); System.out.println("Contexts in Repository: "); for(final Resource context : Iterations.asSet(conn.getContextIDs())) { System.out.println(context); } System.out.println("=================================================="); }
public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames, Iteration<? extends BindingSet, E> bindingSetIter) throws E { this.bindingNames.addAll(bindingNames); Iterations.addAll(bindingSetIter, this.bindingSets); }
@Override protected void handleClose() throws X { super.handleClose(); Iterations.closeCloseable(getRightArg()); }
private List<Map<String,Object>> formatVersions(RepositoryResult<Version> versions) throws RepositoryException { return formatVersions(Iterations.asList(versions)); }
@Test public void testGetNamespaces() throws Exception { setupNamespaces(); Map<String, String> map = Namespaces.asMap(Iterations.asSet(testCon.getNamespaces())); assertThat(map.size(), is(equalTo(3))); assertThat(map.keySet(), hasItems(EXAMPLE, RDFS_PREFIX, RDF_PREFIX)); assertThat(map.get(EXAMPLE), is(equalTo(EXAMPLE_NS))); assertThat(map.get(RDFS_PREFIX), is(equalTo(RDFS_NS))); assertThat(map.get(RDF_PREFIX), is(equalTo("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); }
public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames, Iteration<? extends BindingSet, E> bindingSetIter) throws E { this.bindingNames.addAll(bindingNames); Iterations.addAll(bindingSetIter, this.bindingSets); }
@Override protected void handleClose() throws RepositoryException { try { Iterations.closeCloseable(wrappedIter); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } super.handleClose(); }
private List<Map<String,Object>> formatVersions(RepositoryResult<Version> versions) throws RepositoryException { return formatVersions(Iterations.asList(versions)); }
while (groupIter.hasNext()) { Resource r = groupIter.next(); patternTypes.put(r, Iterations.asSet(Statements.getObjectURIs(r, RDF.TYPE, store)));
protected Set<BindingSet> makeSet(Iteration<BindingSet, X> rightArg2) throws X { return Iterations.addAll(rightArg, makeSet()); }
private <T> T first(Iteration<T, ?> iter) throws Exception { try { if (iter.hasNext()) { return iter.next(); } } finally { Iterations.closeCloseable(iter); } return null; }