Search in sources :

Example 61 with Graph

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());
    }
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing) 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 62 with Graph

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;
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing)

Example 63 with Graph

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());
    }
}
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 64 with Graph

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();
    }
}
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

Thing (com.inova8.intelligentgraph.model.Thing)53 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)45 Order (org.junit.jupiter.api.Order)44 Test (org.junit.jupiter.api.Test)44 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)44 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)22 Resource (com.inova8.intelligentgraph.model.Resource)22 ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)14 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)13 PathPatternException (com.inova8.pathql.processor.PathPatternException)12 RecognitionException (org.antlr.v4.runtime.RecognitionException)12 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)8 Repository (org.eclipse.rdf4j.repository.Repository)8 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)6 NullValueReturnedException (com.inova8.intelligentgraph.exceptions.NullValueReturnedException)5 ServerException (com.inova8.intelligentgraph.exceptions.ServerException)5 ScriptException (javax.script.ScriptException)5 IRI (org.eclipse.rdf4j.model.IRI)5 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)5 Trace (com.inova8.intelligentgraph.evaluator.Trace)4