org.apache.jena.sparql.ARQConstants Java Examples

The following examples show how to use org.apache.jena.sparql.ARQConstants. 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: BindPlan.java    From sparql-generate with Apache License 2.0 6 votes vote down vote up
@Override
protected final Binding exec(Binding binding, Context context) {
    LOG.debug("Start " + this);
    context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime());
    final FunctionEnv env = new FunctionEnvBase(context);
    try {
        final NodeValue n = expr.eval(binding, env);
        if (LOG.isTraceEnabled()) {
            LOG.trace("New binding " + var + " = " + LogUtils.compress(n.asNode()));
        }
        return BindingFactory.binding(binding, var, n.asNode());
    } catch(ExprEvalException ex) {
        LOG.trace("No evaluation for " + this + " " + ex.getMessage());
        return binding;
    }
}
 
Example #2
Source File: JenaUtil.java    From shacl with Apache License 2.0 6 votes vote down vote up
private static Node invokeFunction(Resource function, ExprList args, Dataset dataset) {

		if (dataset == null) {
	        dataset = ARQFactory.get().getDataset(ModelFactory.createDefaultModel());
	    }
		
		E_Function expr = new E_Function(function.getURI(), args);
		DatasetGraph dsg = dataset.asDatasetGraph();
		Context cxt = ARQ.getContext().copy();
		cxt.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime());
		FunctionEnv env = new ExecutionContext(cxt, dsg.getDefaultGraph(), dsg, null);
		try {
			NodeValue r = expr.eval(BindingRoot.create(), env);
			if(r != null) {
				return r.asNode();
			}
		}
		catch(ExprEvalException ex) {
		}
		return null;
	}
 
Example #3
Source File: ContextUtils.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
private Builder() {
	this.context = new Context(ARQ.getContext());
	this.commons = new Commons();

	// update functionregistry
	FunctionRegistry registry = (FunctionRegistry) context.get(ARQConstants.registryFunctions);
	SPARQLExtFunctionRegistry newRegistry = new SPARQLExtFunctionRegistry(registry, context);
	context.set(ARQConstants.registryFunctions, newRegistry);

	// update iteratorregistry
	IteratorFunctionRegistry iteratorRegistry = (IteratorFunctionRegistry) context
			.get(SPARQLExt.REGISTRY_ITERATORS);
	IteratorFunctionRegistry newIteratorRegistry = new IteratorFunctionRegistry(iteratorRegistry, context);
	context.set(SPARQLExt.REGISTRY_ITERATORS, newIteratorRegistry);

	// default streammanager
	context.set(SysRIOT.sysStreamManager, SPARQLExtStreamManager.makeStreamManager());

	// set variable parts
	context.set(DATASET, DatasetFactory.create());

	// default prefix manager
	context.set(PREFIX_MANAGER, PrefixMapping.Standard);

	// default number of results and blank nodes
	context.set(SIZE, 0);
	// context.set(LIST_NODES, new HashMap<>());

	context.set(COMMONS, commons);
}
 
Example #4
Source File: ElementTransformSPARQLStar.java    From RDFstarTools with Apache License 2.0 4 votes vote down vote up
protected Node createFreshAnonVarForReifiedTriple()
{
	final String varName = ARQConstants.allocVarAnonMarker + randomVarID + anonVarCounter++;
	return NodeFactory.createVariable( varName );
}
 
Example #5
Source File: DB2DescribeHandler.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
public void start(Model accumulateResultModel, Context cxt) {
	acc = accumulateResultModel;
	this.dataset = (Dataset) cxt.get(ARQConstants.sysCurrentDataset);
	resources = new HashSet<String>();
}