[jira] [Commented] (JENA-1502) SPARQL extensions for processing CSV, XML, JSON and remote data

2018-03-14 Thread Andy Seaborne (JIRA)

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

Andy Seaborne commented on JENA-1502:
-

Just on JSON numbers -> RDF:

v3.7.0 will have JS functions and the conversion from JS to RDF for the 
function result, tries to narrow the number to integer if possible:

https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/sparql/function/js/NV.java


> SPARQL extensions for processing CSV, XML, JSON and remote data
> ---
>
> Key: JENA-1502
> URL: https://issues.apache.org/jira/browse/JENA-1502
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ
>Affects Versions: Jena 3.6.0
>Reporter: Claus Stadler
>Priority: Major
>
> Many systems have been built so far for transforming heterogeneous data - 
> most prominently CSV, XML and JSON) to RDF.
> As it turns out, with a few extensions to ARQ, Jena becomes (at least for me) 
> an extremely convenient tool for this task.
> To clarify our point, for a project we have to convert several (open) 
> datasets, and we came up with a solution where we just have to execute a 
> sequence of SPARQL queries making use of our ARQ extensions.
> In [this 
> repository|https://github.com/QROWD/QROWD-RDF-Data-Integration/tree/master/datasets/1046-1051]
>  there are sub folders with JSON datasets, and the conversion is just a 
> matter of running the SPARQL queries in the files 
> [workloads.sparql|https://github.com/QROWD/QROWD-RDF-Data-Integration/blob/master/datasets/1046-1051/workloads.sparql]
>  (which adds triples describing workloads into a jena in-memory dataset) and 
> [process.sparql|https://github.com/QROWD/QROWD-RDF-Data-Integration/blob/master/datasets/1046-1051/process.sparql]
>  (which processes all workloads in that dataset and inserts triples into a 
> (named) result graph). We created a [thin command line 
> wrapper|https://github.com/SmartDataAnalytics/Sparqlintegrate] to 
> conveniently run these conversions.
> An example of these extension functions:
> {code:sql}
> # Add labels of train / bus stops
> INSERT {
>   GRAPH eg:result { ?s rdfs:label ?l }
> }
> WHERE {
>   # Magic property to fetch the text (at present always a string) of some URL
>url:text ?src .
>   # Parse into a literal of JSON datatype
>   BIND(STRDT(?src, xsd:json) AS ?o)
>   # Access a JSON array attribute
>   BIND(json:path(?o, "$.stopNames") AS ?stopNames)
>   # Create bindings for each element in the JSON document
>   ?stopNames json:unnest (?l ?i) .
>   # An ordinary join with existing data
>   GRAPH ?x { ?s eg:stopId ?i }
> }
> {code}
> In fact, these SPARQL ARQ extensions would enable any Jena-based project to 
> perform such integration tasks - and for instance one could already start a 
> Fuseki  in order to play around with conversions in a Web interface.
> * Is there interest to integrate our ARQ [SPARQL extension 
> functions|https://github.com/SmartDataAnalytics/jena-sparql-api/tree/develop/jena-sparql-api-sparql-ext]
>  into Jena? If so, what would we have to do and where (which existing or new 
> jena module) would be the most appropriate place?
> We are also open to discussion and changes on what exactly the signatures of 
> these extension functions should look like. For instance, right now we use 
> two custom datatypes, xsd:json and xsd:xml which obviously should be replaced 
> by better IRIs.
> * Maybe the functionality of running files containing sequences of SPARQL 
> queries from the command line could also be added to Jena directly - as I 
> think there is no magic outside the scope of Jena to it.



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


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

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

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

ASF GitHub Bot commented on JENA-632:
-

GitHub user afs opened a pull request:

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

JENA-632: Conversion of Nodes to JsonValues.



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

$ git pull https://github.com/afs/jena node2json

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

https://github.com/apache/jena/pull/383.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 #383


commit 2dd4418a2271e980511bbd6382c37f5130aa6e3a
Author: Andy Seaborne 
Date:   2018-03-13T17:01:52Z

Towards JENA-632: Conversion of Nodes to JsonValues.




> 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-1502) SPARQL extensions for processing CSV, XML, JSON and remote data

2018-03-14 Thread Andy Seaborne (JIRA)

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

Andy Seaborne commented on JENA-1502:
-

Hi Claus,

Certainly some interest from me at least.  I would have thought a separate 
module would be the way to go.

I see you've found [Jena system 
initialization|https://jena.apache.org/documentation/notes/system-initialization.html].
 Do the functions and property functions get tested elsewhere in the overall 
project?

Letting users know by emailing users@jena is probably a good thing to do 
because it can, sometimes, get suggestions/feedback/different perspectives 
sooner rather than later.



> SPARQL extensions for processing CSV, XML, JSON and remote data
> ---
>
> Key: JENA-1502
> URL: https://issues.apache.org/jira/browse/JENA-1502
> Project: Apache Jena
>  Issue Type: Improvement
>  Components: ARQ
>Affects Versions: Jena 3.6.0
>Reporter: Claus Stadler
>Priority: Major
>
> Many systems have been built so far for transforming heterogeneous data - 
> most prominently CSV, XML and JSON) to RDF.
> As it turns out, with a few extensions to ARQ, Jena becomes (at least for me) 
> an extremely convenient tool for this task.
> To clarify our point, for a project we have to convert several (open) 
> datasets, and we came up with a solution where we just have to execute a 
> sequence of SPARQL queries making use of our ARQ extensions.
> In [this 
> repository|https://github.com/QROWD/QROWD-RDF-Data-Integration/tree/master/datasets/1046-1051]
>  there are sub folders with JSON datasets, and the conversion is just a 
> matter of running the SPARQL queries in the files 
> [workloads.sparql|https://github.com/QROWD/QROWD-RDF-Data-Integration/blob/master/datasets/1046-1051/workloads.sparql]
>  (which adds triples describing workloads into a jena in-memory dataset) and 
> [process.sparql|https://github.com/QROWD/QROWD-RDF-Data-Integration/blob/master/datasets/1046-1051/process.sparql]
>  (which processes all workloads in that dataset and inserts triples into a 
> (named) result graph). We created a [thin command line 
> wrapper|https://github.com/SmartDataAnalytics/Sparqlintegrate] to 
> conveniently run these conversions.
> An example of these extension functions:
> {code:sql}
> # Add labels of train / bus stops
> INSERT {
>   GRAPH eg:result { ?s rdfs:label ?l }
> }
> WHERE {
>   # Magic property to fetch the text (at present always a string) of some URL
>url:text ?src .
>   # Parse into a literal of JSON datatype
>   BIND(STRDT(?src, xsd:json) AS ?o)
>   # Access a JSON array attribute
>   BIND(json:path(?o, "$.stopNames") AS ?stopNames)
>   # Create bindings for each element in the JSON document
>   ?stopNames json:unnest (?l ?i) .
>   # An ordinary join with existing data
>   GRAPH ?x { ?s eg:stopId ?i }
> }
> {code}
> In fact, these SPARQL ARQ extensions would enable any Jena-based project to 
> perform such integration tasks - and for instance one could already start a 
> Fuseki  in order to play around with conversions in a Web interface.
> * Is there interest to integrate our ARQ [SPARQL extension 
> functions|https://github.com/SmartDataAnalytics/jena-sparql-api/tree/develop/jena-sparql-api-sparql-ext]
>  into Jena? If so, what would we have to do and where (which existing or new 
> jena module) would be the most appropriate place?
> We are also open to discussion and changes on what exactly the signatures of 
> these extension functions should look like. For instance, right now we use 
> two custom datatypes, xsd:json and xsd:xml which obviously should be replaced 
> by better IRIs.
> * Maybe the functionality of running files containing sequences of SPARQL 
> queries from the command line could also be added to Jena directly - as I 
> think there is no magic outside the scope of Jena to it.



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


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

2018-03-14 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on JENA-632:
--

Commit 2dd4418a2271e980511bbd6382c37f5130aa6e3a in jena's branch 
refs/heads/master from [~andy.seaborne]
[ https://git-wip-us.apache.org/repos/asf?p=jena.git;h=2dd4418 ]

Towards JENA-632: Conversion of Nodes to JsonValues.

> 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-1507) GROUP BY and aggregates when there are no matching of the WHERE pattern.

2018-03-14 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on JENA-1507:
---

Commit 65d4e11692bd55175f2f489d56526f3fbcb3e669 in jena's branch 
refs/heads/master from [~andy.seaborne]
[ https://git-wip-us.apache.org/repos/asf?p=jena.git;h=65d4e11 ]

JENA-1507: Merge commit 'refs/pull/382/head' of https://github.com/apache/jena

This closes #382.


> GROUP BY and aggregates when there are no matching of the WHERE pattern.
> 
>
> Key: JENA-1507
> URL: https://issues.apache.org/jira/browse/JENA-1507
> Project: Apache Jena
>  Issue Type: Bug
>  Components: ARQ
>Affects Versions: Jena 3.6.0
>Reporter: Andy Seaborne
>Assignee: Andy Seaborne
>Priority: Major
> Fix For: 3.7.0
>
>
> There are two bugs in ARQs handling of grouping when there are no results in 
> the WHERE clause.
> When there is a GROUP BY, the outcome should be no rows. 
>  * JENA-1487
>  * [users list 
> discussion|https://lists.apache.org/thread.html/72c2045e639c589880619443beafec5be963733e0f9f0887e134d467@%3Cusers.jena.apache.org%3E]
> When there is no GROUP BY, no aggregates, and no pattern match, the result 
> should be one row of no columns; when there is no GROUP BY, the result is 
> always one row.  It returns zero rows (v3.6.0 and before).



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


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

2018-03-14 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on JENA-632:
--

Commit b1e89b2fd723b74b0f0160fbbf1a1acd44a44f8a in jena's branch 
refs/heads/master from [~andy.seaborne]
[ https://git-wip-us.apache.org/repos/asf?p=jena.git;h=b1e89b2 ]

JENA-632: Merge commit 'refs/pull/383/head' of https://github.com/apache/jena

This closes #383.


> 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] [Resolved] (JENA-1507) GROUP BY and aggregates when there are no matching of the WHERE pattern.

2018-03-14 Thread Andy Seaborne (JIRA)

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

Andy Seaborne resolved JENA-1507.
-
   Resolution: Fixed
Fix Version/s: 3.7.0

> GROUP BY and aggregates when there are no matching of the WHERE pattern.
> 
>
> Key: JENA-1507
> URL: https://issues.apache.org/jira/browse/JENA-1507
> Project: Apache Jena
>  Issue Type: Bug
>  Components: ARQ
>Affects Versions: Jena 3.6.0
>Reporter: Andy Seaborne
>Assignee: Andy Seaborne
>Priority: Major
> Fix For: 3.7.0
>
>
> There are two bugs in ARQs handling of grouping when there are no results in 
> the WHERE clause.
> When there is a GROUP BY, the outcome should be no rows. 
>  * JENA-1487
>  * [users list 
> discussion|https://lists.apache.org/thread.html/72c2045e639c589880619443beafec5be963733e0f9f0887e134d467@%3Cusers.jena.apache.org%3E]
> When there is no GROUP BY, no aggregates, and no pattern match, the result 
> should be one row of no columns; when there is no GROUP BY, the result is 
> always one row.  It returns zero rows (v3.6.0 and before).



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


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

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

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

ASF GitHub Bot commented on JENA-632:
-

Github user asfgit closed the pull request at:

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


> 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-14 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on JENA-632:
-

Github user afs commented on the issue:

https://github.com/apache/jena/pull/114
  
PR #383 - we can still change it based on experience.

BTW The grammar accepts the JSON field names in single quotes to make 
embedding in strings easier. It's a STRING1, either one `"` or one `'` 
delimiting (not mixed!).

I doubt it will need many 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)


[jira] [Commented] (JENA-1507) GROUP BY and aggregates when there are no matching of the WHERE pattern.

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

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

ASF GitHub Bot commented on JENA-1507:
--

Github user asfgit closed the pull request at:

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


> GROUP BY and aggregates when there are no matching of the WHERE pattern.
> 
>
> Key: JENA-1507
> URL: https://issues.apache.org/jira/browse/JENA-1507
> Project: Apache Jena
>  Issue Type: Bug
>  Components: ARQ
>Affects Versions: Jena 3.6.0
>Reporter: Andy Seaborne
>Assignee: Andy Seaborne
>Priority: Major
> Fix For: 3.7.0
>
>
> There are two bugs in ARQs handling of grouping when there are no results in 
> the WHERE clause.
> When there is a GROUP BY, the outcome should be no rows. 
>  * JENA-1487
>  * [users list 
> discussion|https://lists.apache.org/thread.html/72c2045e639c589880619443beafec5be963733e0f9f0887e134d467@%3Cusers.jena.apache.org%3E]
> When there is no GROUP BY, no aggregates, and no pattern match, the result 
> should be one row of no columns; when there is no GROUP BY, the result is 
> always one row.  It returns zero rows (v3.6.0 and before).



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


[jira] [Commented] (JENA-1507) GROUP BY and aggregates when there are no matching of the WHERE pattern.

2018-03-14 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on JENA-1507:
---

Commit 8a64ffeef483df37bcbd313ada28104a945d2027 in jena's branch 
refs/heads/master from [~andy.seaborne]
[ https://git-wip-us.apache.org/repos/asf?p=jena.git;h=8a64ffe ]

JENA-1507: No rows when no match if GROUP BY used


> GROUP BY and aggregates when there are no matching of the WHERE pattern.
> 
>
> Key: JENA-1507
> URL: https://issues.apache.org/jira/browse/JENA-1507
> Project: Apache Jena
>  Issue Type: Bug
>  Components: ARQ
>Affects Versions: Jena 3.6.0
>Reporter: Andy Seaborne
>Assignee: Andy Seaborne
>Priority: Major
> Fix For: 3.7.0
>
>
> There are two bugs in ARQs handling of grouping when there are no results in 
> the WHERE clause.
> When there is a GROUP BY, the outcome should be no rows. 
>  * JENA-1487
>  * [users list 
> discussion|https://lists.apache.org/thread.html/72c2045e639c589880619443beafec5be963733e0f9f0887e134d467@%3Cusers.jena.apache.org%3E]
> When there is no GROUP BY, no aggregates, and no pattern match, the result 
> should be one row of no columns; when there is no GROUP BY, the result is 
> always one row.  It returns zero rows (v3.6.0 and before).



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


[GitHub] jena pull request #383: JENA-632: Conversion of Nodes to JsonValues.

2018-03-14 Thread asfgit
Github user asfgit closed the pull request at:

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


---


[GitHub] jena pull request #381: Reformat QueryIterGroup; no test output from TestPar...

2018-03-14 Thread asfgit
Github user asfgit closed the pull request at:

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


---


[GitHub] jena pull request #382: JENA-1507: Fixes for aggregates when no WHERE match.

2018-03-14 Thread asfgit
Github user asfgit closed the pull request at:

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


---


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

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

https://github.com/apache/jena/pull/114
  
PR #383 - we can still change it based on experience.

BTW The grammar accepts the JSON field names in single quotes to make 
embedding in strings easier. It's a STRING1, either one `"` or one `'` 
delimiting (not mixed!).

I doubt it will need many tests.


---


[GitHub] jena pull request #383: JENA-632: Conversion of Nodes to JsonValues.

2018-03-14 Thread afs
GitHub user afs opened a pull request:

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

JENA-632: Conversion of Nodes to JsonValues.



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

$ git pull https://github.com/afs/jena node2json

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

https://github.com/apache/jena/pull/383.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 #383


commit 2dd4418a2271e980511bbd6382c37f5130aa6e3a
Author: Andy Seaborne 
Date:   2018-03-13T17:01:52Z

Towards JENA-632: Conversion of Nodes to JsonValues.




---


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

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

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

ASF GitHub Bot commented on JENA-632:
-

Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
FWIW, the output of the second test right now is

```
{ 
  "s" : "s" ,
  "p" : "" ,
  "o" : "def@en"
}
{ 
  "s" : "s" ,
  "p" : "" ,
  "o" : "abc"
}
{ 
  "s" : "s" ,
  "p" : "" ,
  "o" : "123^^http://www.w3.org/2001/XMLSchema#decimal;
}

```

@afs are you planning to send another PR when the draft is ready (it looks 
good to me as-is now :-) ) or would you prefer to include in this PR and 
Jena-632? It does seem to be related with/necessary for JENA-632. Happy to get 
updates to this branch :-)


> 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-14 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
FWIW, the output of the second test right now is

```
{ 
  "s" : "s" ,
  "p" : "" ,
  "o" : "def@en"
}
{ 
  "s" : "s" ,
  "p" : "" ,
  "o" : "abc"
}
{ 
  "s" : "s" ,
  "p" : "" ,
  "o" : "123^^http://www.w3.org/2001/XMLSchema#decimal;
}

```

@afs are you planning to send another PR when the draft is ready (it looks 
good to me as-is now :-) ) or would you prefer to include in this PR and 
Jena-632? It does seem to be related with/necessary for JENA-632. Happy to get 
updates to this branch :-)


---


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

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

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

ASF GitHub Bot commented on JENA-632:
-

Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
+1 for the current draft

I would use it 
[here](https://github.com/kinow/jena/blob/a948f300fb40701e49e83db9d03e5d83da8145f6/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java#L358
 and 
[here](https://github.com/kinow/jena/blob/a948f300fb40701e49e83db9d03e5d83da8145f6/jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java#L71).

This way instead of looking only at the literals, we'd have the output from 
the table above.

So far I have just two unit tests in my working copy

```java
@Test public void testExecJson() {
// JENA-632
Query query = QueryFactory.create("JSON { \"s\": ?s , \"p\": ?p , 
\"o\" : ?o } "
+ "WHERE { ?s ?p ?o }", Syntax.syntaxARQ);

try ( QueryExecution qexec = QueryExecutionFactory.create(query, m) 
) {
JsonArray jsonArray = qexec.execJson();
assertNotNull( jsonArray );
assertEquals(3, jsonArray.size());
}
}

@Test public void testExecJsonItems() {
// JENA-632
Model model = ModelFactory.createDefaultModel();
{
Resource r = model.createResource(AnonId.create("s"));
Property p = model.getProperty("");
RDFNode node = ResourceFactory.createTypedLiteral("123", 
XSDDatatype.XSDdecimal);
model.add(r, p, node);
r = model.createResource(AnonId.create("s"));
p = model.getProperty("");
node = ResourceFactory.createTypedLiteral("abc", 
XSDDatatype.XSDstring);
model.add(r, p, node);
r = model.createResource(AnonId.create("s"));
p = model.getProperty("");
node = ResourceFactory.createLangLiteral("def", "en");
model.add(r, p, node);
}
Query query = QueryFactory.create("JSON { \"s\": ?s , \"p\": ?p , 
\"o\" : ?o } "
+ "WHERE { ?s ?p ?o }", Syntax.syntaxARQ);

try ( QueryExecution qexec = QueryExecutionFactory.create(query, 
model) ) {
Iterator execJsonItems = qexec.execJsonItems();
while(execJsonItems.hasNext()) {
JsonObject next = execJsonItems.next();
System.out.println(next);
}
}
```

Where the second test is doing - more or less - the same example you 
provided in your previous comment. Once we have the conversion in place, I will 
update it to confirm I get what's expected.

Then after that I was thinking about quickly running with jacoco to see how 
much of this PR is being tested.


> 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-14 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/jena/pull/114
  
+1 for the current draft

I would use it 
[here](https://github.com/kinow/jena/blob/a948f300fb40701e49e83db9d03e5d83da8145f6/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java#L358
 and 
[here](https://github.com/kinow/jena/blob/a948f300fb40701e49e83db9d03e5d83da8145f6/jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java#L71).

This way instead of looking only at the literals, we'd have the output from 
the table above.

So far I have just two unit tests in my working copy

```java
@Test public void testExecJson() {
// JENA-632
Query query = QueryFactory.create("JSON { \"s\": ?s , \"p\": ?p , 
\"o\" : ?o } "
+ "WHERE { ?s ?p ?o }", Syntax.syntaxARQ);

try ( QueryExecution qexec = QueryExecutionFactory.create(query, m) 
) {
JsonArray jsonArray = qexec.execJson();
assertNotNull( jsonArray );
assertEquals(3, jsonArray.size());
}
}

@Test public void testExecJsonItems() {
// JENA-632
Model model = ModelFactory.createDefaultModel();
{
Resource r = model.createResource(AnonId.create("s"));
Property p = model.getProperty("");
RDFNode node = ResourceFactory.createTypedLiteral("123", 
XSDDatatype.XSDdecimal);
model.add(r, p, node);
r = model.createResource(AnonId.create("s"));
p = model.getProperty("");
node = ResourceFactory.createTypedLiteral("abc", 
XSDDatatype.XSDstring);
model.add(r, p, node);
r = model.createResource(AnonId.create("s"));
p = model.getProperty("");
node = ResourceFactory.createLangLiteral("def", "en");
model.add(r, p, node);
}
Query query = QueryFactory.create("JSON { \"s\": ?s , \"p\": ?p , 
\"o\" : ?o } "
+ "WHERE { ?s ?p ?o }", Syntax.syntaxARQ);

try ( QueryExecution qexec = QueryExecutionFactory.create(query, 
model) ) {
Iterator execJsonItems = qexec.execJsonItems();
while(execJsonItems.hasNext()) {
JsonObject next = execJsonItems.next();
System.out.println(next);
}
}
```

Where the second test is doing - more or less - the same example you 
provided in your previous comment. Once we have the conversion in place, I will 
update it to confirm I get what's expected.

Then after that I was thinking about quickly running with jacoco to see how 
much of this PR is being tested.


---