Search in sources :

Example 31 with ResourceResults

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

the class Example6_Tests method example6_6.

/**
 * Example 6 6.
 */
@Test
@Order(6)
void example6_6() {
    try {
        Thing aPerson = source.getThing(":aPerson");
        ResourceResults bmis = aPerson.getFacts(":Observation@:BMIObservation[:hasDate [lt %1]]/:hasBMI", literal(LocalDate.parse("2021-08-03")));
        assertEquals("[ {s=http://inova8.com/intelligentgraph/example6/Measurement_1, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"21.453287197231838\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example6/Measurement_2, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"22.03856749311295\"^^<http://www.w3.org/2001/XMLSchema#double>};]", bmis.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 32 with ResourceResults

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

the class Remote_CRUD_Test method ig_1.

/**
 * Ig 1.
 */
@Test
@Order(1)
void ig_1() {
    try {
        source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
        Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph2>");
        source.prefix("<http://inova8.com/calc2graph/testGraph2/>");
        Thing myCountry = graph.getThing(":Country2");
        Thing Attribute = graph.getThing(":Attribute").addFact(RDFS.SUBCLASSOF, RDF.STATEMENT);
        Thing AttributeType = graph.getThing(":AttributeType");
        graph.getThing(":attributeOf").addFact(RDFS.SUB_PROPERTY_OF, RDF.SUBJECT).addFact(RDFS.DOMAIN, Attribute).addFact(RDFS.RANGE, RDFS.RESOURCE);
        graph.getThing(":attributeType").addFact(RDFS.SUB_PROPERTY_OF, RDF.PREDICATE).addFact(RDFS.DOMAIN, Attribute).addFact(RDFS.RANGE, AttributeType);
        graph.getThing(":attributeMeasurement").addFact(RDFS.SUB_PROPERTY_OF, RDF.OBJECT).addFact(RDFS.DOMAIN, Attribute).addFact(RDFS.RANGE, XSD.STRING);
        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);
        Boolean closed = source.closeGraph("<http://inova8.com/calc2graph/testGraph2>");
        assertEquals(true, closed);
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : 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 33 with ResourceResults

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

the class Remote_GettingStartedTests method test_10.

/**
 * Test 10.
 */
@Test
@Order(10)
void test_10() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create("http://localhost:8080/rdf4j-server", "tutorial");
        source.prefix("<http://inova8.com/calc2graph/testGraph1/>");
        Graph graph1 = source.openGraph("<http://inova8.com/calc2graph/testGraph1>");
        Thing myCountry = graph1.getThing(":Country1");
        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.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
        source.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
    } 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 34 with ResourceResults

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

the class Remote_GettingStartedTests method test_50.

/**
 * Test 50.
 */
@Test
@Order(50)
void test_50() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create("http://localhost:8080/rdf4j-server", "tutorial");
        source.prefix("<http://inova8.com/calc2graph/testGraph5/>");
        Graph graph = source.openGraph("<http://inova8.com/calc2graph/testGraph5>");
        Thing Attribute = graph.getThing(":Attribute").addFact(RDFS.SUBCLASSOF, RDF.STATEMENT);
        Thing AttributeType = graph.getThing(":AttributeType");
        graph.getThing(":attributeOf").addFact(RDFS.SUB_PROPERTY_OF, RDF.SUBJECT).addFact(RDFS.DOMAIN, Attribute).addFact(RDFS.RANGE, RDFS.RESOURCE);
        graph.getThing(":attributeType").addFact(RDFS.SUB_PROPERTY_OF, RDF.PREDICATE).addFact(RDFS.DOMAIN, Attribute).addFact(RDFS.RANGE, AttributeType);
        graph.getThing(":attributeMeasurement").addFact(RDFS.SUB_PROPERTY_OF, RDF.OBJECT).addFact(RDFS.DOMAIN, Attribute).addFact(RDFS.RANGE, XSD.STRING);
        Thing myCountry = graph.getThing(":Country1");
        String performanceCalculation = "2*3";
        myCountry.addFact(":Attribute@:salesPerformance", performanceCalculation, SCRIPT.GROOVY);
        ResourceResults results = myCountry.getFacts(":Attribute@:salesPerformance");
        // if(results.hasNext()) {
        for (Resource result : results) {
            assertEquals("6", result.getValue().stringValue());
            break;
        }
        // source.removeGraph("<http://inova8.com/calc2graph/testGraph>");
        source.closeGraph("<http://inova8.com/calc2graph/testGraph5>");
    // }else {
    // fail();
    // }
    } 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 35 with ResourceResults

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

the class Remote_PathQL_GetFactTests method test_3.

/**
 * Test 3.
 */
@Test
@Order(3)
void test_3() {
    try {
        Thing $this = Thing.create(source, iri("http://inova8.com/calc2graph/id/Unit1"), null);
        Double fact = 0.0;
        for (Resource batterylimit : $this.getFacts(":hasProductBatteryLimit")) {
            @SuppressWarnings("unused") Resource factValue = batterylimit.getFact(":massFlow");
            fact += batterylimit.getFact(":massFlow").doubleValue();
        }
        ResourceResults batterylimits = $this.getFacts(":hasProductBatteryLimit");
        Resource batterylimit;
        while (batterylimits.hasNext()) {
            batterylimit = batterylimits.next();
            fact -= batterylimit.getFact(":massFlow").doubleValue();
        }
        ;
        assertEquals(0.0, fact);
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    }
}
Also used : 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

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