Search in sources :

Example 11 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.

the class IntelligentGraphConnection method getResultsIterator.

/**
 * Gets the results iterator.
 *
 * @param source the source
 * @param thing the thing
 * @param pathElement the path element
 * @param pathTupleExpr the path tuple expr
 * @param contexts the contexts
 * @return the results iterator
 * @throws IllegalArgumentException the illegal argument exception
 * @throws QueryEvaluationException the query evaluation exception
 */
CloseableIteration<BindingSet, QueryEvaluationException> getResultsIterator(IntelligentGraphRepository source, Thing thing, PathElement pathElement, PathTupleExpr pathTupleExpr, Resource... contexts) throws IllegalArgumentException, QueryEvaluationException {
    TupleExpr tupleExpr = pathTupleExpr.getTupleExpr();
    SimpleDataset dataset = prepareDataset(pathElement, source, contexts);
    BindingSet bindings = new QueryBindingSet();
    EvaluationStrategy evaluationStrategy = new StrictEvaluationStrategy(source.getTripleSource(), dataset, null);
    CloseableIteration<BindingSet, QueryEvaluationException> resultsIterator = evaluationStrategy.evaluate(tupleExpr, bindings);
    return resultsIterator;
}
Also used : QueryBindingSet(org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet) BindingSet(org.eclipse.rdf4j.query.BindingSet) EvaluationStrategy(org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategy) StrictEvaluationStrategy(org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategy) StrictEvaluationStrategy(org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategy) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) SimpleDataset(org.eclipse.rdf4j.query.impl.SimpleDataset) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) QueryBindingSet(org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet)

Example 12 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_GetContextFact_Tests method test_2.

/**
 * Test 2.
 */
@Test
@Order(2)
void test_2() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
        source.removeGraph("<http://inova8.com/calc2graph/contextGraph>");
        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");
        Trace result = myCountry1.traceFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions1);
        Query.assertEqualsWOSpaces("<olstyle='list-style-type:none;'><li>Gettingfacts'&lt;http://inova8.com/calc2graph/def/myOption&gt;'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a></li></li><li>...usingoptions:[name=&quot;Peter&quot;&amp;time=&quot;42&quot;^^&lt;http://www.w3.org/2001/XMLSchema#int&gt;]</li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,http://inova8.com/calc2graph/contextGraph,file://src/test/resources/calc2graph.data.ttl]</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>_customQueryOptions.get(&quot;time&quot;).integerValue();</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/myOption'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p></ol>", result.asHTML());
        CustomQueryOptions customQueryOptions2 = new CustomQueryOptions();
        customQueryOptions2.add("time", 43);
        result = myCountry1.traceFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions2);
        Query.assertEqualsWOSpaces("<olstyle='list-style-type:none;'><li>Gettingfacts'&lt;http://inova8.com/calc2graph/def/myOption&gt;'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a></li></li><li>...usingoptions:[time=&quot;43&quot;^^&lt;http://www.w3.org/2001/XMLSchema#int&gt;]</li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,http://inova8.com/calc2graph/contextGraph,file://src/test/resources/calc2graph.data.ttl]</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>_customQueryOptions.get(&quot;time&quot;).integerValue();</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=43^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=43^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=43^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/myOption'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=43^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p></ol>", result.asHTML());
        result = myCountry1.traceFact("<http://inova8.com/calc2graph/def/myOption>&time='2019'^^xsd:int");
        Query.assertEqualsWOSpaces("<olstyle='list-style-type:none;'><li>Gettingfacts'&lt;http://inova8.com/calc2graph/def/myOption&gt;&amp;time='2019'^^xsd:int'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,http://inova8.com/calc2graph/contextGraph,file://src/test/resources/calc2graph.data.ttl]</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>_customQueryOptions.get(&quot;time&quot;).integerValue();</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=2019^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=2019^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=2019^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/myOption'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=2019^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p></ol>", result.asHTML());
        ResourceResults results = myCountry1.getFacts("<http://inova8.com/calc2graph/def/myOption>&time='2020'^^xsd:int");
        for (Resource result1 : results) {
            Query.assertEqualsWOSpaces("2020", result1.stringValue());
        }
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Trace(com.inova8.intelligentgraph.evaluator.Trace) IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) CustomQueryOptions(com.inova8.intelligentgraph.context.CustomQueryOptions) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 13 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_AddGetDeleteFact_Test method ig_1.

