On 09/11/11 07:49, Martin Weitzel wrote:
Ah okay, case solved. An healthy look into API and this works just fine:
final QueryExecution queryExecution =
QueryExecutionFactory.create(QueryFactory.create(queryString),
requestModel);
queryExecution.getContext().set(Symbol.create("TransportSection") ,
transportSection);
My "transportSection" is then available within the QueryContext of the
property function execution.
-- Martin
:-)
That's the best way. An initial binding for a varibale, e.,g. ?myParam
and passing ?myParam to your property function (list of args to be able
to get more than one arg in) shoudl also work but (1) old versions had a
bug on rewriting the constant into the query for property functions and
(2) that's what the context is for anyway.
Andy
2011/11/8 Martin Weitzel<[email protected]>
Hi there,
I am using Jena within a Spring MVC web application as interface for a rdf
knowledge base. The main application for this knowledge base is to be
queried with SPARQL for the best fitting (logistic) service provider for a
certain conext.
I extended the ARQ with a property function, which task is to calculate a
"fitness" value for each service provider. The problem is, that the
calculation is depending on information that is only available within the
requesting query method (i.e. a given transportation path, that is
needed to calculate the distance from a service provider (stored in the
knowledge base) to the path (a request-thing)).
So, I am looking for a best practice to pass:
a) The object (reference) itself or
b) A Key for a ConcurrentMap
to the property function calculating the fitness. I tried to extend the
SPARQL query by binding a string literal to a new variable, so that it
would be available in the binding or the context, but without success. My
current solution is not threadsafe: The FitnessCalculator is registered via
a factory as shown here (http://jena.sourceforge.net/ARQ/extension.html).
The factory is a spring service and injects the query service reference to
the property function. The query method then saves the transport path
object in a public variable, that is accessable by the Property Function.
Obviously, this will have side effects in a multi-threaded environment.
I would appreciate any best practice tips!
-- Martin