@Override protected Object next() throws JspTagException { Object result = null; try { logger.debug("iteration next()..."); result = items.next(); if(result == null) { logger.debug("iteration.next() returned null"); } } catch (Exception e) { logger.debug("iteration.next() threw Exception"); throw new JspTagException(e); } return result; }
private <T> T first(Iteration<T, ?> iter) throws Exception { try { if (iter.hasNext()) { return iter.next(); } } finally { Iterations.closeCloseable(iter); } return null; }
private int countElements(Iteration<?, ?> iter) throws Exception { int count = 0; try { while (iter.hasNext()) { iter.next(); count++; } } finally { Iterations.closeCloseable(iter); } return count; }
/** * * @param arg2 the iteration with elements to add to the includeSet * @param includeSet the set that should have all unique elements of arg2 * @param used the collection size counter of all collections used in answering a query * @param maxSize the point at which we throw a new query exception * @return the includeSet * @throws QueryEvaluationException trigerred when maxSize is smaller than the used value */ public static Set<BindingSet> addAll(Iteration<? extends BindingSet, ? extends QueryEvaluationException> arg2, Set<BindingSet> includeSet, AtomicLong used, long maxSize) throws QueryEvaluationException { while (arg2.hasNext()) { if (includeSet.add(arg2.next()) && used.incrementAndGet() > maxSize) throw new QueryEvaluationException("Size limited reached inside intersect operator"); } return includeSet; }
private int countElements(Iteration<?, ?> iter) throws Exception { int count = 0; try { while (iter.hasNext()) { iter.next(); count++; } } finally { Iterations.closeCloseable(iter); } return count; }
private void visitInsert(Resource insert) throws OpenRDFException { Iteration<? extends Resource, QueryEvaluationException> groupIter = Statements.listResources(insert, store); while (groupIter.hasNext()) { Resource r = groupIter.next(); Value type = Statements.singleValue(r, RDF.TYPE, store); visitPattern(r, (type != null) ? Collections.singleton((IRI)type) : Collections.<IRI> emptySet()); } }
private void visitDelete(Resource delete) throws OpenRDFException { Iteration<? extends Resource, QueryEvaluationException> groupIter = Statements.listResources(delete, store); while (groupIter.hasNext()) { Resource r = groupIter.next(); Value type = Statements.singleValue(r, RDF.TYPE, store); visitPattern(r, (type != null) ? Collections.singleton((IRI)type) : Collections.<IRI> emptySet()); } }
@Override public <E extends Exception> void add( final Iteration<? extends Statement, E> stmts, final Resource... c) throws RepositoryException, E { final Graph g = new LinkedHashModel(); while (stmts.hasNext()) { g.add(stmts.next()); } add(g, c); }
@Override public <E extends Exception> void remove( final Iteration<? extends Statement, E> stmts, final Resource... c) throws RepositoryException, E { final Graph g = new LinkedHashModel(); while (stmts.hasNext()) { g.add(stmts.next()); } remove(g, c); }
Justification j = justifications.next(); if(j.getId() < 0) { log.error("cannot delete justification since it does not have a database ID");
private <T> T first(Iteration<T, ?> iter) throws Exception { try { if (iter.hasNext()) { return iter.next(); } } finally { Iterations.closeCloseable(iter); } return null; }
private int countElements(Iteration<?, ?> iter) throws Exception { int count = 0; try { while (iter.hasNext()) { iter.next(); count++; } } finally { Iterations.closeCloseable(iter); } return count; }
private Order visitOrderBy(Resource orderby) throws OpenRDFException { Order order = new Order(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(orderby, store); while (iter.hasNext()) { Resource r = iter.next(); OrderElem orderElem = visitOrderByCondition(r); order.addElement(orderElem); } return order; }
private void visitGroupBy(Resource groupby) throws OpenRDFException { if (group == null) { group = new Group(); } Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(groupby, store); while (iter.hasNext()) { Resource r = iter.next(); ValueExpr groupByExpr = visitExpression(r); if (!(groupByExpr instanceof Var)) { // TODO // have to create an intermediate Var/Extension for the // expression throw new UnsupportedOperationException("TODO!"); } group.addGroupBindingName(((Var)groupByExpr).getName()); } }
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 <E extends Exception> void remove( Iteration<? extends Statement, E> statementIter, Resource... contexts) throws RepositoryException, E { //Removes the supplied statements from a specific context in this repository, //ignoring any context information carried by the statements themselves. begin(); try { while (statementIter.hasNext()) { remove(statementIter.next(), contexts); } } catch (RepositoryException e) { if (autoCommit) { rollback(); } throw e; } catch (RuntimeException e) { if (autoCommit) { rollback(); } throw e; } finally { autoCommit(); } }
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { QueryPreparer qp = getCurrentQueryPreparer(); if (args.length != 3) { throw new ValueExprEvaluationException(String.format("%s requires 3 argument, got %d", getURI(), args.length)); } Resource subj = (Resource) args[0]; IRI pred = (IRI) args[1]; Resource list = (Resource) args[2]; try { Iteration<? extends Value, QueryEvaluationException> iter = Statements.list(list, qp.getTripleSource()); while (iter.hasNext()) { Value obj = iter.next(); if (Statements.single(subj, pred, obj, qp.getTripleSource()) == null) { return BooleanLiteralImpl.FALSE; } } } catch (QueryEvaluationException e) { throw new ValueExprEvaluationException(e); } return BooleanLiteralImpl.TRUE; } }
private TupleExpr visitHaving(Resource having) throws OpenRDFException { UnaryTupleOperator op = (UnaryTupleOperator)group.getParentNode(); op.setArg(new Extension(group)); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(having, store); while (iter.hasNext()) { Resource r = iter.next(); ValueExpr havingExpr = visitExpression(r); Filter filter = new Filter(op.getArg(), havingExpr); op.setArg(filter); op = filter; } return op; }
private Projection visitResultVariables(Resource resultVars) throws OpenRDFException { ProjectionElemList projElemList = new ProjectionElemList(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(resultVars, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElem projElem = visitResultVariable(r); projElemList.addElement(projElem); } Projection proj = new Projection(); proj.setProjectionElemList(projElemList); tupleRoot = proj; SingletonSet stub = new SingletonSet(); proj.setArg(stub); tupleNode = stub; return proj; }
private Projection visitResultNodes(Resource resultNodes) throws OpenRDFException { ProjectionElemList projElemList = new ProjectionElemList(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(resultNodes, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElem projElem = visitResultNode(r); projElemList.addElement(projElem); } Projection proj = new Projection(); proj.setProjectionElemList(projElemList); tupleRoot = new DescribeOperator(proj); SingletonSet stub = new SingletonSet(); proj.setArg(stub); tupleNode = stub; return proj; }