/**
 * Ig 1.
 */
@Test
@Order(1)
void ig_1() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
        source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
        Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph2>");
        Thing myCountry = graph.getThing(":Country2");
        myCountry.addFact(":Attribute@:sales", "1");
        myCountry.addFact(":Attribute@:sales", "2");
        myCountry.addFact(":Attribute@:sales", "3");
        myCountry.addFact(":Attribute@:sales", "4");
        ResourceResults facts = myCountry.getFacts(":Attribute@:sales[ge '2';lt '4']");
        Integer factsinrange = facts.count();
        assertEquals(2, factsinrange);
        myCountry.deleteFacts(":Attribute@:sales[eq '3']");
        facts = myCountry.getFacts(":Attribute@:sales[ge '2';lt '4']");
        factsinrange = facts.count();
        assertEquals(1, factsinrange);
        // double totalSales = 0;
        // int count = 0;
        // for(Resource sales : myCountry.getFacts(":Attribute@:sales")){
        // totalSales +=  sales.doubleValue();
        // count++;
        // };
        // double averagesales= totalSales/count;
        String averageSalesScript = "totalSales=0; count=0;for(sales in _this.getFacts(\":Attribute@:sales\")){totalSales +=  sales.doubleValue();count++}; return totalSales/count;";
        myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
        Resource averageSales = myCountry.getFact(":averageSales");
        assertEquals(2.3333333333333335, averageSales.doubleValue());
        // Thing country3= myCountry.getThing(":Country3");
        Thing country3 = graph.getThing(":Country3");
        String averageSalesScript3 = "totalSales=0; count=0; myCountry=_this.getThing(\":Country2\"); for(sales in myCountry.getFacts(\":Attribute@:sales\")){totalSales +=  sales.doubleValue();count++}; return totalSales/count;";
        country3.addFact(":averageSales", averageSalesScript3, SCRIPT.GROOVY);
        Resource averageSales3 = myCountry.getFact(":averageSales");
        assertEquals(2.3333333333333335, averageSales3.doubleValue());
        Boolean closed = source.closeGraph("<http://inova8.com/calc2graph/testGraph2>");
        assertEquals(true, closed);
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 14 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_GetTraceFact_Tests method test_5.

/**
 * Test 5.
 */
