[jira] [Commented] (JENA-1578) SPARQL VALUES for ParameterizedSparqlString

2018-07-27 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/JENA-1578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16559906#comment-16559906
 ] 

ASF GitHub Bot commented on JENA-1578:
--

Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/449#discussion_r205813086
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java ---
@@ -1734,4 +1740,243 @@ public String toString() {
 }
 
 }
+
+/**
+ * Assign a varName with a multiple items and whether to include
+ * parenthesis.
+ *
+ * @param varName
+ * @param items
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, Collection 
items, boolean isParenthesisNeeded) {
+this.valuesReplacements.put(varName, new ValueReplacement(varName, 
items, isParenthesisNeeded));
+}
+
+/**
+ * Assign a varName with a multiple items.
+ * Can be used to assign multiple values to a single variable or single
+ * value to multiple variables (if using a List) in the SPARQL 
query.
+ * See setGroupedValues to assign multiple values to multiple 
variables.
+ *
+ * @param varName
+ * @param items
+ */
+public void setValues(String varName, Collection 
items) {
+setValues(varName, items, false);
+}
+
+/**
+ * Assign a varName with a single item and whether to include 
parenthesis.
+ *
+ * @param varName
+ * @param item
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, RDFNode item, boolean 
isParenthesisNeeded) {
+setValues(varName, Arrays.asList(item), isParenthesisNeeded);
+}
+
+/**
+ * Assign a varName with a single item.
+ *
+ * @param varName
+ * @param item
+ */
+public void setValues(String varName, RDFNode item) {
+setValues(varName, Arrays.asList(item), false);
+}
+
+/**
+ * Sets a map of varNames and their items.
+ *
+ * @param valuesItems
+ */
+public void setValues(Map> 
valuesItems) {
+for (String varName : valuesItems.keySet()) {
--- End diff --

Just a style thing, really, but I believe this method could be just 
`valuesItems.forEach(this::setValues)`.


> SPARQL VALUES for ParameterizedSparqlString
> ---
>
> Key: JENA-1578
> URL: https://issues.apache.org/jira/browse/JENA-1578
> Project: Apache Jena
>  Issue Type: New Feature
>  Components: ARQ
>Affects Versions: Jena 3.8.0
>Reporter: Greg Albiston
>Priority: Minor
>
> ParameterizedSparqlString provides an API for substituting variables within 
> SPARQL queries with bound values. It does not support the SPARQL VALUES 
> keyword which allows multiple values to be specified. The VALUES syntax 
> supports multiple values for a single variable, sets of values for multiple 
> variables and multiple sets of values for multiple values.
> Inquiry on 24/07/18 the mailing list about this feature. Patch is forthcoming.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] jena pull request #449: JENA-1578

2018-07-27 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/449#discussion_r205813086
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java ---
@@ -1734,4 +1740,243 @@ public String toString() {
 }
 
 }
+
+/**
+ * Assign a varName with a multiple items and whether to include
+ * parenthesis.
+ *
+ * @param varName
+ * @param items
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, Collection 
items, boolean isParenthesisNeeded) {
+this.valuesReplacements.put(varName, new ValueReplacement(varName, 
items, isParenthesisNeeded));
+}
+
+/**
+ * Assign a varName with a multiple items.
+ * Can be used to assign multiple values to a single variable or single
+ * value to multiple variables (if using a List) in the SPARQL 
query.
+ * See setGroupedValues to assign multiple values to multiple 
variables.
+ *
+ * @param varName
+ * @param items
+ */
+public void setValues(String varName, Collection 
items) {
+setValues(varName, items, false);
+}
+
+/**
+ * Assign a varName with a single item and whether to include 
parenthesis.
+ *
+ * @param varName
+ * @param item
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, RDFNode item, boolean 
isParenthesisNeeded) {
+setValues(varName, Arrays.asList(item), isParenthesisNeeded);
+}
+
+/**
+ * Assign a varName with a single item.
+ *
+ * @param varName
+ * @param item
+ */
+public void setValues(String varName, RDFNode item) {
+setValues(varName, Arrays.asList(item), false);
+}
+
+/**
+ * Sets a map of varNames and their items.
+ *
+ * @param valuesItems
+ */
+public void setValues(Map> 
valuesItems) {
+for (String varName : valuesItems.keySet()) {
--- End diff --

Just a style thing, really, but I believe this method could be just 
`valuesItems.forEach(this::setValues)`.


---


[jira] [Commented] (JENA-1578) SPARQL VALUES for ParameterizedSparqlString

2018-07-27 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/JENA-1578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16559905#comment-16559905
 ] 

ASF GitHub Bot commented on JENA-1578:
--

Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/449#discussion_r205813451
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java ---
@@ -1734,4 +1740,243 @@ public String toString() {
 }
 
 }
