On 20/09/15 11:18, Claude Warren wrote:
Andy,

I started to work on a solution which was fairly simple until I started to
run the test.  I tried creating a query with the same optional block.
However, while they both looked like:
{noformat}

  OPTIONAL
       { ?s  <urn:q>  "123"^^<http://www.w3.org/2001/XMLSchema#int> ;
             <urn:v>  ?x
         FILTER ( ?x > 56 )
       }

{noformat}

the one built by querybuilder is using an ElementTriplesBlock for the:
{noformat}

?s  <urn:q>  "123"^^<http://www.w3.org/2001/XMLSchema#int> ;
             <urn:v>  ?x

{noformat}

while the queryFactory version uses an ElementPathBlock.

I suspect this is as defect in the querybuilder but can you explain the
difference and when one or the other should be used?

ElementGroup

This is unit for OPTIONAL and other compound structures. It can hold several ElementPathBlock, ElementFilter, ElementOptional. Indeed, it can hold other ElementGroup.

Do not confuse with GROUP BY - unrelated. ElementGroup is SPARQL 1.0 and then the term "group" was free.

WhereHandler, other than it's name, looks (by inspection) to be close in concept.

It needs "addPattern(WhereHandler)" which is why the name looks odd to me.

This gives the inner {} in:
    { ?s1 ?p1 ?o1
      { ?s ?p ?o }
      ?s2 ?p2 ?o2
    }

so maybe: untested:

WhereHandler -> PatternHandler
  without setVars
  ?? addAll(PatternHandler)

WhereHandler becomes subclass of PatternHandler.
  with setVars - the only action that only applies to WHERE

WhereHandler::addAll looks odd - only considers ElementTriplesBlock in some cases.

        Andy


Claude

On Sun, Sep 20, 2015 at 10:19 AM, Claude Warren <[email protected]> wrote:

No there isn't.  It is an oversight.  Looks like QueryBuilder needs to
have a group pattern.  I think that this could be done by using a
SelectBuilder as a container the group pattern as we can get a WhereHandler
from it and that seems to have all the bits that are needed.

Claude

On Sat, Sep 19, 2015 at 3:10 PM, Andy Seaborne <[email protected]> wrote:

how do I add

OPTIONAL {
     ?s <q> 123 .
     ?s <v> ?x .
     FILTER(?x>56)
}

i.e a compound OPTIONAL pattern?

There seems to be no concept of a group pattern (do not confuse with
GROUP BY).

(This applies all places group patterns occur, which is quite a few in
SPARQL)

         Andy




--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren





Reply via email to