use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_MultiGraphAddGetFact_Tests method test_30.
/**
* Test 30.
*/
@Test
@Order(30)
void test_30() {
try {
// Thing myCountry = addGraph3();
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");
String totalSalesScript = "return _this.getFacts(\":sales\").total();";
myCountry.addFact(":totalSales", totalSalesScript, SCRIPT.GROOVY);
Double totalCountrySales = myCountry.getFact(":totalSales").doubleValue();
assertEquals(150.0, totalCountrySales);
myCountry.deleteFacts(":sales");
// source.closeGraph("<http://inova8.com/calc2graph/testGraph3>");
source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
} 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 addGraph4.
/**
* Adds the graph 4.
*
* @return the thing
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
private Thing addGraph4() throws RecognitionException, PathPatternException {
source.removeGraph("<http://inova8.com/calc2graph/testGraph4>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph4>");
Thing myCountry = graph.getThing(":Country");
myCountry.addFact(":sales", "100");
myCountry.addFact(":sales", "200");
myCountry.addFact(":sales", "300");
myCountry.addFact(":sales", "400");
myCountry.addFact(":sales", "500");
return myCountry;
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_AddGetDeleteFact_Test method ig_0.
/**
* Ig 0.
*/
@Test
@Order(0)
void ig_0() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph1>");
Thing myCountry = graph.getThing(":Country1");
myCountry.addFact(":sales", "1");
myCountry.addFact(":sales", "2");
myCountry.addFact(":sales", "3");
myCountry.addFact(":sales", "4");
ResourceResults facts = myCountry.getFacts(":sales[ge '2';lt '4']");
Integer factsinrange = facts.count();
assertEquals(2, factsinrange);
// myCountry = graph.getThing(":Country1");////////////////////////////////////////////////////
myCountry.deleteFacts(":sales[eq '3']");
factsinrange = myCountry.getFacts(":sales[ge '2';lt '4']").count();
assertEquals(1, factsinrange);
// Boolean closed =source.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
// assertEquals(true, closed);
} catch (Exception e) {
assertEquals("", e.getMessage());
}
}
use of com.inova8.intelligentgraph.intelligentGraphRepository.Graph in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetContextFact_Tests method test_1.
/**
* Test 1.
*/
@Test
@Order(1)
void test_1() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
// source.prefix("<http://inova8.com/calc2graph/def/>");
// source.prefix("rdfs", "<http://www.w3.org/2000/01/rdf-schema#>");
source.removeGraph("<http://inova8.com/calc2graph/contextGraph>");
// source.prefix("xsd", "<http://www.w3.org/2001/XMLSchema#>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/contextGraph>");
Thing myCountry = graph.getThing(":myCountry");
myCountry.addFact(":myOption", "_customQueryOptions.get(\"time\").integerValue() ;", SCRIPT.GROOVY);
CustomQueryOptions customQueryOptions1 = new CustomQueryOptions();
customQueryOptions1.add("time", 42);
customQueryOptions1.add("name", "Peter");
Thing myCountry1 = graph.getThing(":myCountry");
Resource result;
result = myCountry1.getFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions1);
assertEquals("42", result.stringValue());
CustomQueryOptions customQueryOptions2 = new CustomQueryOptions();
customQueryOptions2.add("time", 43);
result = myCountry1.getFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions2);
assertEquals("43", result.stringValue());
CustomQueryOptions customQueryOptions3 = new CustomQueryOptions();
customQueryOptions3.add("time", 2019);
result = myCountry.getFact(":myOption&time='2019'^^xsd:int", customQueryOptions3);
assertEquals("2019", result.stringValue());
ResourceResults results = myCountry.getFacts("<http://inova8.com/calc2graph/def/myOption>&time='2020'^^xsd:int");
for (Resource result1 : results) {
assertEquals("2020", result1.stringValue());
}
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
Aggregations