Thank you for catching the error in the example.
This change is adding support for the Values keyword to the builders. We
are going to produce a VALUES block.
What we effectively have is a table with column headers and we need a way
to specify it.
alternatively you could look at it as a table with row lables.
The original solution looked at the problem as column headers, the latest
proposal looks at it as row labels. I am more inclined to row labels at
this point specifying the var and all the values. But I can see that some
applications will need to set rows at a time and others columns.
Perhaps the Values builder is the best solution. For purposes of
conceptualization we will talk about column headers (vars) and columns of
data.
So
{code}
addVar( "?x" ).addVar( "?y" );
{code}
would add 2 columns with ?x and ?y as their headers, the columns would have
no data.
{code}
addVar( "?x", "foo", "fu" ).addVar( "?y", "bar", "baz" );
{code}
would add 2 columns with ?x and ?y as their headers and the specified data.
{code}
.addRow( "foo2","bar2").addRow("fu2","baz2")
{code}
would add more rows to the existing set.
{code}
addVar( Collection<Object> )
{code}
would add an entire column with the var as the first item in the collection.
{code}
addVar( "?z", Collection<Object> )
{code}
would add an entire column with the specified var.
{code}
addVars( Map<Var,Collection<Object>> )
{code}
would add the vars and data specified.
Adding an existing var will replace all the data for that var.
all vars must have the same number of items.
On Tue, Feb 28, 2017 at 12:04 PM, Aleksandar Babic (JIRA) <[email protected]>
wrote:
>
> [ https://issues.apache.org/jira/browse/JENA-1295?page=
> com.atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel&focusedCommentId=15887877#comment-15887877 ]
>
> Aleksandar Babic commented on JENA-1295:
> ----------------------------------------
>
> It looks much better, but there is an error, addValues for ?x should be
> {code}.addValues("?x", "foo", "fu"){code}
>
> However, there should be a method overloading (or type checking) for those
> who want to send a large list of values for single variable:
> {code}
> .addValues("?x", Arrays.asList("foo", "fu"))
> {code}
>
> as well as to add all at once:
> {code}
> Map<String, List<String>> values = new HashMap<>(2);
> values.put("?x", Arrays.asList("foo", "fu"))
> values.put("?y", Arrays.asList("bar", "baz"))
>
> builder.addValues(values);
> {code}
>
> I forgot size of all collections should be the same, but it makes sense to
> perform check. Additional, "Values builder" might be good fit here as well:
>
> {code}
> Values values = new Values.Builder("?x", "?y")
> .withData(Arrays.asList("foo", "fu"))
> .withData(Arrays.asList("bar", "baz"))
> .build();
>
> selectBuilder.setValues(values);
> {code}
>
> P.S. Note that values support "[UNDEF|http://www.snee.com/
> bobdc.blog/2012/09/sparql-11s-new-values-keyword.html]" as keyword, which
> should be also supported.
>
>
>
> > Add support to VALUES in SelectBuilder
> > --------------------------------------
> >
> > Key: JENA-1295
> > URL: https://issues.apache.org/jira/browse/JENA-1295
> > Project: Apache Jena
> > Issue Type: Wish
> > Components: QueryBuilder
> > Reporter: Aleksandar Babic
> > Assignee: Claude Warren
> > Fix For: Jena 3.3.0
> >
> >
> > It seems that QueryBuilder is lacking on support for building VALUES
> block, or there is no obvious method to do that.
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.15#6346)
>
--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren