use of com.inova8.intelligentgraph.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_SPARQL_Tests method ig_60.
/**
* Ig 60.
*/
@Test
@Order(60)
void ig_60() {
try {
Thing myCountry = addGraph2();
String averageSalesScript = "return _this.getFacts(\":sales\").average();";
myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
String queryString1 = "PREFIX : <http://inova8.com/calc2graph/def/> select ?s ?o \n" + "FROM <http://inova8.com/calc2graph/testGraph2>\n" + "FROM <file://calc2graph.data.ttl>\n" + "FROM <file://calc2graph.def.ttl>\n" + "{\n" + " ?s :averageSales ?o } limit 10";
String result = Query.runSPARQL(conn, queryString1);
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
assertEquals("s=http://inova8.com/calc2graph/def/Country;o=3.0;\r\n" + "", result);
} catch (Exception e) {
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_SPARQL_Tests method ig_65.
/**
* Ig 65.
*/
@Test
@Order(65)
void ig_65() {
try {
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
source.removeGraph("<http://inova8.com/calc2graph/testGraph4>");
Thing myCountry = addGraph2();
String averageSalesScript = "return _this.getFacts(\":sales\").average();";
myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
String queryString1 = "PREFIX : <http://inova8.com/calc2graph/def/> select ?s ?o \n" + "FROM <http://inova8.com/calc2graph/testGraph2>\n" + // + "FROM <file://calc2graph.def.ttl>\n"
"{\n" + "VALUES(?s){(<http://inova8.com/calc2graph/def/Country>)} " + " ?s :averageSales ?o } limit 10";
String result = Query.runSPARQL(conn, queryString1);
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
assertEquals("s=http://inova8.com/calc2graph/def/Country;o=3.0;\r\n" + "", result);
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
}
try {
Thing myCountry = addGraph3();
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/Country;o=150.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.model.Thing 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.model.Thing 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.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_SPARQL_Tests method ig_90.
/**
* Ig 90.
*/
@Test
@Order(90)
void ig_90() {
try {
Thing myCountry = addGraph4();
String averageSalesScript = "return _this.getFacts(\"<http://inova8.com/calc2graph/def/sales>\").average();";
myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
String queryString1 = "PREFIX : <http://inova8.com/calc2graph/def/> CONSTRUCT{\r\n" + " ?s :averageSales ?o.\r\n" + "} " + "FROM <http://inova8.com/calc2graph/testGraph4>\r\n" + "FROM <http://default>\n" + // + "FROM <file://calc2graph.def.ttl>\r\n"
"{\r\n" + " ?s :averageSales ?o } limit 10";
String result = Query.runCONSTRUCT(conn, queryString1);
assertEquals("(http://inova8.com/calc2graph/def/Country, http://inova8.com/calc2graph/def/averageSales, \"300.0\"^^<http://www.w3.org/2001/XMLSchema#double>)\n", result);
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
Aggregations