use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_MultiGraphAddGetFact_Tests method test_10.
/**
* Test 10.
*/
@Test
@Order(10)
void test_10() {
try {
Graph graph1 = source.openGraph("<http://inova8.com/calc2graph/testGraph1>");
Thing myCountry = graph1.getThing(":Country");
String performanceCalculation = "2*3";
myCountry.addFact(":salesPerformance", performanceCalculation, SCRIPT.GROOVY);
ResourceResults results = myCountry.getFacts(":salesPerformance");
for (Resource result : results) {
assertEquals("6", result.getValue().stringValue());
}
source.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
} catch (Exception e) {
assertEquals("", e.getMessage());
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_MultiGraphAddGetFact_Tests method test_20.
/**
* Test 20.
*/
@Test
@Order(20)
void test_20() {
try {
// Thing myCountry = addGraph2();
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph2>");
Thing myCountry = graph.getThing(":Country");
myCountry.addFact(":sales", "1");
myCountry.addFact(":sales", "2");
myCountry.addFact(":sales", "3");
myCountry.addFact(":sales", "4");
myCountry.addFact(":sales", "5");
String averageSalesScript = "totalSales=0; count=0;for(sales in _this.getFacts(\"<http://inova8.com/calc2graph/def/sales>\")){totalSales += sales.doubleValue();count++}; return totalSales/count;";
myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
CustomQueryOptions customQueryOptions = new CustomQueryOptions();
customQueryOptions.add("time", 42);
customQueryOptions.add("name", "Peter");
Double averageCountrySales = myCountry.getFact(":averageSales", customQueryOptions).doubleValue();
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
assertEquals(3.0, averageCountrySales);
} catch (Exception e) {
assertEquals("", e.getMessage());
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_SPARQL_Tests method addGraph3.
/**
* Adds the graph 3.
*
* @return the thing
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
private Thing addGraph3() throws RecognitionException, PathPatternException {
source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph3>");
Thing myCountry = graph.getThing(":Country");
myCountry.addFact(":sales", "10");
myCountry.addFact(":sales", "20");
myCountry.addFact(":sales", "30");
myCountry.addFact(":sales", "40");
myCountry.addFact(":sales", "50");
return myCountry;
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_SPARQL_Tests method ig_70.
/**
* Ig 70.
*/
@Test
@Order(70)
void ig_70() {
try {
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph3>");
Thing myCountry = graph.getThing(":Country1");
myCountry.addFact(":sales", "100");
myCountry.addFact(":sales", "200");
myCountry.addFact(":sales", "300");
myCountry.addFact(":sales", "400");
myCountry.addFact(":sales", "500");
String totalSalesScript = "return _this.getFacts(\"<http://inova8.com/calc2graph/def/sales>\").total();";
myCountry.addFact(":totalSales", totalSalesScript, SCRIPT.GROOVY);
String queryString1 = "PREFIX : <http://inova8.com/calc2graph/def/> select ?s ?o " + "FROM <http://inova8.com/calc2graph/testGraph3>\r\n" + "FROM <http://default>\n" + "FROM <file://calc2graph.data.ttl>\r\n" + "FROM <file://calc2graph.def.ttl>\r\n" + "{\r\n" + " ?s :totalSales ?o} limit 10";
String result = Query.runSPARQL(conn, queryString1);
assertEquals("s=http://inova8.com/calc2graph/def/Country1;o=1500.0;\r\n" + "", result);
source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
result = Query.runSPARQL(conn, queryString1);
assertEquals("", result);
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_SPARQL_Tests method addGraph2.
/**
* Adds the graph 2.
*
* @return the thing
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
// }
private Thing addGraph2() throws RecognitionException, PathPatternException {
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph2>");
Thing myCountry = graph.getThing(":Country");
myCountry.addFact(":sales", "1");
myCountry.addFact(":sales", "2");
myCountry.addFact(":sales", "3");
myCountry.addFact(":sales", "4");
myCountry.addFact(":sales", "5");
// myCountry.addFact(":sales", "60");
return myCountry;
}
Aggregations