[ 
https://issues.apache.org/jira/browse/JENA-2242?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kelvin Qian updated JENA-2242:
------------------------------
    Description: 
Currently when stringifying a WhereBuilder (e.g. for debugging), any VALUES 
clause is not included in the output of .toString:
{code:java}
import java.util.ArrayList;
import java.util.HashMap;

import org.apache.jena.graph.Node;
import org.apache.jena.grpah.Triple;
import org.apache.jena.arq.querybuilder.Converters;

import org.apache.jena.arq.querybuilder.WhereBuilder;
 
// Node creation
Node svarNode = Converters.checkVar(NodeFactory.createVariable("s"));
Node pvarNode = Converters.checkVar(NodeFactory.createVariable("p"));
Node ovarNode = Converters.checkVar(NodeFactory.createVariable("o"));

// Values map creation
ArrayList<Node> subjColl = new ArrayList<>();
subjColl.add(NodeFactory.createURI("http://example.org#subject";));

HashMap<Node, ArrayList<Node>> valMap = new HashMap<>();
valMap.put(svarNode, subjColl);

// WhereBuilder creation
WhereBuilder wb = new WhereBuilder();
wb.addWhere(svarNode, pvarNode, ovarNode);
wb.addWhereValueVars(valMap);

wb.toString();

// WHERE { ?s ?p ?o }
{code}
It is only when you add the WhereBuilder to another builder, e.g. a 
ConstructBuilder, when you are able to visualize the VALUES clause:
{code:java}
import org.apache.jena.arq.querybuilder.ConstructBuilder;

ConstructBuilder cb = new ConstructBuilder();
cb.addConstruct(new Triple(svarNode, pvarNode, ovarNode));
cb.addWhere(wb);

cb.toString();

// CONSTRUCT 
//   { 
//     ?s ?p ?o .
//   }
// WHERE
//   { ?s  ?p  ?o
//     VALUES ( ?s ) { ( <http://example.org#subject> ) }
//   }
{code}
Ideally we would like to visualize the VALUES clause by including it in the 
result string while stringifying the WhereBuilder, not just with the 
ConstructBuilder. This would improve the development experience by allowing us 
to focus on debuggin the WHERE clause, without having to consider the 
containing query or update.

  was:
Currently when stringifying a WhereBuilder (e.g. for debugging), any VALUES 
clause is not included in the output of .toString:
{code:java}
import java.util.HashMap;

import org.apache.jena.graph.Node;
import org.apache.jena.grpah.Triple;
import org.apache.jena.arq.querybuilder.Converters;

import org.apache.jena.arq.querybuilder.WhereBuilder;
 
// Node creation
Node svarNode = Converters.checkVar(NodeFactory.createVariable("s"));
Node pvarNode = Converters.checkVar(NodeFactory.createVariable("p"));
Node ovarNode = Converters.checkVar(NodeFactory.createVariable("o"));

// Values map creation
ArrayList<Node> subjColl = new ArrayList<>();
subjColl.add(NodeFactory.createURI("http://example.org#subject";));

HashMap<Node, ArrayList<Node>> valMap = new HashMap<>();
valMap.put(svarNode, subjColl);

// WhereBuilder creation
WhereBuilder wb = new WhereBuilder();
wb.addWhere(svarNode, pvarNode, ovarNode);
wb.addWhereValueVars(valMap);

wb.toString();

// WHERE { ?s ?p ?o }
{code}
It is only when you add the WhereBuilder to another builder, e.g. a 
ConstructBuilder, when you are able to visualize the VALUES clause:
{code:java}
import org.apache.jena.arq.querybuilder.ConstructBuilder;

ConstructBuilder cb = new ConstructBuilder();
cb.addConstruct(new Triple(svarNode, pvarNode, ovarNode));
cb.addWhere(wb);

cb.toString();

// CONSTRUCT 
//   { 
//     ?s ?p ?o .
//   }
// WHERE
//   { ?s  ?p  ?o
//    VALUES ( ?s ) { ( <http://example.org#subject> ) }
//   }
{code}
Ideally we would like to visualize the VALUES clause by including it in the 
result string while stringifying the WhereBuilder, not just with the 
ConstructBuilder.


> Include VALUES clause in string when stringifying a WhereBuilder
> ----------------------------------------------------------------
>
>                 Key: JENA-2242
>                 URL: https://issues.apache.org/jira/browse/JENA-2242
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: QueryBuilder
>    Affects Versions: Jena 4.3.2
>            Reporter: Kelvin Qian
>            Assignee: Claude Warren
>            Priority: Major
>
> Currently when stringifying a WhereBuilder (e.g. for debugging), any VALUES 
> clause is not included in the output of .toString:
> {code:java}
> import java.util.ArrayList;
> import java.util.HashMap;
> import org.apache.jena.graph.Node;
> import org.apache.jena.grpah.Triple;
> import org.apache.jena.arq.querybuilder.Converters;
> import org.apache.jena.arq.querybuilder.WhereBuilder;
>  
> // Node creation
> Node svarNode = Converters.checkVar(NodeFactory.createVariable("s"));
> Node pvarNode = Converters.checkVar(NodeFactory.createVariable("p"));
> Node ovarNode = Converters.checkVar(NodeFactory.createVariable("o"));
> // Values map creation
> ArrayList<Node> subjColl = new ArrayList<>();
> subjColl.add(NodeFactory.createURI("http://example.org#subject";));
> HashMap<Node, ArrayList<Node>> valMap = new HashMap<>();
> valMap.put(svarNode, subjColl);
> // WhereBuilder creation
> WhereBuilder wb = new WhereBuilder();
> wb.addWhere(svarNode, pvarNode, ovarNode);
> wb.addWhereValueVars(valMap);
> wb.toString();
> // WHERE { ?s ?p ?o }
> {code}
> It is only when you add the WhereBuilder to another builder, e.g. a 
> ConstructBuilder, when you are able to visualize the VALUES clause:
> {code:java}
> import org.apache.jena.arq.querybuilder.ConstructBuilder;
> ConstructBuilder cb = new ConstructBuilder();
> cb.addConstruct(new Triple(svarNode, pvarNode, ovarNode));
> cb.addWhere(wb);
> cb.toString();
> // CONSTRUCT 
> //   { 
> //     ?s ?p ?o .
> //   }
> // WHERE
> //   { ?s  ?p  ?o
> //     VALUES ( ?s ) { ( <http://example.org#subject> ) }
> //   }
> {code}
> Ideally we would like to visualize the VALUES clause by including it in the 
> result string while stringifying the WhereBuilder, not just with the 
> ConstructBuilder. This would improve the development experience by allowing 
> us to focus on debuggin the WHERE clause, without having to consider the 
> containing query or update.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to