Search in sources :

Example 41 with IntelligentGraphRepository

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

the class Thing method create.

/**
 * Creates the.
 *
 * @param source the source
 * @param graphIri the graph iri
 * @param superValue the super value
 * @param evaluationContext the evaluation context
 * @return the thing
 */
@SuppressWarnings("deprecation")
public static Thing create(IntelligentGraphRepository source, IRI graphIri, org.eclipse.rdf4j.model.Value superValue, EvaluationContext evaluationContext) {
    Thing thing;
    // graphIri.stringValue()+"~"+ superValue.stringValue();
    String graphThingKey = superValue.stringValue();
    if (superValue != null && source != null && source.getThings().containsKey(graphThingKey)) {
        thing = source.getThings().get(graphThingKey);
        thing.setSource(source);
        if (evaluationContext != null) {
            // if(thing.evaluationContext.getPrefixes()==null || thing.evaluationContext.getPrefixes().isEmpty())thing.evaluationContext.setPrefixes(evaluationContext.getPrefixes());
            if (evaluationContext.getCustomQueryOptions() != null && !evaluationContext.getCustomQueryOptions().isEmpty())
                thing.evaluationContext.setCustomQueryOptions(evaluationContext.getCustomQueryOptions());
            if (evaluationContext.getTracer() != null && evaluationContext.getTracer().isTracing())
                thing.evaluationContext.setTracer(evaluationContext.getTracer());
            if (evaluationContext.getDataset() != null)
                thing.evaluationContext.setDataset(evaluationContext.getDataset());
            thing.evaluationContext.setContexts(evaluationContext.getContexts());
        }
        // Overwrite the graphName if not null
        if (graphIri != null)
            thing.graphName = graphIri;
        return thing;
    } else {
        thing = new Thing(source, superValue, evaluationContext);
        if (source != null)
            source.getThings().put(graphThingKey, thing);
        if (graphIri == null)
            graphIri = Graph.DEFAULTGRAPH;
        thing.graphName = graphIri;
    }
    if (evaluationContext != null)
        thing.evaluationContext = evaluationContext;
    else if (thing.evaluationContext == null)
        thing.evaluationContext = new EvaluationContext();
    return thing;
}
Also used : EvaluationContext(com.inova8.intelligentgraph.evaluator.EvaluationContext)

Example 42 with IntelligentGraphRepository

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

the class Local_GetTraceFact_Tests method test_3.

/**
 * Test 3.
 */
@Test
@Order(3)
void test_3() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Unit1"), null);
        source.clearCache();
        Trace trace = _this.traceFact(":massThroughput");
        Query.assertEqualsWOSpaces(// assertEquals
        "<olstyle='list-style-type:none;'><li>Gettingfacts':massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]</li></li><olstyle='list-style-type:none;'><li>Evaluatingpredicate<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>varmassThroughput=0.0;<br>for(batterylimitin_this.getFacts(&quot;:hasProductBatteryLimit&quot;)){<br>&nbsp;&nbsp;&nbsp;massThroughput+=batterylimit.getFact(&quot;:massFlow&quot;).doubleValue()<br>};<br>massThroughput;</code></pre></div></li><olstyle='list-style-type:none;'><li>Gettingfacts':hasProductBatteryLimit'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/hasProductBatteryLimit'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=http://inova8.com/calc2graph/id/BatteryLimit2</li></li><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Redirectingevaluationofpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</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/BatteryLimit2'target='_blank'>BatteryLimit2</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/BatteryLimit2'target='_blank'>BatteryLimit2</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/BatteryLimit2'target='_blank'>BatteryLimit2</a>,byinvoking<b>javascript</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>40;</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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842</li></li><li>Returnedfact':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p><li>Nextfact'http://inova8.com/calc2graph/def/hasProductBatteryLimit'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=http://inova8.com/calc2graph/id/BatteryLimit3</li></li><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a></li></li><li>Redirectingevaluationofpredicate<ahref='http://inova8.com/calc2graph/def/massFlow'target='_blank'>massFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</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/BatteryLimit3'target='_blank'>BatteryLimit3</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/BatteryLimit3'target='_blank'>BatteryLimit3</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/BatteryLimit3'target='_blank'>BatteryLimit3</a>,byinvoking<b>groovy</b>script</li></li><li><divstyle='border:1pxsolidblack;'><pre><code>20;</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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=20^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=.5</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=.5^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<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/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0</li></li><li>Returnedfact':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit3'target='_blank'>BatteryLimit3</a>=10.0^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol><li>Evaluated<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li></ol><li>Calculated<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
        trace = _this.traceFact(":massThroughput");
        Query.assertEqualsWOSpaces(// assertEquals
        "<olstyle='list-style-type:none;'><li>Gettingfacts':massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a></li></li><li>...withincontexts:[file://src/test/resources/calc2graph.def.ttl,file://src/test/resources/calc2graph.data.ttl]</li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/massThroughput'target='_blank'>massThroughput</a>of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><li>Returnedfact'http://inova8.com/calc2graph/def/massThroughput'of<ahref='http://inova8.com/calc2graph/id/Unit1'target='_blank'>Unit1</a>=37.99999952316284^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
        source.clearCache();
    } 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)

Example 43 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository 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());
    }
}
Also used : IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) 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 44 with IntelligentGraphRepository

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

the class Local_GetTraceFact_Tests method test_1.

/**
 * Test 1.
 */
@Test
@Order(1)
void test_1() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit2"));
        @SuppressWarnings("unused") Resource result1 = _this.getFact(":volumeFlow");
        Trace trace = _this.traceFact(":massFlow");
        _this = source.getThing(iri("http://inova8.com/calc2graph/id/Unit1"));
        Resource result2 = _this.getFact(":massThroughput");
        // assertEquals("40", result1.stringValue());
        Query.assertEqualsWOSpaces(// assertEquals
        "<olstyle='list-style-type:none;'><li>Gettingfacts':massFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</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/BatteryLimit2'target='_blank'>BatteryLimit2</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/BatteryLimit2'target='_blank'>BatteryLimit2</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/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Retrievedcachedvalue<ahref='http://inova8.com/calc2graph/def/volumeFlow'target='_blank'>volumeFlow</a>of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40</li></li><li>Returnedfact':volumeFlow'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=40^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a></li></li><li>Nextfact'http://inova8.com/calc2graph/def/density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7</li></li><li>Returnedfact':Attribute@:density'of<ahref='http://inova8.com/calc2graph/id/BatteryLimit2'target='_blank'>BatteryLimit2</a>=.7^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<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/BatteryLimit2'target='_blank'>BatteryLimit2</a>=27.999999523162842^^<ahref='http://www.w3.org/2001/XMLSchema#double'target='_blank'>double</a></li></li><p></ol>", trace.asHTML());
        assertEquals("37.99999952316284", result2.stringValue());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Trace(com.inova8.intelligentgraph.evaluator.Trace) IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 45 with IntelligentGraphRepository

use of com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository 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();
    }
}
Also used : 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)

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