use of com.inova8.intelligentgraph.path.PathBinding in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternPathTests method test_4.
/**
* Test 4.
*
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
@Test
@Order(4)
void test_4() throws RecognitionException, PathPatternException {
PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn[ eq [ rdfs:label \"Calc2Graph1\"] ]#/^:lat/:long/^:left/:right");
PathBinding pathBinding = new PathBinding();
pathBinding = element.visitPathBinding(pathBinding, 0);
assertEquals("[n0,r1:<http://default/Location>@http://default/appearsOn,r1,DIRECT,true]\r\n" + "[r1,http://default/lat,n2,INVERSE]\r\n" + "[n2,http://default/long,n3,DIRECT]\r\n" + "[n3,http://default/left,n4,INVERSE]\r\n" + "[n4,http://default/right,n5,DIRECT]\r\n" + "", pathBinding.toString());
}
use of com.inova8.intelligentgraph.path.PathBinding in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternPathTests method test_2.
/**
* Test 2.
*
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
@Test
@Order(2)
void test_2() throws RecognitionException, PathPatternException {
PathElement element = PathParser.parsePathPattern(repositoryContext, ":parent1[:gender :female]/^:child2[:gender :male; :birthplace [rdfs:label 'Maidstone']]/:parent3");
PathBinding pathBinding = new PathBinding();
pathBinding = element.visitPathBinding(pathBinding, 0);
assertEquals("[n0,http://default/parent1,n1,DIRECT]\r\n" + "[n1,http://default/child2,n2,INVERSE]\r\n" + "[n2,http://default/parent3,n3,DIRECT]\r\n" + "", pathBinding.toString());
}
use of com.inova8.intelligentgraph.path.PathBinding 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());
}
use of com.inova8.intelligentgraph.path.PathBinding in project com.inova8.intelligentgraph by peterjohnlawrence.
the class FactResults method nextResource.
/**
* Next resource.
*
* @return the resource
* @throws QueryEvaluationException the query evaluation exception
*/
@Override
public Resource nextResource() throws QueryEvaluationException {
BindingSet next = getResourceSet().next();
PathBinding path = new PathBinding();
path = pathElement.visitPathBinding(path, 0);
// for(Edge edge:path) {
// TODO
// Value sourceValue = next.getBinding(edge.getSourceVariable().getName()).getValue();
// Value predicateValue = next.getBinding(edge.getPredicateVariable().getName()).getValue();
// Value reificationValue = edge.getReification();
// Value targetValue = next.getBinding(edge.getTargetVariable().getName()).getValue();
// Boolean direction = edge.isInverse();
// Boolean isDereified = edge.getIsDereified();
// Fact edgeFact = new Fact(sourceValue, predicateValue, targetValue);
// }
Resource objectValue = calculateValue(next);
return new Fact(next.getBinding(getPathElement().getTargetSubject().getName()).getValue(), next.getBinding(getPathElement().getTargetPredicate().getName()).getValue(), objectValue.getValue());
}
Aggregations