+
+/**
+ * Assign a varName with a multiple items and whether to include
+ * parenthesis.
+ *
+ * @param varName
+ * @param items
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, Collection 
items, boolean isParenthesisNeeded) {
+this.valuesReplacements.put(varName, new ValueReplacement(varName, 
items, isParenthesisNeeded));
+}
+
+/**
+ * Assign a varName with a multiple items.
+ * Can be used to assign multiple values to a single variable or single
+ * value to multiple variables (if using a List) in the SPARQL 
query.
+ * See setGroupedValues to assign multiple values to multiple 
variables.
+ *
+ * @param varName
+ * @param items
+ */
+public void setValues(String varName, Collection 
items) {
+setValues(varName, items, false);
+}
+
+/**
+ * Assign a varName with a single item and whether to include 
parenthesis.
+ *
+ * @param varName
+ * @param item
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, RDFNode item, boolean 
isParenthesisNeeded) {
+setValues(varName, Arrays.asList(item), isParenthesisNeeded);
+}
+
+/**
+ * Assign a varName with a single item.
+ *
+ * @param varName
+ * @param item
+ */
+public void setValues(String varName, RDFNode item) {
+setValues(varName, Arrays.asList(item), false);
+}
+
+/**
+ * Sets a map of varNames and their items.
+ *
+ * @param valuesItems
+ */
+public void setValues(Map> 
valuesItems) {
+for (String varName : valuesItems.keySet()) {
+Collection items = valuesItems.get(varName);
+setValues(varName, items);
+}
+}
+
+/**
+ * All varNames in the map will use the same approach to parenthesis.
+ *
+ * @param valuesItems
+ * @param isParenthesisNeeded
+ */
+public void setValues(Map> 
valuesItems, Boolean isParenthesisNeeded) {
+for (String varName : valuesItems.keySet()) {
+Collection items = valuesItems.get(varName);
+setValues(varName, items, isParenthesisNeeded);
--- End diff --

Similarly, `valuesItems.forEach((varName, item)->setValues(varName, items, 
isParenthesisNeeded))`, and the same below.


> SPARQL VALUES for ParameterizedSparqlString
> ---
>
> Key: JENA-1578
> URL: https://issues.apache.org/jira/browse/JENA-1578
> Project: Apache Jena
>  Issue Type: New Feature
>  Components: ARQ
>Affects Versions: Jena 3.8.0
>Reporter: Greg Albiston
>Priority: Minor
>
> ParameterizedSparqlString provides an API for substituting variables within 
> SPARQL queries with bound values. It does not support the SPARQL VALUES 
> keyword which allows multiple values to be specified. The VALUES syntax 
> supports multiple values for a single variable, sets of values for multiple 
> variables and multiple sets of values for multiple values.
> Inquiry on 24/07/18 the mailing list about this feature. Patch is forthcoming.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] jena pull request #449: JENA-1578

2018-07-27 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/449#discussion_r205813451
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java ---
@@ -1734,4 +1740,243 @@ public String toString() {
 }
 
 }
