Search in sources :

Example 16 with PathPatternException

use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_MultiGraphAddGetFact_Tests method addGraph3.

/**
 * Adds the graph 3.
 *
 * @return the thing
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@SuppressWarnings("unused")
private Thing addGraph3() throws RecognitionException, PathPatternException {
    source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
    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");
    return myCountry;
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing)

Example 17 with PathPatternException

use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_SPARQL_Tests method addGraph3.

/**
 * Adds the graph 3.
 *
 * @return the thing
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
private Thing addGraph3() throws RecognitionException, PathPatternException {
    source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
    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");
    return myCountry;
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing)

Example 18 with PathPatternException

use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_SPARQL_Tests method addGraph2.

/**
 * Adds the graph 2.
 *
 * @return the thing
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
// }
private Thing addGraph2() throws RecognitionException, PathPatternException {
    source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
    Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph2>");
    Thing myCountry = graph.getThing(":Country");
    myCountry.addFact(":sales", "1");
    myCountry.addFact(":sales", "2");
    myCountry.addFact(":sales", "3");
    myCountry.addFact(":sales", "4");
    myCountry.addFact(":sales", "5");
    // myCountry.addFact(":sales", "60");
    return myCountry;
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing)

Example 19 with PathPatternException

use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_Sparql_IntelligentGraphTests method addGraph2.

/**
 * Adds the graph 2.
 *
 * @return the thing
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
private Thing addGraph2() throws RecognitionException, PathPatternException {
    source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
    source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
    source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
    source.removeGraph("<http://inova8.com/calc2graph/testGraph4>");
    Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph2>");
    Thing myCountry = graph.getThing(":Country2");
    myCountry.addFact(":sales", "1");
    myCountry.addFact(":sales", "2");
    myCountry.addFact(":sales", "3");
    myCountry.addFact(":sales", "4");
    myCountry.addFact(":sales", "5");
    myCountry.addFact(":sales", "60");
    String averageSalesScript = "totalSales=0; count=0;for(sales in _this.getFacts(\"<http://inova8.com/calc2graph/def/sales>\")){totalSales +=  sales.doubleValue();count++}; return totalSales/count;";
    myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
    return myCountry;
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing)

Example 20 with PathPatternException

use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_Sparql_IntelligentGraphTests 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/testGraph1>");
    source.removeGraph("<http://inova8.com/calc2graph/testGraph2>");
    source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
    source.removeGraph("<http://inova8.com/calc2graph/testGraph4>");
    Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph4>");
    Thing myCountry = graph.getThing(":Country4");
    myCountry.addFact(":sales", "100");
    myCountry.addFact(":sales", "200");
    myCountry.addFact(":sales", "300");
    myCountry.addFact(":sales", "400");
    myCountry.addFact(":sales", "500");
    String averageSalesScript = "return _this.getFacts(\":sales\").average();";
    myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
    return myCountry;
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing)

Aggregations

PathElement (com.inova8.pathql.element.PathElement)25 Order (org.junit.jupiter.api.Order)17 Test (org.junit.jupiter.api.Test)17 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)17 Thing (com.inova8.intelligentgraph.model.Thing)15 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)9 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)6 PathBinding (com.inova8.intelligentgraph.path.PathBinding)5 PredicateElement (com.inova8.pathql.element.PredicateElement)4 PathPatternLexer (com.inova8.pathql.pathPattern.PathPatternLexer)3 PathPatternParser (com.inova8.pathql.pathPattern.PathPatternParser)3 PathPatternVisitor (com.inova8.pathql.processor.PathPatternVisitor)3 CharStream (org.antlr.v4.runtime.CharStream)3 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)3 IRI (org.eclipse.rdf4j.model.IRI)3 ReificationType (com.inova8.pathql.context.ReificationType)2 PathPatternException (com.inova8.pathql.processor.PathPatternException)2 IriRefValueElement (com.inova8.pathql.element.IriRefValueElement)1 IriRefContext (com.inova8.pathql.pathPattern.PathPatternParser.IriRefContext)1 PathEltOrInverseContext (com.inova8.pathql.pathPattern.PathPatternParser.PathEltOrInverseContext)1