use of com.inova8.intelligentgraph.path.EdgeBinding in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PredicateElement method pathPredicatePatternTupleExpr.
/**
* Path predicate pattern tuple expr.
*
* @param predicatePattern the predicate pattern
* @param intermediateSourceVariable the intermediate source variable
* @param intermediatePredicateVariable the intermediate predicate variable
* @param intermediateTargetVariable the intermediate target variable
* @param customQueryOptions the custom query options
* @return the path tuple expr
*/
private PathTupleExpr pathPredicatePatternTupleExpr(PathTupleExpr predicatePattern, Variable intermediateSourceVariable, Variable intermediatePredicateVariable, Variable intermediateTargetVariable, CustomQueryOptions customQueryOptions) {
TupleExpr intermediatePredicatePattern;
Variable predicateVariable;
if (isNegated) {
predicateVariable = new Variable(getPredicateSPARQLVariable());
// TODO
Variable variable = new Variable("p2", predicate);
if (isInverseOf) {
StatementPattern inverseOfPattern = new StatementPattern(intermediateTargetVariable, predicateVariable, intermediateSourceVariable);
Compare filterExpression = new Compare(predicateVariable, variable, CompareOp.NE);
intermediatePredicatePattern = new Filter(inverseOfPattern, filterExpression);
} else {
intermediatePredicatePattern = new StatementPattern(intermediateSourceVariable, predicateVariable, intermediateTargetVariable);
}
} else {
intermediatePredicateVariable.setValue(predicate);
// Variable(getPredicateSPARQLVariable(), predicate);
predicateVariable = intermediatePredicateVariable;
if (isInverseOf) {
intermediatePredicatePattern = new StatementPattern(intermediateTargetVariable, predicateVariable, intermediateSourceVariable);
} else {
intermediatePredicatePattern = new StatementPattern(intermediateSourceVariable, predicateVariable, intermediateTargetVariable);
}
}
if (objectFilterElement != null) {
intermediatePredicatePattern = (TupleExpr) objectFilterElement.filterExpression(intermediateTargetVariable, intermediatePredicateVariable, null, intermediatePredicatePattern, customQueryOptions).getTupleExpr();
}
// EdgeBinding
statementBinding = new StatementBinding(intermediateSourceVariable, predicateVariable, intermediateTargetVariable, getIsInverseOf());
if (predicatePattern == null) {
predicatePattern = new PathTupleExpr(intermediatePredicatePattern);
// predicatePattern.setStatementBinding(statementBinding);
} else {
predicatePattern.setTupleExpr(new Join(predicatePattern.getTupleExpr(), intermediatePredicatePattern));
}
predicatePattern.setStatementBinding(statementBinding);
predicatePattern.setBoundVariable(predicatePattern.getStatementBinding().getSourceVariable());
predicatePattern.getPath().add(statementBinding);
return predicatePattern;
}
use of com.inova8.intelligentgraph.path.EdgeBinding in project com.inova8.intelligentgraph by peterjohnlawrence.
the class IntelligentStatementPaths method pathToLiteral.
/**
* Path to literal.
*
* @param bindingset the bindingset
* @return the literal
*/
private Literal pathToLiteral(BindingSet bindingset) {
ModelBuilder builder = new ModelBuilder();
builder.setNamespace("", PATHQL.NAMESPACE);
PathBinding thisPathBinding = pathTupleExpr.getPath();
for (EdgeBinding edge : thisPathBinding) {
edge.addEdgeToPathModel(builder, bindingset);
}
Model pathModel = builder.build();
OutputStream pathJSON = new ByteArrayOutputStream();
Rio.write(pathModel, pathJSON, RDFFormat.TURTLE);
return literal(pathJSON.toString());
}
Aggregations