[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
If it does not make the release then - whatever! - there'll be another 
along soon!

I may be able to do some work on it after the release. I think I now 
understand it better and it makes a useful contribution to developing 
applications that want JSON simply.

Have fun in Japan!



> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
If it does not make the release then - whatever! - there'll be another 
along soon!

I may be able to do some work on it after the release. I think I now 
understand it better and it makes a useful contribution to developing 
applications that want JSON simply.

Have fun in Japan!



---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
Eval tests: https://gist.github.com/afs/9e57b705a0d53889606346f6723238ce

Framework : needs more tests!


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
Eval tests: https://gist.github.com/afs/9e57b705a0d53889606346f6723238ce

Framework : needs more tests!


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
@afs had a quick look at your gist and it looks good! I won't be able to 
have a proper look at it and to commit for the next ~8 hours. But feel free to 
commit to this branch and update the pull request too if you prefer :-)


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
@afs had a quick look at your gist and it looks good! I won't be able to 
have a proper look at it and to commit for the next ~8 hours. But feel free to 
commit to this branch and update the pull request too if you prefer :-)


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
And only started working again on this because you bumped this PR @ajs6f 
:-) learning a lot working on this ticket, and with JENA-1488, hope to start 
contributing back to Jena more now.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
And only started working again on this because you bumped this PR @ajs6f 
:-) learning a lot working on this ticket, and with JENA-1488, hope to start 
contributing back to Jena more now.


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
Will apply some of the changes tonight. But I'm afraid I may not be able to 
fix the serialization issues before this weekend when there might be a new 
release. This weekend I'll be in Japan for some weeks, so may have to complete 
working on the other comments by mid-April  


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
Will apply some of the changes tonight. But I'm afraid I may not be able to 
fix the serialization issues before this weekend when there might be a new 
release. This weekend I'll be in Japan for some weeks, so may have to complete 
working on the other comments by mid-April 😢 


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
Syntax tests: https://gist.github.com/afs/e069478ec6839267256b9eacd30aa2c4


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175923999
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
+#ifdef ARQ
--- End diff --

Consider it done. I'll copy it to a GitHub gist in case I need to test 
grammars again (not only in Jena... I believe I actually got it from some 
StackOverflow answer).


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
Syntax tests: https://gist.github.com/afs/e069478ec6839267256b9eacd30aa2c4


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175923748
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java ---
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.atlas.lib.Closeable;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/** A JSON iterator for JsonObject's, that wraps a QueryIterator, and a 
list
+ * of result variables.
+ */
+public class JsonIterator implements Iterator
+{
--- End diff --

Okeydokey @afs I noticed new classes are getting the new formatting 
applied, but wasn't sure about changing it in this PR or leaving as it was. 
This change started somewhere in 2015, so lots of old code formatting here.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175923999
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
+#ifdef ARQ
--- End diff --

Consider it done. I'll copy it to a GitHub gist in case I need to test 
grammars again (not only in Jena... I believe I actually got it from some 
StackOverflow answer).


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175923550
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java 
---
@@ -532,6 +535,18 @@ else if ( 
actualContentType.equals(WebContent.contentTypeJSON))
 }
 }
 
+@Override
+public JsonArray execJson()
+{
+throw new NotImplementedException("JSON queries not implemented 
for remote calls") ;
--- End diff --

Coincidentally, I noticed this [lang] class here too yesterday, and was 
going to replace by that Atlas class... but first I searched other occurrences, 
and I think somewhere in a sparql module it was being used too. So I thought it 
was OK. Happy to replace this one by the atlas module class. Consider it done 
in some hours.


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175923550
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java 
---
@@ -532,6 +535,18 @@ else if ( 
actualContentType.equals(WebContent.contentTypeJSON))
 }
 }
 
