use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class IntelligentGraphRepository method getPath.
public Path getPath(String boundPredicatePattern, CustomQueryOptions customQueryOptions) {
logger.debug("getPath{}\n", boundPredicatePattern);
PathResults pathValues = getPaths(boundPredicatePattern, null);
if (pathValues == null) {
// this.getEvaluationContext().getTracer().tracePathReturnNull(this, boundPredicatePattern);
return new NullPath();
} else if (pathValues.hasNext()) {
Path path = (Path) pathValues.next();
// this.getEvaluationContext().getTracer().tracePathReturn(this, boundPredicatePattern,path);
return path;
} else {
// this.getEvaluationContext().getTracer().tracePathEmpty(this, boundPredicatePattern);
pathValues.close();
return new NullPath();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class IntelligentGraphRepository method getPaths.
public PathResults getPaths(String boundPredicatePattern, CustomQueryOptions customQueryOptions) {
logger.debug("getPaths{}\n", boundPredicatePattern);
// this.getEvaluationContext().getTracer().tracePaths(this, boundPredicatePattern);
SimpleDataset dataset = IntelligentGraphRepository.getDataset(customQueryOptions);
// dataset.addDefaultGraph(this.graphName);
org.eclipse.rdf4j.model.Resource[] contextArray = dataset.getDefaultGraphs().toArray(new org.eclipse.rdf4j.model.Resource[0]);
PathResults results = null;
IRI predicate = IntelligentGraphRepository.preparePredicate(PATHQL.getPaths, boundPredicatePattern);
if (this.getRepository() == null) {
CloseableIteration<? extends Statement, QueryEvaluationException> localPathIterator = this.getTripleSource().getStatements(null, predicate, null, contextArray);
results = new PathResults(localPathIterator, this, null);
} else {
CloseableIteration<Statement, RepositoryException> pathIterator = this.getRepository().getConnection().getStatements(null, predicate, null, contextArray);
results = new PathResults(pathIterator, this, null, customQueryOptions);
}
return results;
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_BoundPath_Tests method test_2.
/**
* Test 2.
*/
@Test
@Order(2)
void test_2() {
try {
PathResults paths = source.getPaths("[ eq <http://inova8.com/calc2graph/id/Continuant_1>]/:Connection@:connectedTo/:Connection@:connectedTo/:Connection@:connectedTo");
assertEquals("Path=[[http://inova8.com/calc2graph/id/Continuant_1,<http://inova8.com/calc2graph/id/Connection_1_2>:<http://inova8.com/calc2graph/def/Connection>@http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Continuant_2,DIRECT,false]\r\n" + "[http://inova8.com/calc2graph/id/Continuant_2,<http://inova8.com/calc2graph/id/Connection_2_3>:<http://inova8.com/calc2graph/def/Connection>@http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Continuant_3,DIRECT,false]\r\n" + "[http://inova8.com/calc2graph/id/Continuant_3,<http://inova8.com/calc2graph/id/Connection_3_4>:<http://inova8.com/calc2graph/def/Connection>@http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Continuant_4,DIRECT,false]\r\n" + "]\r\n" + "", paths.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_BoundPath_Tests method test_3.
/**
* Test 3.
*/
@Test
@Order(3)
void test_3() {
try {
PathResults paths = source.getPaths("[ eq <http://inova8.com/calc2graph/id/Continuant_1>]/:Connection@:connectedTo/:Connection@:connectedTo/:Connection@:connectedTo#");
assertEquals("Path=[[http://inova8.com/calc2graph/id/Continuant_1,<http://inova8.com/calc2graph/id/Connection_1_2>:<http://inova8.com/calc2graph/def/Connection>@http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Continuant_2,DIRECT,false]\r\n" + "[http://inova8.com/calc2graph/id/Continuant_2,<http://inova8.com/calc2graph/id/Connection_2_3>:<http://inova8.com/calc2graph/def/Connection>@http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Continuant_3,DIRECT,false]\r\n" + "[http://inova8.com/calc2graph/id/Continuant_3,<http://inova8.com/calc2graph/id/Connection_3_4>:<http://inova8.com/calc2graph/def/Connection>@http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Connection_3_4,DIRECT,true]\r\n" + "]\r\n" + "", paths.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_BoundPath_Tests method test_7.
/**
* Test 7.
*/
@Test
@Order(7)
void test_7() {
try {
Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Equipment_1"), null);
ResourceResults results = _this.getFacts(":connectedTo{1,3}");
ArrayList<String> resultsArrayList = new ArrayList<String>();
for (Resource result : results) {
resultsArrayList.add(result.stringValue());
}
assertEquals("[http://inova8.com/calc2graph/id/Equipment_2, http://inova8.com/calc2graph/id/Equipment_2_1, http://inova8.com/calc2graph/id/Equipment_3, http://inova8.com/calc2graph/id/Equipment_2_2, http://inova8.com/calc2graph/id/Equipment_4, http://inova8.com/calc2graph/id/Equipment_2_3]", resultsArrayList.toString());
PathResults paths = _this.getPaths(":connectedTo{1,3}");
ArrayList<String> pathArrayList = new ArrayList<String>();
for (Path path : paths) {
pathArrayList.add(path.toString());
}
assertEquals("[Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_1,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_3,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_1,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_2,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_3,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_3,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_4,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_1,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_2,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2_2,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_3,DIRECT]\r\n" + "]\r\n" + "]", pathArrayList.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
e.printStackTrace();
}
}
Aggregations