Search in sources :

Example 11 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults 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 12 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults 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());
    }
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) PathPatternException(com.inova8.pathql.processor.PathPatternException) RecognitionException(org.antlr.v4.runtime.RecognitionException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 13 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_Eastman3D_GetPath_Tests method test_0.

/**
 * Test 0.
 */
@Test
@Order(0)
void test_0() {
    try {
        Thing _this = source.getThing("eastman.BatteryLimit:Stripper.Bottoms");
        // 
        ResourceResults facts = _this.getFacts("^plant:Transference@plant.TransferenceKind:ProcessFlow{1,3}");
        assertEquals("[ {s=http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Valve/U8}; {s=http://inova8.com/eastman/id/Valve/U8, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Pump/G103}; {s=http://inova8.com/eastman/id/Pump/G103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Vessel/V103};]", facts.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : 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 ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_Eastman3D_GetPath_Tests method test_5.

/**
 * Test 5.
 */
@Test
@Order(5)
void test_5() {
    try {
        Thing _this = source.getThing("eastman.Signal:XMEAS17");
        // 
        ResourceResults facts = _this.getFacts("^plant:attribute.providedBy/plant:attribute.of.PlantItem/^plant:Transference@plant.TransferenceKind:ProcessFlow{1,6}/^plant:attribute.of.PlantItem/plant:attribute.providedBy");
        assertEquals("[ {s=http://inova8.com/eastman/id/Attribute/U1.valvePosition.XMV8, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMV8}; {s=http://inova8.com/eastman/id/Attribute/V103.level.XMEAS15, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS15}; {s=http://inova8.com/eastman/id/Attribute/V103.temperature.XMEAS18, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS18}; {s=http://inova8.com/eastman/id/Attribute/Stripper.Condensate.volumeFlow.XMEAS14, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS14}; {s=http://inova8.com/eastman/id/Attribute/Stripper.Feed.volumeFlow.XMEAS4, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS4}; {s=http://inova8.com/eastman/id/Attribute/V103.level.XMEAS15, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS15}; {s=http://inova8.com/eastman/id/Attribute/V103.temperature.XMEAS18, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS18}; {s=http://inova8.com/eastman/id/Attribute/Stripper.Condensate.volumeFlow.XMEAS14, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS14}; {s=http://inova8.com/eastman/id/Attribute/Stripper.Feed.volumeFlow.XMEAS4, p=http://inova8.com/plant/def/attribute.providedBy, o=http://inova8.com/eastman/id/Signal/XMEAS4};]", facts.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : 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 ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_Eastman3D_GetPath_Tests method test_4.

/**
 * Test 4.
 */
@Test
@Order(4)
void test_4() {
    try {
        Thing _this = source.getThing("eastman.Signal:XMEAS17");
        // 
        ResourceResults facts = _this.getFacts("^plant:attribute.providedBy/plant:attribute.of.PlantItem/^plant:Transference@plant.TransferenceKind:ProcessFlow{1,6}");
        assertEquals("[ {s=http://inova8.com/eastman/id/BatteryLimit/Stripper.Bottoms, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Valve/U8}; {s=http://inova8.com/eastman/id/Valve/U8, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Pump/G103}; {s=http://inova8.com/eastman/id/Pump/G103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Vessel/V103}; {s=http://inova8.com/eastman/id/Vessel/V103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Boiler/B103}; {s=http://inova8.com/eastman/id/Vessel/V103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/BatteryLimit/Stripper.Condensate}; {s=http://inova8.com/eastman/id/Vessel/V103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/BatteryLimit/Stripper.Feed}; {s=http://inova8.com/eastman/id/Boiler/B103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Vessel/V103}; {s=http://inova8.com/eastman/id/Vessel/V103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/Boiler/B103}; {s=http://inova8.com/eastman/id/Vessel/V103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/BatteryLimit/Stripper.Condensate}; {s=http://inova8.com/eastman/id/Vessel/V103, p=^http://inova8.com/plant/def/Transference@http://inova8.com/plant/def/TransferenceKind/ProcessFlow, o=http://inova8.com/eastman/id/BatteryLimit/Stripper.Feed};]", facts.toString());
    // assertEquals("[http://inova8.com/eastman/id/Valve/U8;http://inova8.com/eastman/id/Pump/G103;http://inova8.com/eastman/id/Vessel/V103;http://inova8.com/eastman/id/Boiler/B103;http://inova8.com/eastman/id/BatteryLimit/Stripper.Condensate;http://inova8.com/eastman/id/BatteryLimit/Stripper.Feed;http://inova8.com/eastman/id/Vessel/V103;http://inova8.com/eastman/id/Boiler/B103;http://inova8.com/eastman/id/BatteryLimit/Stripper.Condensate;http://inova8.com/eastman/id/BatteryLimit/Stripper.Feed;]", facts.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : 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

ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)46 Order (org.junit.jupiter.api.Order)42 Test (org.junit.jupiter.api.Test)42 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)42 Thing (com.inova8.intelligentgraph.model.Thing)33 Resource (com.inova8.intelligentgraph.model.Resource)23 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)12 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)7 ArrayList (java.util.ArrayList)7 NullValueReturnedException (com.inova8.intelligentgraph.exceptions.NullValueReturnedException)4 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)3 Path (com.inova8.intelligentgraph.path.Path)3 PathResults (com.inova8.intelligentgraph.results.PathResults)3 Trace (com.inova8.intelligentgraph.evaluator.Trace)2 ResourceStatementResults (com.inova8.intelligentgraph.results.ResourceStatementResults)2 PathPatternException (com.inova8.pathql.processor.PathPatternException)2 RecognitionException (org.antlr.v4.runtime.RecognitionException)2 IRI (org.eclipse.rdf4j.model.IRI)2 Statement (org.eclipse.rdf4j.model.Statement)2 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)2