use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Thing method getPaths.
/**
* Gets the paths.
*
* @param predicatePattern the predicate pattern
* @param customQueryOptions the custom query options
* @return the paths
*/
public PathResults getPaths(String predicatePattern, CustomQueryOptions customQueryOptions) {
logger.debug("getPaths{}\n", predicatePattern);
this.getEvaluationContext().getTracer().tracePaths(this, predicatePattern);
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, predicatePattern);
if (this.getSource().getRepository() == null) {
CloseableIteration<? extends Statement, QueryEvaluationException> localPathIterator = this.getSource().getTripleSource().getStatements(this.getIRI(), predicate, null, contextArray);
results = new PathResults(localPathIterator, this, null);
} else {
CloseableIteration<Statement, RepositoryException> pathIterator = this.getSource().getRepository().getConnection().getStatements(this.getIRI(), 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_GetPath_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();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetPath_Tests method test_3.
/**
* Test 3.
*/
@Test
@Order(3)
void test_3() {
try {
Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Continuant_1"), null);
PathResults paths = _this.getPaths(":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_Eastman3D_GetPath_Tests method test_6.
/**
* Test 6.
*/
@Test
@Order(6)
void test_6() {
try {
Thing _this = source.getThing("eastman.BatteryLimit:Stripper.Bottoms");
PathResults paths = _this.getPaths("^plant:Transference@plant.TransferenceKind:ProcessFlow{3,3}");
for (Path path : paths) {
assertEquals("Path=[[http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,<http://inova8.com/eastman/id/ProcessFlow/U8-processFlow-Stripper.Bottoms>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Valve/U8,INVERSE,false]\r\n" + "[http://inova8.com/eastman/id/Valve/U8,<http://inova8.com/eastman/id/ProcessFlow/G103-processFlow-U8>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Pump/G103,INVERSE,false]\r\n" + "[http://inova8.com/eastman/id/Pump/G103,<http://inova8.com/eastman/id/ProcessFlow/V103-processFlow-G103>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Vessel/V103,INVERSE,false]\r\n" + "]\r\n" + "", path.toString());
break;
}
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_Eastman3D_GetPath_Tests method test_3.
/**
* Test 3.
*/
@Test
@Order(3)
void test_3() {
try {
Thing _this = source.getThing("eastman.Signal:XMEAS17");
//
PathResults paths = _this.getPaths("^plant:attribute.providedBy/plant:attribute.of.PlantItem/^plant:Transference@plant.TransferenceKind:ProcessFlow{1,3}");
assertEquals("Path=[[http://inova8.com/eastman/id/Signal/XMEAS17,http://inova8.com/plant/def/attribute.providedBy,http://inova8.com/eastman/id/Attribute/Stripper.Bottoms.volumeFlow.XMEAS17,INVERSE]\r\n" + "[http://inova8.com/eastman/id/Attribute/Stripper.Bottoms.volumeFlow.XMEAS17,http://inova8.com/plant/def/attribute.of.PlantItem,http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,DIRECT]\r\n" + "[http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,<http://inova8.com/eastman/id/ProcessFlow/U8-processFlow-Stripper.Bottoms>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Valve/U8,INVERSE,false]\r\n" + "]\r\n" + "Path=[[http://inova8.com/eastman/id/Signal/XMEAS17,http://inova8.com/plant/def/attribute.providedBy,http://inova8.com/eastman/id/Attribute/Stripper.Bottoms.volumeFlow.XMEAS17,INVERSE]\r\n" + "[http://inova8.com/eastman/id/Attribute/Stripper.Bottoms.volumeFlow.XMEAS17,http://inova8.com/plant/def/attribute.of.PlantItem,http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,DIRECT]\r\n" + "[http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,<http://inova8.com/eastman/id/ProcessFlow/U8-processFlow-Stripper.Bottoms>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Valve/U8,INVERSE,false]\r\n" + "[http://inova8.com/eastman/id/Valve/U8,<http://inova8.com/eastman/id/ProcessFlow/G103-processFlow-U8>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Pump/G103,INVERSE,false]\r\n" + "]\r\n" + "Path=[[http://inova8.com/eastman/id/Signal/XMEAS17,http://inova8.com/plant/def/attribute.providedBy,http://inova8.com/eastman/id/Attribute/Stripper.Bottoms.volumeFlow.XMEAS17,INVERSE]\r\n" + "[http://inova8.com/eastman/id/Attribute/Stripper.Bottoms.volumeFlow.XMEAS17,http://inova8.com/plant/def/attribute.of.PlantItem,http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,DIRECT]\r\n" + "[http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms,<http://inova8.com/eastman/id/ProcessFlow/U8-processFlow-Stripper.Bottoms>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Valve/U8,INVERSE,false]\r\n" + "[http://inova8.com/eastman/id/Valve/U8,<http://inova8.com/eastman/id/ProcessFlow/G103-processFlow-U8>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Pump/G103,INVERSE,false]\r\n" + "[http://inova8.com/eastman/id/Pump/G103,<http://inova8.com/eastman/id/ProcessFlow/V103-processFlow-G103>:<http://inova8.com/plant/def/Transference>@http://inova8.com/plant/def/TransferenceKind/ProcessFlow,http://inova8.com/eastman/id/Vessel/V103,INVERSE,false]\r\n" + "]\r\n" + "", paths.toString());
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
Aggregations