Hi Lorenz,

thanks, but wouldn't these methods append VALUES at the end of the
query? Which would not be equivalent to having it injected at the
beginning?

I don't want to build the whole query with Java -- I already have a
query string.

Martynas

On Mon, Nov 25, 2024 at 7:58 AM Lorenz Buehmann
<buehm...@informatik.uni-leipzig.de> wrote:
>
> Hi,
>
> you mentioned a query builder, so did you try to use the Jena query
> builder already? If so,
>
> the method addWhereValueVars on the SelectBuilder[1] or directly on the
> WhereBuilder[2] would be the way to go.
>
>
> Cheers,
>
> Lorenz
>
> [1]
> https://jena.apache.org/documentation/javadoc/extras/querybuilder/org.apache.jena.querybuilder/org/apache/jena/arq/querybuilder/SelectBuilder.html#addWhereValueVars(java.util.Map)
>
>
> [2]
> https://jena.apache.org/documentation/javadoc/extras/querybuilder/org.apache.jena.querybuilder/org/apache/jena/arq/querybuilder/WhereBuilder.html#addWhereValueVars(java.util.Map)
>
>
> On 25.11.24 01:02, David Habgood wrote:
> > Hi Martynas,
> >
> > Do you know ahead of time which variable(s) you're going to be injecting
> > the VALUES clause for?
> >
> > I've been using a pattern where I add VALUES ?this { UNDEF } in "template"
> > queries, then at runtime parse the query and replace "UNDEF" (where all of
> > the DataBlockValue <https://www.w3.org/TR/sparql11-query/#rDataBlockValue>s
> > in a binding within a InlineDataFull are "UNDEF") with a set of bindings
> > supplied at runtime. This has the benefit that if you do not supply a
> > binding for ?this, UNDEF means it is left unbound.
> >
> > Thanks,
> >
> > On Mon, Nov 25, 2024 at 9:40 AM Martynas Jusevičius <marty...@atomgraph.com>
> > wrote:
> >
> >> Hi,
> >>
> >> What would be the simplest way to safely (i.e. using query builder or
> >> algebra) to inject a VALUES block at the beginning of a query?
> >>
> >> For example
> >>
> >> SELECT *
> >> {
> >>    ?this ?p ?o
> >> }
> >>
> >> should become
> >>
> >> SELECT *
> >> {
> >>    VALUES ?this <http://localhost>
> >>    ?this ?p ?o
> >> }
> >>
> >> after the injection.
> >>
> >> Thanks,
> >>
> >> Martynas
> >>
> --
> Lorenz Bühmann
> Research Associate/Scientific Developer
>
> Email buehm...@infai.org
>
> Institute for Applied Informatics e.V. (InfAI) | Goerdelerring 9 | 04109 
> Leipzig | Germany
>

Reply via email to