@Test
@Order(5)
void test_5() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
        source.removeGraph("<http://inova8.com/calc2graph/contextGraph>");
        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");
        Trace result = myCountry1.traceFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions1);
        Query.assertEqualsWOSpaces(// assertEquals
        "<olstyle='list-style-type:none;'><li>Gettingfacts'&lt;http://inova8.com/calc2graph/def/myOption&gt;'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a></li></li><li>...usingoptions:[name=&quot;Peter&quot;&amp;time=&quot;42&quot;^^&lt;http://www.w3.org/2001/XMLSchema#int&gt;]</li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,http://inova8.com/calc2graph/contextGraph,file://src/test/resources/calc2graph.data.ttl]</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>_customQueryOptions.get(&quot;time&quot;).integerValue();</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/myOption'target='_blank'>myOption</a>of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/myOption'of<ahref='http://inova8.com/calc2graph/def/myCountry'target='_blank'>myCountry</a>=42^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p></ol>", result.asHTML());
        CustomQueryOptions customQueryOptions2 = new CustomQueryOptions();
        customQueryOptions2.add("time", 43);
        result = myCountry1.traceFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions2);
        Query.assertEqualsWOSpaces(// assertEquals
        "1.Gettingfacts'<http://inova8.com/calc2graph/def/myOption>'ofmyCountry<http://inova8.com/calc2graph/def/myCountry>2....usingoptions:[time=\"43\"^^<http://www.w3.org/2001/XMLSchema#int>]3....withincontexts:[file://src/test/resources/calc2graph.def.ttl,http://inova8.com/calc2graph/contextGraph,file://src/test/resources/calc2graph.data.ttl]1.EvaluatingpredicatemyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>,byinvokinggroovyscript2._customQueryOptions.get(\"time\").integerValue();3.EvaluatedmyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=43^^int<http://www.w3.org/2001/XMLSchema#int>4.CalculatedmyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=43^^int<http://www.w3.org/2001/XMLSchema#int>5.RetrievedcachedvaluemyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=43^^int<http://www.w3.org/2001/XMLSchema#int>6.Returnedfact'http://inova8.com/calc2graph/def/myOption'ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=43^^int<http://www.w3.org/2001/XMLSchema#int>", result.asText());
        result = myCountry1.traceFact("<http://inova8.com/calc2graph/def/myOption>&time='2019'^^xsd:int");
        Query.assertEqualsWOSpaces(// assertEquals
        "1.Gettingfacts'<http://inova8.com/calc2graph/def/myOption>&time='2019'^^xsd:int'ofmyCountry<http://inova8.com/calc2graph/def/myCountry>2....withincontexts:[file://src/test/resources/calc2graph.def.ttl,http://inova8.com/calc2graph/contextGraph,file://src/test/resources/calc2graph.data.ttl]1.EvaluatingpredicatemyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>,byinvokinggroovyscript2._customQueryOptions.get(\"time\").integerValue();3.EvaluatedmyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=2019^^int<http://www.w3.org/2001/XMLSchema#int>3.CalculatedmyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=2019^^int<http://www.w3.org/2001/XMLSchema#int>4.RetrievedcachedvaluemyOption<http://inova8.com/calc2graph/def/myOption>ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=2019^^int<http://www.w3.org/2001/XMLSchema#int>5.Returnedfact'http://inova8.com/calc2graph/def/myOption'ofmyCountry<http://inova8.com/calc2graph/def/myCountry>=2019^^int<http://www.w3.org/2001/XMLSchema#int>", result.asText());
        ResourceResults results = myCountry1.getFacts("<http://inova8.com/calc2graph/def/myOption>&time='2020'^^xsd:int");
        for (Resource result1 : results) {
            Query.assertEqualsWOSpaces("2020", result1.stringValue());
        }
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Trace(com.inova8.intelligentgraph.evaluator.Trace) IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) CustomQueryOptions(com.inova8.intelligentgraph.context.CustomQueryOptions) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 15 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_GetTraceFact_Tests method test_4.

/**
 * Test 4.
 */