+@Override
+public JsonArray execJson()
+{
+throw new NotImplementedException("JSON queries not implemented 
for remote calls") ;
--- End diff --

Coincidentally, I noticed this [lang] class here too yesterday, and was 
going to replace by that Atlas class... but first I searched other occurrences, 
and I think somewhere in a sparql module it was being used too. So I thought it 
was OK. Happy to replace this one by the atlas module class. Consider it done 
in some hours.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175923748
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java ---
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.atlas.lib.Closeable;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/** A JSON iterator for JsonObject's, that wraps a QueryIterator, and a 
list
+ * of result variables.
+ */
+public class JsonIterator implements Iterator
+{
--- End diff --

Okeydokey @afs I noticed new classes are getting the new formatting 
applied, but wasn't sure about changing it in this PR or leaving as it was. 
This change started somewhere in 2015, so lots of old code formatting here.


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175922851
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
--- End diff --

Most likely. Will remove tonight.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175922851
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
--- End diff --

Most likely. Will remove tonight.


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175918594
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java ---
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.atlas.lib.Closeable;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/** A JSON iterator for JsonObject's, that wraps a QueryIterator, and a 
list
+ * of result variables.
+ */
+public class JsonIterator implements Iterator
+{
--- End diff --

I've been planning to offer a low-interruption plan for some large-scale 
reformatting later this spring, so no harm in leaving this.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175918594
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java ---
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.atlas.lib.Closeable;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/** A JSON iterator for JsonObject's, that wraps a QueryIterator, and a 
list
+ * of result variables.
+ */
+public class JsonIterator implements Iterator
+{
--- End diff --

I've been planning to offer a low-interruption plan for some large-scale 
reformatting later this spring, so no harm in leaving this.


---


[GitHub] jena issue #385: defined filters and tokenizers for ConfigurableAnalyzer

2018-03-20 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/385
  
Workflow doucmentation: 
https://cwiki.apache.org/confluence/display/JENA/Commit+Workflow+for+Github-ASF


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175909873
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -326,6 +361,46 @@ void AskQuery() : {}
   SolutionModifier()
 }
 
+#ifdef ARQ
+void JsonQuery() : {}
+{
+  JsonClause()
+  ( DatasetClause() )*
+  WhereClause()
+  SolutionModifier()
+}
+
+void JsonClause() : { Object o ; String s ; Token t; }
+{
+   { getQuery().setQueryJsonType() ; }
+  
+  s = String()
+  // PNAME_NS would eval true before COLON (default namescape) so we make 
sure we got what we were expecting
+  t = < PNAME_NS > {
+if ( ! t.image.equals(":") )
+  throwParseException("Prefix name expression not legal at this point 
: "+t.image, t.beginLine, t.beginColumn) ;
+  }
+  (
+o = Var() { getQuery().addResultVar((Var) o) ; 
getQuery().addJsonMapping(s, o) ; }
+  | o = String() { getQuery().addJsonMapping(s, o) ; }
+  | o = Number() { getQuery().addJsonMapping(s, o) ; }
+  )
+  (
+ s = String()
+t = < PNAME_NS > {
+  if ( ! t.image.equals(":") )
+throwParseException("Prefix name expression not legal at this 
point : "+t.image, t.beginLine, t.beginColumn) ;
+}
+(
+  o = Var() { getQuery().addResultVar((Var) o) ; 
getQuery().addJsonMapping(s, o) ; }
+| o = String() { getQuery().addJsonMapping(s, o) ; }
+| o = Number() { getQuery().addJsonMapping(s, o) ; }
+)
--- End diff --

Does not cover URIs, booleans or JSON null.

I tried `JSON { "F": "string" } WHERE {}` but got `[ {} ]` (one element, no 
object fields) - which does not look right to me.

A bunch of tests calling a common function like `test(String query, String 
jsonResult)` would help. e.g.

@Test public void json_query_01() { test("JSON { 'F': 'string' } WHERE 
{}", "{ [ 'F' : 'string ] }" ; }

`JsonValue` supports structural `.equals`.


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175912074
  
--- Diff: jena-arq/src/main/java/org/apache/jena/query/Query.java ---
@@ -515,6 +519,14 @@ public void addHavingCondition(Expr expr)
 havingExprs.add(expr) ;
 }
 
+// SELECT JSON
+
+public Map jsonMapping = new LinkedHashMap<>();
--- End diff --

I can't find any use of `jsonMapping` except serialization which would 
explain the lack of fields noted above.


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175915508
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/serializer/QuerySerializer.java 
---
@@ -142,7 +144,19 @@ public void visitAskResultForm(Query query)
 out.print("ASK") ;
 out.newline() ;
 }
-
+
+@Override
+public void visitJsonResultForm(Query query) {
+out.print("JSON {");
--- End diff --

More test suggestions: `testParse("JSON { "s": "FOO" , "p" : ?p , "o" : ?o 
} WHERE { }")` to parse to Q, serialize, reparse to Q2 and check Q.equals(Q2).

e.g.a new `org.apache.jena.sparql.syntax.TestJSONParsing`

`JSON { "s": "FOO" }` becomes `JSON { "s": FOO }`


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175910160
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -2176,6 +2251,19 @@ String String() : { Token t ; String lex ; }
 }
 }
 
+#ifdef ARQ
+Number Number() : { Token t ; Number number ; }
+{
+  (
+t = < INTEGER > { number = integerValue(t.image) ; }
+  | t = < DECIMAL > { number = doubleValue(t.image) ; }
--- End diff --

Any reason to exclude doubles?


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175912825
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java ---
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.atlas.lib.Closeable;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/** A JSON iterator for JsonObject's, that wraps a QueryIterator, and a 
list
+ * of result variables.
+ */
+public class JsonIterator implements Iterator
+{
--- End diff --

Feel free to reformat int same like `{` and no space before `;`.

(yes - a lot of code is not formatted but we seem to be heading that way).

Or leave for now and we can clean up new classes after merging.


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175906815
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
+#ifdef ARQ
--- End diff --

Please remove "main".


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175915508
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/serializer/QuerySerializer.java 
---
@@ -142,7 +144,19 @@ public void visitAskResultForm(Query query)
 out.print("ASK") ;
 out.newline() ;
 }
-
+
+@Override
+public void visitJsonResultForm(Query query) {
+out.print("JSON {");
--- End diff --

More test suggestions: `testParse("JSON { "s": "FOO" , "p" : ?p , "o" : ?o 
} WHERE { }")` to parse to Q, serialize, reparse to Q2 and check Q.equals(Q2).

e.g.a new `org.apache.jena.sparql.syntax.TestJSONParsing`

`JSON { "s": "FOO" }` becomes `JSON { "s": FOO }`


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175914165
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/serializer/QuerySerializer.java 
---
@@ -142,7 +144,19 @@ public void visitAskResultForm(Query query)
 out.print("ASK") ;
 out.newline() ;
 }
-
+
+@Override
+public void visitJsonResultForm(Query query) {
+out.print("JSON {");
--- End diff --

The `qparse` tool uses serialization (and it parses the result back again).


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175909873
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -326,6 +361,46 @@ void AskQuery() : {}
   SolutionModifier()
 }
 
+#ifdef ARQ
+void JsonQuery() : {}
+{
+  JsonClause()
+  ( DatasetClause() )*
+  WhereClause()
+  SolutionModifier()
+}
+
+void JsonClause() : { Object o ; String s ; Token t; }
+{
+   { getQuery().setQueryJsonType() ; }
+  
+  s = String()
+  // PNAME_NS would eval true before COLON (default namescape) so we make 
sure we got what we were expecting
+  t = < PNAME_NS > {
+if ( ! t.image.equals(":") )
+  throwParseException("Prefix name expression not legal at this point 
: "+t.image, t.beginLine, t.beginColumn) ;
+  }
+  (
+o = Var() { getQuery().addResultVar((Var) o) ; 
getQuery().addJsonMapping(s, o) ; }
+  | o = String() { getQuery().addJsonMapping(s, o) ; }
+  | o = Number() { getQuery().addJsonMapping(s, o) ; }
+  )
+  (
+ s = String()
+t = < PNAME_NS > {
+  if ( ! t.image.equals(":") )
+throwParseException("Prefix name expression not legal at this 
point : "+t.image, t.beginLine, t.beginColumn) ;
+}
+(
+  o = Var() { getQuery().addResultVar((Var) o) ; 
getQuery().addJsonMapping(s, o) ; }
+| o = String() { getQuery().addJsonMapping(s, o) ; }
+| o = Number() { getQuery().addJsonMapping(s, o) ; }
+)
--- End diff --

Does not cover URIs, booleans or JSON null.

I tried `JSON { "F": "string" } WHERE {}` but got `[ {} ]` (one element, no 
object fields) - which does not look right to me.

A bunch of tests calling a common function like `test(String query, String 
jsonResult)` would help. e.g.

@Test public void json_query_01() { test("JSON { 'F': 'string' } WHERE 
{}", "{ [ 'F' : 'string ] }" ; }

`JsonValue` supports structural `.equals`.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175911878
  
--- Diff: jena-arq/src/main/java/org/apache/jena/query/Query.java ---
@@ -515,6 +519,14 @@ public void addHavingCondition(Expr expr)
 havingExprs.add(expr) ;
 }
 
+// SELECT JSON
+
+public Map jsonMapping = new LinkedHashMap<>();
--- End diff --

Preference - don't expose data structures which can be modified. Either 
return a copy (if it is not called repeatedly) or with a 
`Collections.unmodifiableMap` wrapper.



> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175913506
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java 
---
@@ -532,6 +535,18 @@ else if ( 
actualContentType.equals(WebContent.contentTypeJSON))
 }
 }
 
+@Override
+public JsonArray execJson()
+{
+throw new NotImplementedException("JSON queries not implemented 
for remote calls") ;
--- End diff --

Minor: for better or worse, we have 
`org.apache.jena.atlas.lib.NotImplemented`.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175913506
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java 
---
@@ -532,6 +535,18 @@ else if ( 
actualContentType.equals(WebContent.contentTypeJSON))
 }
 }
 
+@Override
+public JsonArray execJson()
+{
+throw new NotImplementedException("JSON queries not implemented 
for remote calls") ;
--- End diff --

Minor: for better or worse, we have 
`org.apache.jena.atlas.lib.NotImplemented`.


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175914165
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/serializer/QuerySerializer.java 
---
@@ -142,7 +144,19 @@ public void visitAskResultForm(Query query)
 out.print("ASK") ;
 out.newline() ;
 }
-
+
+@Override
+public void visitJsonResultForm(Query query) {
+out.print("JSON {");
--- End diff --

The `qparse` tool uses serialization (and it parses the result back again).


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175912074
  
--- Diff: jena-arq/src/main/java/org/apache/jena/query/Query.java ---
@@ -515,6 +519,14 @@ public void addHavingCondition(Expr expr)
 havingExprs.add(expr) ;
 }
 
+// SELECT JSON
+
+public Map jsonMapping = new LinkedHashMap<>();
--- End diff --

I can't find any use of `jsonMapping` except serialization which would 
explain the lack of fields noted above.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175915889
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/QueryTransformOps.java
 ---
@@ -217,6 +217,11 @@ public void visitAskResultForm(Query query) {
 newQuery.setQueryAskType();
--- End diff --

Transforming `JSON { ... }` can be left for another ticket.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175910819
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
--- End diff --

This is not in master.jj nowadays. Is this from the early forking?


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175906815
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
+#ifdef ARQ
--- End diff --

Please remove "main".


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175910819
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -99,7 +99,42 @@ import org.apache.jena.sparql.core.Quad ;
 #endif
 
 public class CLASS extends PARSERBASE
-{}
+{
+boolean allowAggregatesInExpressions = false ;
--- End diff --

This is not in master.jj nowadays. Is this from the early forking?


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175915889
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/syntax/syntaxtransform/QueryTransformOps.java
 ---
@@ -217,6 +217,11 @@ public void visitAskResultForm(Query query) {
 newQuery.setQueryAskType();
--- End diff --

Transforming `JSON { ... }` can be left for another ticket.


---


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175910160
  
--- Diff: jena-arq/Grammar/master.jj ---
@@ -2176,6 +2251,19 @@ String String() : { Token t ; String lex ; }
 }
 }
 
+#ifdef ARQ
+Number Number() : { Token t ; Number number ; }
+{
+  (
+t = < INTEGER > { number = integerValue(t.image) ; }
+  | t = < DECIMAL > { number = doubleValue(t.image) ; }
--- End diff --

Any reason to exclude doubles?


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175912825
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java ---
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.atlas.lib.Closeable;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/** A JSON iterator for JsonObject's, that wraps a QueryIterator, and a 
list
+ * of result variables.
+ */
+public class JsonIterator implements Iterator
+{
--- End diff --

Feel free to reformat int same like `{` and no space before `;`.

(yes - a lot of code is not formatted but we seem to be heading that way).

Or leave for now and we can clean up new classes after merging.


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread afs
Github user afs commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175911878
  
--- Diff: jena-arq/src/main/java/org/apache/jena/query/Query.java ---
@@ -515,6 +519,14 @@ public void addHavingCondition(Expr expr)
 havingExprs.add(expr) ;
 }
 
+// SELECT JSON
+
+public Map jsonMapping = new LinkedHashMap<>();
--- End diff --

Preference - don't expose data structures which can be modified. Either 
return a copy (if it is not called repeatedly) or with a 
`Collections.unmodifiableMap` wrapper.



---


[GitHub] jena issue #385: defined filters and tokenizers for ConfigurableAnalyzer

2018-03-20 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/385
  
To be clear, what is here at Github is essentially a read-only mirror. 
What's at Apache is the real deal. We've talked about reversing that mirroring 
relationship (so that we could merge PRs here at Github) but there are other 
consequences to so doing, mostly involving integrations with other services 
like Jira.


---


[GitHub] jena issue #385: defined filters and tokenizers for ConfigurableAnalyzer

2018-03-20 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/385
  
Hey, @xristy, you want to push instead to the `master` branch at Apache:

https://git-wip-us.apache.org/repos/asf/jena.git


---


[GitHub] jena issue #385: defined filters and tokenizers for ConfigurableAnalyzer

2018-03-20 Thread xristy
Github user xristy commented on the issue:

https://github.com/apache/jena/pull/385
  
I'm guessing that I'm supposed to perform the pull request but when I try 
to push to apache/jena master on github my github user, xristy, doesn't have 
permission for apache/jena.git.

What is the proper procedure?


---


[jira] [Commented] (JENA-1239) fuseki should not autocreate a config.ttl file if a configuration file is specified on the command line

2018-03-20 Thread Andy Seaborne (JIRA)

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

Andy Seaborne commented on JENA-1239:
-

[~danpritts] -- indeed.  As a project, Apache Jena works on contributions from 
individuals who are volunteers.

Would you like to provide a patch?

Did you try Fuseki basic? That is a pure server, no on-disk server state.

> fuseki should not autocreate a config.ttl file if a configuration file is 
> specified on the command line
> ---
>
> Key: JENA-1239
> URL: https://issues.apache.org/jira/browse/JENA-1239
> Project: Apache Jena
>  Issue Type: Bug
>  Components: Fuseki
>Affects Versions: Fuseki 2.4.0
> Environment: RHEL6, openjdk 1.8.0_101
>Reporter: Dan Pritts
>Priority: Minor
>
> I use the command line to specify a configuration file when I start fuseki.  
> My config is not in $FUSEKI_BASE/config.ttl
> Even so, fuseki autocreates a config.ttl in $FUSEKI_BASE if one does not 
> already exist.  
> This could easily be confusing to the next person who comes along (heck, it 
> confused me when rolled back around to fuseki today after being away from it 
> for a few weeks).  So, I propose that you add a check (do I have a config 
> file?) before you create the default config.ttl.  
> thanks



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


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
Replied @afs `s last comment, and also rebased the code. Even though it's 
rebased, there's quite a few commits... let me know if I should squash the 
commits or if it's preferable to leave the commit history :-) ready to review, 
take 3?


> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
Replied @afs `s last comment, and also rebased the code. Even though it's 
rebased, there's quite a few commits... let me know if I should squash the 
commits or if it's preferable to leave the commit history :-) ready to review, 
take 3?


---


[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.

2018-03-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

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

https://github.com/apache/jena/pull/114#discussion_r175680295
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/query/ResultSetFormatter.java ---
@@ -516,6 +520,41 @@ static public void outputAsJSON(boolean booleanResult)
 static public void outputAsJSON(OutputStream outStream, boolean 
booleanResult)
 { output(outStream, booleanResult, SPARQLResultSetJSON) ; }
 
+/** Output an iterator of JSON values.
+*
+* @param outStream output stream
+* @param jsonItems The JSON values
+*/
+   public static void outputAsJSON(OutputStream outStream, 
Iterator jsonItems)
+   {
+   JSWriter jWriter = new JSWriter(outStream) ;
+   jWriter.startArray() ;
+   jWriter.startOutput() ;
+   while (jsonItems.hasNext()) 
+   {
+   jWriter.startObject() ;
+   JsonObject jsonItem = jsonItems.next() ;
+   for (Entry entry: jsonItem.entrySet()) 
+   {
+   JsonValue value = entry.getValue() ;
+   String val = "";
+   if (value.isString()) {
--- End diff --

>"outputAsJSON" is a bit confusing because the other functions of the same 
name produce SPARQL results in JSON. How about "output"?

Sounds good to me. Done!

>In the code, numbers still come out as strings.

Oh, d'oh me! You raised the issue, I updated the code but not the part that 
writes it back to the user. And even added a test that was testing it was 
getting "123" and "true" in the output. Fixed the test, and thanks heaps for 
the code snippet! Otherwise I'd be scratching my head and thinking how to use 
JSWriter.

Updated, and uploaded the data below

```
@prefix :   .

:s :p 123 .
:s :p "abc" .
:s :p "def"@en .
```

Then queried `JSON { "s": ?s , "p": ?p , "o" : ?o } WHERE { ?s ?p ?o }`. 
Screen shot below with the `123` value - hopefully - correctly displayed! 
:man_dancing: :tada: 


![screenshot_2018-03-20_21-02-30](https://user-images.githubusercontent.com/304786/37642710-116538c6-2c83-11e8-95e4-d14a28e57a5a.png)



> Generate JSON from SPARQL directly.
> ---
>
> Key: JENA-632
> URL: https://issues.apache.org/jira/browse/JENA-632
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ, Fuseki
>Reporter: Andy Seaborne
>Assignee: Bruno P. Kinoshita
>Priority: Minor
>  Labels: java, javacc
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The capability to generate JSON directly from a SPARQL (or extended SPARQL) 
> query would enable the creation of JSON data API over published linked data.
> This project would cover:
> # Design and publication of a design.
> # Refinement of design based on community feed
> # Implementation, including testing.
> # Refinement of implementation based on community feed
> Skills required: Java, some parser work, design and discussion with the user 
> community, basic understanding of HTTP and content negotiation.



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


[GitHub] jena pull request #114: JENA-632: Generate JSON from SPARQL directly

2018-03-20 Thread kinow
Github user kinow commented on a diff in the pull request:

https://github.com/apache/jena/pull/114#discussion_r175680295
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/query/ResultSetFormatter.java ---
@@ -516,6 +520,41 @@ static public void outputAsJSON(boolean booleanResult)
 static public void outputAsJSON(OutputStream outStream, boolean 
booleanResult)
 { output(outStream, booleanResult, SPARQLResultSetJSON) ; }
 
+/** Output an iterator of JSON values.
+*
+* @param outStream output stream
+* @param jsonItems The JSON values
+*/
+   public static void outputAsJSON(OutputStream outStream, 
Iterator jsonItems)
+   {
+   JSWriter jWriter = new JSWriter(outStream) ;
+   jWriter.startArray() ;
+   jWriter.startOutput() ;
+   while (jsonItems.hasNext()) 
+   {
+   jWriter.startObject() ;
+   JsonObject jsonItem = jsonItems.next() ;
+   for (Entry entry: jsonItem.entrySet()) 
+   {
+   JsonValue value = entry.getValue() ;
+   String val = "";
+   if (value.isString()) {
--- End diff --

>"outputAsJSON" is a bit confusing because the other functions of the same 
name produce SPARQL results in JSON. How about "output"?

Sounds good to me. Done!

>In the code, numbers still come out as strings.

Oh, d'oh me! You raised the issue, I updated the code but not the part that 
writes it back to the user. And even added a test that was testing it was 
getting "123" and "true" in the output. Fixed the test, and thanks heaps for 
the code snippet! Otherwise I'd be scratching my head and thinking how to use 
JSWriter.

Updated, and uploaded the data below

```
@prefix :   .

:s :p 123 .
:s :p "abc" .
:s :p "def"@en .
```

Then queried `JSON { "s": ?s , "p": ?p , "o" : ?o } WHERE { ?s ?p ?o }`. 
Screen shot below with the `123` value - hopefully - correctly displayed! 
:man_dancing: :tada: 


![screenshot_2018-03-20_21-02-30](https://user-images.githubusercontent.com/304786/37642710-116538c6-2c83-11e8-95e4-d14a28e57a5a.png)



---