+
+/**
+ * Assign a varName with a multiple items and whether to include
+ * parenthesis.
+ *
+ * @param varName
+ * @param items
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, Collection 
items, boolean isParenthesisNeeded) {
+this.valuesReplacements.put(varName, new ValueReplacement(varName, 
items, isParenthesisNeeded));
+}
+
+/**
+ * Assign a varName with a multiple items.
+ * Can be used to assign multiple values to a single variable or single
+ * value to multiple variables (if using a List) in the SPARQL 
query.
+ * See setGroupedValues to assign multiple values to multiple 
variables.
+ *
+ * @param varName
+ * @param items
+ */
+public void setValues(String varName, Collection 
items) {
+setValues(varName, items, false);
+}
+
+/**
+ * Assign a varName with a single item and whether to include 
parenthesis.
+ *
+ * @param varName
+ * @param item
+ * @param isParenthesisNeeded
+ */
+public void setValues(String varName, RDFNode item, boolean 
isParenthesisNeeded) {
+setValues(varName, Arrays.asList(item), isParenthesisNeeded);
+}
+
+/**
+ * Assign a varName with a single item.
+ *
+ * @param varName
+ * @param item
+ */
+public void setValues(String varName, RDFNode item) {
+setValues(varName, Arrays.asList(item), false);
+}
+
+/**
+ * Sets a map of varNames and their items.
+ *
+ * @param valuesItems
+ */
+public void setValues(Map> 
valuesItems) {
+for (String varName : valuesItems.keySet()) {
+Collection items = valuesItems.get(varName);
+setValues(varName, items);
+}
+}
+
+/**
+ * All varNames in the map will use the same approach to parenthesis.
+ *
+ * @param valuesItems
+ * @param isParenthesisNeeded
+ */
+public void setValues(Map> 
valuesItems, Boolean isParenthesisNeeded) {
+for (String varName : valuesItems.keySet()) {
+Collection items = valuesItems.get(varName);
+setValues(varName, items, isParenthesisNeeded);
--- End diff --

Similarly, `valuesItems.forEach((varName, item)->setValues(varName, items, 
isParenthesisNeeded))`, and the same below.


---


[GitHub] jena pull request #449: JENA-1578

2018-07-27 Thread GregAlbiston
GitHub user GregAlbiston opened a pull request:

https://github.com/apache/jena/pull/449

JENA-1578

- Subclass ValueReplacement and methods added to allow substitution of 
varNames with collections of RDFNodes. This is used in SPARQL queries to 
provide inline data with the VALUES keyword.
- Supports multiple values for a single variable, sets of values for 
multiple variables and multiple sets of values for multiple values.
- Optional inclusion of parenthesis for the first two cases.
- Tests included for use cases.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/GregAlbiston/jena query-value-replacement

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/449.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #449


commit 27695b93b7454b3948cc623cff788a18942a66e2
Author: Greg Albiston 
Date:   2018-07-27T14:05:52Z

ARQ:Query:ParameterizedSparqlString
- Subclass ValueReplacement and methods added to allow substitution of 
varNames with collections of RDFNodes. This is used in SPARQL queries to 
provide inline data with the VALUES keyword.
- Tests included for use cases.




---


[jira] [Commented] (JENA-1578) SPARQL VALUES for ParameterizedSparqlString

2018-07-27 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/JENA-1578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16559810#comment-16559810
 ] 

ASF GitHub Bot commented on JENA-1578:
--

GitHub user GregAlbiston opened a pull request:

https://github.com/apache/jena/pull/449

JENA-1578

- Subclass ValueReplacement and methods added to allow substitution of 
varNames with collections of RDFNodes. This is used in SPARQL queries to 
provide inline data with the VALUES keyword.
- Supports multiple values for a single variable, sets of values for 
multiple variables and multiple sets of values for multiple values.
- Optional inclusion of parenthesis for the first two cases.
- Tests included for use cases.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/GregAlbiston/jena query-value-replacement

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/449.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #449


commit 27695b93b7454b3948cc623cff788a18942a66e2
Author: Greg Albiston 
Date:   2018-07-27T14:05:52Z

ARQ:Query:ParameterizedSparqlString
- Subclass ValueReplacement and methods added to allow substitution of 
varNames with collections of RDFNodes. This is used in SPARQL queries to 
provide inline data with the VALUES keyword.
- Tests included for use cases.




> SPARQL VALUES for ParameterizedSparqlString
> ---
>
> Key: JENA-1578
> URL: https://issues.apache.org/jira/browse/JENA-1578
> Project: Apache Jena
>  Issue Type: New Feature
>  Components: ARQ
>Affects Versions: Jena 3.8.0
>Reporter: Greg Albiston
>Priority: Minor
>
> ParameterizedSparqlString provides an API for substituting variables within 
> SPARQL queries with bound values. It does not support the SPARQL VALUES 
> keyword which allows multiple values to be specified. The VALUES syntax 
> supports multiple values for a single variable, sets of values for multiple 
> variables and multiple sets of values for multiple values.
> Inquiry on 24/07/18 the mailing list about this feature. Patch is forthcoming.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (JENA-1578) SPARQL VALUES for ParameterizedSparqlString

2018-07-27 Thread Greg Albiston (JIRA)
Greg Albiston created JENA-1578:
---

 Summary: SPARQL VALUES for ParameterizedSparqlString
 Key: JENA-1578
 URL: https://issues.apache.org/jira/browse/JENA-1578
 Project: Apache Jena
  Issue Type: New Feature
  Components: ARQ
Affects Versions: Jena 3.8.0
Reporter: Greg Albiston


ParameterizedSparqlString provides an API for substituting variables within 
SPARQL queries with bound values. It does not support the SPARQL VALUES keyword 
which allows multiple values to be specified. The VALUES syntax supports 
multiple values for a single variable, sets of values for multiple variables 
and multiple sets of values for multiple values.

Inquiry on 24/07/18 the mailing list about this feature. Patch is forthcoming.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)