There's another way to modify queries dynamically - as RDF using SPIN
vocabulary:
http://www.w3.org/Submission/2011/SUBM-spin-modeling-20110222/

Example QueryBuilder class:
https://github.com/Graphity/graphity-ldp/blob/master/src/main/java/org/graphity/util/QueryBuilder.java

Martynas
graphity.org

On Mon, Oct 29, 2012 at 6:31 PM, John Liu <john_ws_...@yahoo.com> wrote:
> Thank you very much Andy for your quick action.
>
>>It will be in tonight's snapshot build of 2.7.5-SNAPSHOT (it builds at about 
>>05:00 UTC)
>
> When will Jena 2.7.5 be released?
>
>>Not all algebra expressions can be turned into a query. If you are
>>manipulating the algebra, you can create forms OpAsQuery does not recognize.
>
> Can I assume that all ops which are compiled from a sparql query can be 
> turned back to a sparql query? For example, the following codes are always 
> working fine:
>
>           AlgebraGenerator ag = new AlgebraGenerator();
>           Op op = ag.compile(query);
>           Query query2 = OpAsQuery.asQuery(op);
>
>
> The reason why we use these functions is that we want to add filters into the 
> query in runtime, for example modifying the op by adding a filter expression 
> (op = OpFilter.filter(e, op);), is this the best way to do that(adding a 
> filter)?
>
> Thanks, John
>
>
>
>
> ________________________________
>  From: Andy Seaborne <a...@apache.org>
> To: users@jena.apache.org
> Sent: Friday, October 26, 2012 6:19:00 PM
> Subject: Re: ARQNotImplemented exception thrown by ARQ function calls
>
> Oversight - I've just implemented it (it's not hard!).  It wil be in
> tonight's snapshot build of 2.7.5-SNAPSHOT (it builds at about 05:00 UTC)
>
> https://repository.apache.org/content/repositories/snapshots/org/apache/jena/apache-jena/
>
> By the way, you can execute algebra expressions directly:
>
> DatasetGraph dsg = ...
> QueryIterator qIter = Algebra.exec(op, dsg) ;
>
> Not all algebra expressions can be turned into a query. If you are
> manipulating the algebra, you can create forms OpAsQuery does not recognize.
>
>     Andy
>
> On 26/10/12 22:24, John Liu wrote:
>> I use some Jena arq apis to modify the query for adding filter in runtime.
>>
>> The query is
>>
>> PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
>> PREFIX onto: <http://dbpedia.org/ontology/>
>> SELECT * WHERE {
>> ?p a onto:Place .
>> ?p geo:l* ?loc .
>> }
>>
>> There is valid card in the line "?p geo:l* ?loc ."
>>
>> The funcations I used are:
>>
>>      AlgebraGenerator ag = new AlgebraGenerator();
>>      Op op = ag.compile(query);
>>      op = OpFilter.filter(e, op);
>>      Query query2 = OpAsQuery.asQuery(op);
>>
>> This query causes an ARQNotImplemented exception thrown in the last function 
>> call. The exception stack trace is:
>>
>> com.hp.hpl.jena.sparql.ARQNotImplemented error occurred when handling the 
>> REST data service.
>> Not implemented: OpPath
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.visit(OpAsQuery.java:224)
>>   at com.hp.hpl.jena.sparql.algebra.op.OpPath.visit(OpPath.java:73)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.asElementGroup(OpAsQuery.java:97)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.asElement(OpAsQuery.java:88)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.visit(OpAsQuery.java:168)
>>   at com.hp.hpl.jena.sparql.algebra.op.OpSequence.visit(OpSequence.java:75)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.visit(OpAsQuery.java:473)
>>   at com.hp.hpl.jena.sparql.algebra.op.OpSlice.visit(OpSlice.java:50)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.asElementGroup(OpAsQuery.java:97)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.asElement(OpAsQuery.java:88)
>>   at 
>> com.hp.hpl.jena.sparql.algebra.OpAsQuery$Converter.visit(OpAsQuery.java:310)
>>   at com.hp.hpl.jena.sparql.algebra.op.OpFilter.visit(OpFilter.java:110)
>>   at com.hp.hpl.jena.sparql.algebra.OpAsQuery.asQuery(OpAsQuery.java:50)
>>
>> The arq library I used is jena-arq-2.9.1 and the jean is jena-core-2.7.1
>>
>> My question is if this is bug in the arq functions? I have tested these 
>> functions without adding the filter(the third call), but it still throws the 
>> exception.
>>
>> If it isa bug, how can I file a defect to it?
>>
>> If it is not, how can I fix my code to avoid this exception.
>>
>> Thanks a lot for your help.
>>
>> John
>>

Reply via email to