use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternSPARQLTests method test_5.
/**
* Test 5.
*
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
@Test
@Order(5)
void test_5() throws RecognitionException, PathPatternException {
PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn[ rdfs:label \"eastman3d\" ]#/:lat");
assertEquals("?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?n0\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://default/appearsOn>\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?n1\r\n" + "?n1 <http://rdfs/label> 'eastman3d' .\r\n" + "?r1 <http://default/lat> ?n2 .\r\n" + "", element.toSPARQL());
}
use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternSPARQLTests method test_4.
/**
* Test 4.
*
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
@Test
@Order(4)
void test_4() throws RecognitionException, PathPatternException {
PathElement element = PathParser.parsePathPattern(repositoryContext, ":volumeFlow [ gt \"35\" ]");
assertEquals("?n0 <http://default/volumeFlow> ?n1 .\r\n" + "FILTER(?n1 gt '35')\r\n" + "", element.toSPARQL());
}
use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternSPARQLTests method test_05.
/**
* Test 05.
*
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
@Test
@Order(0)
void test_05() throws RecognitionException, PathPatternException {
PathElement element = PathParser.parsePathPattern(repositoryContext, ":parent1/:parent2/:parent3");
assertEquals("?n0 <http://default/parent1> ?n1 .\r\n" + "?n1 <http://default/parent2> ?n2 .\r\n" + "?n2 <http://default/parent3> ?n3 .\r\n" + "", element.toSPARQL());
}
use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathParser method parseIriRef.
/**
* Parses the iri ref.
*
* @param repositoryContext the repository context
* @param uriPattern the uri pattern
* @return the iri ref value element
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
public static IriRefValueElement parseIriRef(RepositoryContext repositoryContext, String uriPattern) throws RecognitionException, PathPatternException {
try {
pathPatternVisitor = new PathPatternVisitor(repositoryContext);
CharStream input = CharStreams.fromString(uriPattern);
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
IriRefContext pathPatternTree = parser.iriRef();
PathElement iriRefValueElement = pathPatternVisitor.visit(pathPatternTree);
return (IriRefValueElement) iriRefValueElement;
} catch (Exception qe) {
throw new PathPatternException(qe.getMessage(), null);
}
}
use of com.inova8.pathql.processor.PathPatternException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathParser method parsePredicate.
/**
* Parses the predicate.
*
* @param repositoryContext the repository context
* @param uriPattern the uri pattern
* @return the predicate element
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
public static PredicateElement parsePredicate(RepositoryContext repositoryContext, String uriPattern) throws RecognitionException, PathPatternException {
pathPatternVisitor = new PathPatternVisitor(repositoryContext);
CharStream input = CharStreams.fromString(uriPattern);
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
PathEltOrInverseContext pathPatternTree = parser.pathEltOrInverse();
PathElement iriRefValueElement = pathPatternVisitor.visit(pathPatternTree);
return (PredicateElement) iriRefValueElement;
}
Aggregations