Search in sources :

Example 21 with PathTupleExpr

use of com.inova8.intelligentgraph.path.PathTupleExpr in project com.inova8.intelligentgraph by peterjohnlawrence.

the class IntelligentStatementPaths method hasNext.

/**
 * Checks for next.
 *
 * @return true, if successful
 * @throws QueryEvaluationException the query evaluation exception
 */
@Override
public boolean hasNext() throws QueryEvaluationException {
    if (resultsIterator != null && resultsIterator.hasNext()) {
        return true;
    } else {
        while (pathIteration < this.sortedIterations.size()) {
            CustomQueryOptions customQueryOptions = CustomQueryOption.getCustomQueryOptions(contexts, source.getRepositoryContext().getPrefixes());
            pathTupleExpr = pathElement.pathPatternQuery(pathIteration, customQueryOptions);
            if (this.thing == null && pathTupleExpr.getBoundVariable() == null) {
                throw new QueryEvaluationException("Paths query unbound");
            } else {
                this.boundVariableName = pathTupleExpr.getBoundVariable().getName();
            }
            pathIteration++;
            this.resultsIterator = intelligentGraphConnection.getResultsIterator(source, thing, pathElement, pathTupleExpr, contexts);
            boolean hasNext = resultsIterator.hasNext();
            if (hasNext)
                return true;
        }
        return false;
    }
}
Also used : CustomQueryOptions(com.inova8.intelligentgraph.context.CustomQueryOptions) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException)

Aggregations

PathTupleExpr (com.inova8.intelligentgraph.path.PathTupleExpr)19 PathElement (com.inova8.pathql.element.PathElement)10 Order (org.junit.jupiter.api.Order)10 Test (org.junit.jupiter.api.Test)10 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)10 Join (org.eclipse.rdf4j.query.algebra.Join)6 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)6 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)3 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)2 StatementBinding (com.inova8.intelligentgraph.path.StatementBinding)2 Filter (org.eclipse.rdf4j.query.algebra.Filter)2 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)2 Union (org.eclipse.rdf4j.query.algebra.Union)2 QueryException (com.inova8.intelligentgraph.exceptions.QueryException)1 UnionBinding (com.inova8.intelligentgraph.path.UnionBinding)1 Iterations (com.inova8.pathql.element.Iterations)1 ArrayList (java.util.ArrayList)1 IRI (org.eclipse.rdf4j.model.IRI)1 BindingSet (org.eclipse.rdf4j.query.BindingSet)1 And (org.eclipse.rdf4j.query.algebra.And)1