Java Code Examples for org.apache.jena.sparql.expr.ExprList#add()

The following examples show how to use org.apache.jena.sparql.expr.ExprList#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExprNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Expr normalize(ExprFunctionN func) {
    ExprList args = new ExprList();
    for (Expr expr : func.getArgs()) {
        Expr arg = normalize(expr);
        args.add(arg);
    }
    return func.copy(args);
}
 
Example 2
Source File: ExprNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Expr normalize(ExprFunctionOp funcOp) {
    ExprList args = new ExprList();
    for (Expr expr : funcOp.getArgs()) {
        Expr arg = normalize(expr);
        args.add(arg);
    }
    return funcOp.copy(args, funcOp.getGraphPattern());
}
 
Example 3
Source File: ExprNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Expr normalize(ExprFunctionN func) {
    ExprList args = new ExprList();
    for (Expr expr : func.getArgs()) {
        Expr arg = normalize(expr);
        args.add(arg);
    }
    return func.copy(args);
}
 
Example 4
Source File: ExprNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Expr normalize(ExprFunctionOp funcOp) {
    ExprList args = new ExprList();
    for (Expr expr : funcOp.getArgs()) {
        Expr arg = normalize(expr);
        args.add(arg);
    }
    return funcOp.copy(args, funcOp.getGraphPattern());
}
 
Example 5
Source File: ExprNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Expr normalize(ExprAggregator eAgg) {
    final ExprList exprList = eAgg.getAggregator().getExprList();
    if (exprList == null) {
        return eAgg;
    } else {
        final Var v = eAgg.getVar();
        final ExprList x = new ExprList();
        for (Expr e : exprList) {
            x.add(normalize(e));
        }
        Aggregator agg = eAgg.getAggregator().copy(x);
        return new ExprAggregator(v, agg);
    }
}
 
Example 6
Source File: ExprNormalizer.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Expr normalize(Node_ExtendedURI n) {
    ExprList args = new ExprList();
    List<Expr> components = n.getComponents();
    for (Expr e : components) {
        args.add(normalize(e));
    }
    Expr str = new E_StrConcat(args);
    Expr expr = new E_IRI(str);
    return expr;
}
 
Example 7
Source File: TemplateUtils.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
public static E_Function getFunction(SPARQLExtQuery query) {
    if (query.isSubQuery() && query.getName() != null) {
        String qs = query.toString();
        SPARQLExtQuery query2 = (SPARQLExtQuery) ParserSPARQLExt.parseSubQuery(query, qs);
        query2.setFromClauses(query.getFromClauses());
        query2.setQuerySelectType();
        query2.setQueryResultStar(true);
        query2.setName(null);
        query2.setCallParameters(null);
        if (query2.getQueryPattern() == null) {
            query2.setQueryPattern(new ElementGroup());
        }
        
        SelectExtractionVisitor selectExtractionVisitor = new SelectExtractionVisitor(query2);
        query.visit(selectExtractionVisitor);
        SPARQLExtQuery query3 = selectExtractionVisitor.getOutput();
        
        NodeValue selectQuery = null;

        if(query3 != null) {
        	selectQuery = NodeValue.makeNode(query2.toString(), null, SPARQLExt.MEDIA_TYPE_URI);
        }

        ExprList exprList = new ExprList(selectQuery);
        exprList.add(query.getName());
        exprList.addAll(query.getCallParameters());
        return new E_Function(FUN_Select_Call_Template.URI, exprList);
    } else {
        NodeValue n = NodeValue.makeNode(query.toString(), null, SPARQLExt.MEDIA_TYPE_URI);
        return new E_Function(ST.callTemplate, new ExprList(n));
    }
}
 
Example 8
Source File: JenaUtil.java    From shacl with Apache License 2.0 5 votes vote down vote up
public static Node invokeFunction3(Resource function, RDFNode argument1, RDFNode argument2, RDFNode argument3, Dataset dataset) {
	ExprList args = new ExprList();
	args.add(argument1 != null ? NodeValue.makeNode(argument1.asNode()) : new ExprVar("arg1"));
	args.add(argument2 != null ? NodeValue.makeNode(argument2.asNode()) : new ExprVar("arg2"));
	args.add(argument3 != null ? NodeValue.makeNode(argument3.asNode()) : new ExprVar("arg3"));
	return invokeFunction(function, args, dataset);
}
 
Example 9
Source File: JenaUtil.java    From shacl with Apache License 2.0 3 votes vote down vote up
/**
 * Calls a given SPARQL function with two arguments.
 *
 * @param function  the URI resource of the function to call
 * @param argument1 the first argument
 * @param argument2 the second argument
 * @param dataset   the Dataset to operate on or null for default
 * @return the result of the function call
 */
public static Node invokeFunction2(Resource function, RDFNode argument1, RDFNode argument2, Dataset dataset) {
	ExprList args = new ExprList();
	args.add(argument1 != null ? NodeValue.makeNode(argument1.asNode()) : new ExprVar("arg1"));
	args.add(argument2 != null ? NodeValue.makeNode(argument2.asNode()) : new ExprVar("arg2"));
	return invokeFunction(function, args, dataset);
}
 
Example 10
Source File: JenaUtil.java    From shacl with Apache License 2.0 2 votes vote down vote up
/**
 * Calls a given SPARQL function with one argument.
 *
 * @param function the URI resource of the function to call
 * @param argument the first argument
 * @param dataset  the Dataset to operate on or null for default
 * @return the result of the function call
 */
public static Node invokeFunction1(Resource function, RDFNode argument, Dataset dataset) {
	ExprList args = new ExprList();
	args.add(argument != null ? NodeValue.makeNode(argument.asNode()) : new ExprVar("arg1"));
	return invokeFunction(function, args, dataset);
}