@Test
@Order(4)
void test_4() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
        // Graph graph = source.addGraph("<file://src/test/resources/calc2graph.data.ttl>");
        // Thing _this =graph.getThing("<http://inova8.com/calc2graph/id/BatteryLimit1>");
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
        Trace trace = _this.traceFact(":massFlow");
        Query.assertEqualsWOSpaces(// assertEquals
        "<olstyle='list-style-type:none;'><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]</li></li><li>Redirectingevaluationofpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>,to<b>&lt;http://inova8.com/calc2graph/id/calculateMassFlow&gt;</b>script</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>varresult=_this.getFact(&quot;:volumeFlow&quot;).floatValue()*_this.getFact(&quot;:Attribute@:density&quot;).floatValue();&nbsp;<br>result;</code></pre></div></li><olstyle='list-style-type:none;'><li>Gettingfacts':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a></li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>,byinvoking<b>javascript</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>59;</code></pre></div></li><olstyle='list-style-type:none;'></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=59^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=59^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=59^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=59</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=59^^<ahref='http://www.w3.org/2001/XMLSchema#int'target='_blank'>int</a></li></li><p><li>Gettingfacts':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=.42</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=.42^^<ahref='http://www.w3.org/2001/XMLSchema#string'target='_blank'>string</a></li></li><p></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=24.77999922633171^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=24.77999922633171^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=24.77999922633171^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit1'target='_blank'>BatteryLimit1</a>=24.77999922633171^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
        // String renderedTrace = new net.htmlparser.jericho.Source(trace).getRenderer().setMaxLineLength(Integer.MAX_VALUE).setNewLine(null).toString();
        source.clearCache();
        Trace renderedTrace = _this.traceFact(":massFlow");
        Query.assertEqualsWOSpaces(// assertEquals
        "1.Gettingfacts':massFlow'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>2....withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]3.RedirectingevaluationofpredicatemassFlow<http://inova8.com/calc2graph/def/massFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>,to<http://inova8.com/calc2graph/id/calculateMassFlow>script1.EvaluatingpredicatemassFlow<http://inova8.com/calc2graph/def/massFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>,byinvokinggroovyscript2.varresult=_this.getFact(\":volumeFlow\").floatValue()*_this.getFact(\":Attribute@:density\").floatValue();result;1.Gettingfacts':volumeFlow'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>1.EvaluatingpredicatevolumeFlow<http://inova8.com/calc2graph/def/volumeFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>,byinvokingjavascriptscript2.59;3.EvaluatedvolumeFlow<http://inova8.com/calc2graph/def/volumeFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=59^^int<http://www.w3.org/2001/XMLSchema#int>2.CalculatedvolumeFlow<http://inova8.com/calc2graph/def/volumeFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=59^^int<http://www.w3.org/2001/XMLSchema#int>3.RetrievedcachedvaluevolumeFlow<http://inova8.com/calc2graph/def/volumeFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=59^^int<http://www.w3.org/2001/XMLSchema#int>4.Nextfact'http://inova8.com/calc2graph/def/volumeFlow'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=595.Returnedfact':volumeFlow'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=59^^int<http://www.w3.org/2001/XMLSchema#int>6.Gettingfacts':Attribute@:density'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>7.Nextfact'http://inova8.com/calc2graph/def/density'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=.428.Returnedfact':Attribute@:density'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=.42^^string<http://www.w3.org/2001/XMLSchema#string>3.EvaluatedmassFlow<http://inova8.com/calc2graph/def/massFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=24.77999922633171^^double<http://www.w3.org/2001/XMLSchema#double>4.CalculatedmassFlow<http://inova8.com/calc2graph/def/massFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=24.77999922633171^^double<http://www.w3.org/2001/XMLSchema#double>5.RetrievedcachedvaluemassFlow<http://inova8.com/calc2graph/def/massFlow>ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=24.77999922633171^^double<http://www.w3.org/2001/XMLSchema#double>6.Returnedfact'http://inova8.com/calc2graph/def/massFlow'ofBatteryLimit1<http://inova8.com/calc2graph/id/BatteryLimit1>=24.77999922633171^^double<http://www.w3.org/2001/XMLSchema#double>", renderedTrace.asText());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Trace(com.inova8.intelligentgraph.evaluator.Trace) IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)37 Thing (com.inova8.intelligentgraph.model.Thing)36 Order (org.junit.jupiter.api.Order)24 Test (org.junit.jupiter.api.Test)24 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)24 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)20 Resource (com.inova8.intelligentgraph.model.Resource)15 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)11 IRI (org.eclipse.rdf4j.model.IRI)9 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)9 Repository (org.eclipse.rdf4j.repository.Repository)8 EvaluationContext (com.inova8.intelligentgraph.evaluator.EvaluationContext)7 ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)7 Trace (com.inova8.intelligentgraph.evaluator.Trace)6 Value (org.eclipse.rdf4j.model.Value)5 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)5 ValueExprEvaluationException (org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException)5 PathElement (com.inova8.pathql.element.PathElement)4 SimpleLiteral (org.eclipse.rdf4j.model.impl.SimpleLiteral)4 BindingSet (org.eclipse.rdf4j.query.BindingSet)4