use of com.inova8.pathql.element.IriRefValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternVisitor method visitQueryOptions.
/**
* Visit query options.
*
* @param ctx the ctx
* @return the query options path element
*/
@Override
public QueryOptionsPathElement visitQueryOptions(QueryOptionsContext ctx) {
// queryOptions : ( queryOption )+;
// queryOption: KEY '=' literal ('^^' type )?;
// KEY : '&' [a-zA-Z]+ ;
CustomQueryOptions customQueryOptions = new CustomQueryOptions();
for (QueryOptionContext queryOption : ctx.queryOption()) {
String key = queryOption.KEY().getText().substring(1);
LiteralValueElement literal = (LiteralValueElement) visit(queryOption.literal());
if (queryOption.type() != null) {
IriRefValueElement type = (IriRefValueElement) visit(queryOption.type());
Literal typeLiteral = Values.literal(Values.getValueFactory(), literal.getLiteral().getLabel(), type.getIri());
customQueryOptions.add(key, typeLiteral);
} else {
customQueryOptions.add(key, literal.getLiteral());
}
}
QueryOptionsPathElement queryOptionsPathElement = new QueryOptionsPathElement(this.repositoryContext);
queryOptionsPathElement.setCustomQueryOptions(customQueryOptions);
return queryOptionsPathElement;
}
use of com.inova8.pathql.element.IriRefValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternVisitor method visitReifiedPredicate.
/**
* Visit reified predicate.
*
* @param ctx the ctx
* @return the predicate element
*/
@Override
public PredicateElement visitReifiedPredicate(ReifiedPredicateContext ctx) {
// reifiedPredicate : iriRef? REIFIER predicateRef factFilterPattern? dereifier? ; #statementFilterPattern
PredicateElement reifiedPredicateElement = new PredicateElement(this.repositoryContext);
reifiedPredicateElement.setIsReified(true);
if (ctx.iriRef() != null) {
reifiedPredicateElement.setReification(((IriRefValueElement) visit(ctx.iriRef())).getIri());
}
if (ctx.predicateRef() != null) {
reifiedPredicateElement.setPredicate(((IriRefValueElement) visit(ctx.predicateRef())).getIri());
}
if (ctx.factFilterPattern() != null) {
reifiedPredicateElement.setObjectFilterElement((FactFilterElement) visit(ctx.factFilterPattern()));
}
if (ctx.dereifier() != null) {
reifiedPredicateElement.setIsDereified(true);
}
return reifiedPredicateElement;
}
use of com.inova8.pathql.element.IriRefValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternVisitor method visitQname.
/**
* Visit qname.
*
* @param ctx the ctx
* @return the iri ref value element
*/
@Override
public IriRefValueElement visitQname(QnameContext ctx) {
// qname : PNAME_NS PN_LOCAL;
IriRefValueElement qnameElement = new IriRefValueElement(this.repositoryContext);
IRI qname = this.repositoryContext.convertQName(ctx.getText(), getPrefixes());
if (qname != null) {
qnameElement.setIri(qname);
return qnameElement;
} else {
if (thing != null)
thing.getEvaluationContext().getTracer().traceQNameError(ctx.getText());
throw new ScriptFailedException(String.format("Error identifying namespace of qName %s", ctx.getText()));
}
}
use of com.inova8.pathql.element.IriRefValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternVisitor method visitPname_ns.
/**
* Visit pname ns.
*
* @param ctx the ctx
* @return the iri ref value element
*/
@Override
public IriRefValueElement visitPname_ns(Pname_nsContext ctx) {
// pname_ns : PNAME_NS ;
IriRefValueElement pname_nsElement = new IriRefValueElement(this.repositoryContext);
Prefixes prefixes = null;
prefixes = this.repositoryContext.getPrefixes();
// if(thing!=null) prefixes=thing.getPrefixes();
IRI qname = this.repositoryContext.convertQName(ctx.getText(), prefixes);
if (qname != null) {
pname_nsElement.setIri(qname);
return pname_nsElement;
} else {
if (thing != null)
thing.getEvaluationContext().getTracer().traceQNameError(ctx.getText());
throw new ScriptFailedException(String.format("Error identifying namespace of qName %s", ctx.getText()));
}
}
use of com.inova8.pathql.element.IriRefValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternVisitor method visitPredicate.
/**
* Visit predicate.
*
* @param ctx the ctx
* @return the predicate element
*/
@Override
public PredicateElement visitPredicate(PredicateContext ctx) {
// predicate : ( reifiedPredicate | predicateRef | rdfType | '*' ) factFilterPattern? #objectFilterPattern
PredicateElement predicateElement = null;
if (ctx.reifiedPredicate() != null) {
predicateElement = (PredicateElement) visit(ctx.reifiedPredicate());
predicateElement.setOperator(PathConstants.Operator.PREDICATE);
} else if (ctx.predicateRef() != null) {
predicateElement = new PredicateElement(this.repositoryContext);
predicateElement.setOperator(PathConstants.Operator.PREDICATE);
IriRefValueElement predicateRef = ((IriRefValueElement) visit(ctx.predicateRef()));
predicateElement.setPredicate(predicateRef.getIri());
} else if (ctx.rdfType() != null) {
predicateElement = new PredicateElement(this.repositoryContext);
predicateElement.setOperator(PathConstants.Operator.PREDICATE);
predicateElement.setPredicate((iri("http://rdftype")));
} else if (ctx.anyPredicate() != null) {
predicateElement = new PredicateElement(this.repositoryContext);
predicateElement.setOperator(PathConstants.Operator.PREDICATE);
predicateElement.setAnyPredicate(true);
}
if (ctx.factFilterPattern() != null) {
if (ctx.reifiedPredicate() != null) {
predicateElement.setStatementFilterElement((FactFilterElement) visit(ctx.factFilterPattern()));
} else {
predicateElement.setObjectFilterElement((FactFilterElement) visit(ctx.factFilterPattern()));
}
}
return predicateElement;
}
Aggregations