You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by confidencesun <gi...@git.apache.org> on 2015/07/22 09:12:14 UTC

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

GitHub user confidencesun opened a pull request:

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

    Merge confidencesun/master (Merged from JENA-491) for the first half part of GSoC 2015 project

    

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

    $ git pull https://github.com/confidencesun/jena master

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

    https://github.com/apache/jena/pull/89.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 #89
    
----
commit 5237c71aef40b7e1be24a62f407ab3f0ae550b41
Author: confidencesun <co...@gmail.com>
Date:   2015-03-21T16:34:54Z

    a demo for JENA-491

commit 15c9b132964e331132225661da4cc8348d02418c
Author: confidencesun <co...@gmail.com>
Date:   2015-05-24T08:39:47Z

    Merge pull request #1 from apache/master
    
    pull master to  begin

commit ee075b7b201f80c6ed421210971952f139a8ccaf
Author: confidencesun <co...@gmail.com>
Date:   2015-05-26T13:24:15Z

    Merge pull request #3 from apache/master
    
    sych master 20150526

commit 3f163bff6b1d4020c0f2a77321bbb47baf743ebb
Author: confidencesun <co...@gmail.com>
Date:   2015-05-26T23:38:58Z

    delete JENA-491 example code

commit ca1dc7bbcce401dea0908f22b3a4209d562716a0
Author: confidencesun <co...@gmail.com>
Date:   2015-05-26T23:47:00Z

    Merge pull request #4 from confidencesun/master
    
    delete JENA-491 example code

commit 2d09a7dfe84539ecdafc9f99247019d0ddeefd5e
Author: confidencesun <co...@gmail.com>
Date:   2015-06-11T14:56:15Z

    create new Template for SPARQL_11

commit 07c8b98dbafbf2ea12ee3f6df6816e8edda93650
Author: confidencesun <co...@gmail.com>
Date:   2015-06-12T03:03:13Z

    rollback FmtTemplate, in order to build success for TS_Scripted

commit 2cb175d2305c02582eb24629d18d06bdc53ae4ba
Author: confidencesun <co...@gmail.com>
Date:   2015-06-15T10:12:10Z

    reimplement Template, that does not affect the SPARQL 1.0 parser

commit a8b0d53e83a39357f6d35763494ecfa447826b51
Author: confidencesun <co...@gmail.com>
Date:   2015-06-18T03:21:34Z

    The SPARQL 1.1 parser (like the SPARQL 1.0 parser) are now unchanged.

commit c475249148792da2148cd9ec9976312516ed1d11
Author: confidencesun <co...@gmail.com>
Date:   2015-06-18T08:44:33Z

    refactor ConstructTemplate() to make ARQ for constructing quards similar
    to that for triples.

commit 5076b1ed0844d0a1e7c57b539b64af3d831ee039
Author: confidencesun <co...@gmail.com>
Date:   2015-06-19T08:22:38Z

    new QueryExecution operations: execConstrucQuads(),
    execConstructDataset()

commit d0ce13b2587905859c9ed854f5114b8c86c2125c
Author: confidencesun <co...@gmail.com>
Date:   2015-06-19T08:53:07Z

    add licence info for ExampleConstructQuads; retain QuadAcc unchanged

commit d58625693e9439ee0c9164b56993b44f34c2a383
Author: confidencesun <co...@gmail.com>
Date:   2015-06-21T13:16:18Z

    fix bugs for default graphs; add some examples in
    ExampleConstructQuads.java

commit 5e56c1f2b0e2b0b2f6a1e7fda9fe17b6254176da
Author: confidencesun <co...@gmail.com>
Date:   2015-06-21T13:28:15Z

    commit ExampleConstructQuads.java

commit 1348bf5498543f747f1b4707f011a46bfcca90e1
Author: confidencesun <co...@gmail.com>
Date:   2015-07-22T06:16:15Z

    Merge pull request #8 from apache/master
    
    pull master up to date

commit e58b62cb2e288cc71754776e00179cd011ecdf5f
Author: confidencesun <co...@gmail.com>
Date:   2015-07-22T07:07:10Z

    Merge remote-tracking branch 'origin/JENA-491'

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by confidencesun <gi...@git.apache.org>.
Github user confidencesun commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35834150
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/syntax/Template.java ---
    @@ -52,14 +63,43 @@ public Template(BasicPattern bgp)
     //    public void addTriplePath(int index, TriplePath path)
     //    { throw new ARQException("Triples-only collector") ; }
     
    -
    -    public BasicPattern getBGP()        { return bgp ; }
    -    public List<Triple> getTriples()    { return bgp.getList() ; }
    +    public BasicPattern getBGP()
    +    { 
    +    	if (this.bgp != null){
    +    		return this.bgp;
    +    	}
    +    	BasicPattern bgp = new BasicPattern();
    +    	for(Quad q: qp.getQuads()){
    +    		bgp.add(q.asTriple());
    +    	}
    +    	return bgp;
    +    }
    +    public List<Triple> getTriples()
    +    { 
    +    	if(this.bgp != null){
    +    		return this.bgp.getList();
    +    	}
    +    	List<Triple> triples = new ArrayList<Triple>();
    +    	for(Quad q: qp.getQuads()){
    +    		triples.add(q.asTriple());
    +    	}
    +    	return triples;
    +    }
    +    public List<Quad> getQuads() {
    +    	if( this.bgp != null){
    +    		List<Quad> quads = new ArrayList<Quad>();
    +    		for(Triple triple: this.bgp.getList()){
    +    			quads.add( new Quad( Quad.defaultGraphNodeGenerated, triple ) ); 
    --- End diff --
    
    What do you mean by streams? Any examples?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35198277
  
    --- Diff: jena-arq/Grammar/arq.jj ---
    @@ -500,6 +498,27 @@ void QuadsNotTriples(QuadAccSink acc) : {Node gn ; Node prev = acc.getGraph() ;
         <RBRACE>
         { setAccGraph(acc, prev) ; }
     }
    +void ConstructQuads(QuadAcc acc) : {}
    +{
    +    (TriplesTemplate(acc))?
    +    (
    +       ConstructQuadsNotTriples(acc)
    +       (<DOT>)?
    +       (TriplesTemplate(acc))?
    +    )*
    +}
    +void ConstructQuadsNotTriples(QuadAccSink acc) : {Node gn = org.apache.jena.sparql.core.Quad.defaultGraphNodeGenerated ; Node prev = acc.getGraph() ; }
    +{
    --- End diff --
    
    No need to write the package name - add an import then this code can be shorter.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35870389
  
    --- Diff: jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
    @@ -0,0 +1,141 @@
    +/*
    + * 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 arq.examples.constructquads;
    +
    +import java.util.Iterator;
    +
    +import org.apache.jena.graph.Triple;
    +import org.apache.jena.query.Dataset;
    +import org.apache.jena.query.DatasetFactory;
    +import org.apache.jena.query.Query;
    +import org.apache.jena.query.QueryExecution;
    +import org.apache.jena.query.QueryExecutionFactory;
    +import org.apache.jena.query.QueryFactory;
    +import org.apache.jena.query.Syntax;
    +import org.apache.jena.rdf.model.Model;
    +import org.apache.jena.rdf.model.ModelFactory;
    +import org.apache.jena.rdf.model.Property;
    +import org.apache.jena.rdf.model.Resource;
    +import org.apache.jena.sparql.core.Quad;
    +import org.apache.jena.util.PrintUtil;
    +
    +public class ExampleConstructQuads {
    +	public static void main(String[] args) {
    +
    +		// create testing data :
    +		// 1) default graph data
    +		Model model = ModelFactory.createDefaultModel();
    +		Resource s = model.createResource("http://eg.com/s");
    +		Property p = model.createProperty("http://eg.com/p");
    +		Resource o = model.createResource("http://eg.com/o");
    +		model.add(s, p, o);
    +		Dataset dataset = DatasetFactory.create(model);
    +		// 2) named graph data
    +		Model model1 = ModelFactory.createDefaultModel();
    +		Resource s1 = model.createResource("http://eg.com/s1");
    +		Property p1 = model.createProperty("http://eg.com/p1");
    +		Resource o1 = model.createResource("http://eg.com/o1");
    +		model1.add(s1, p1, o1);
    +		dataset.addNamedModel("<http://eg.com/g1>", model1);
    +
    +
    +		// construct named graph
    +		System.out.println("construct named graph:");
    +		String queryString = "CONSTRUCT { GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
    --- End diff --
    
    You may have them turned off. Check Preferences > Java > Compiler > Errors/Warnings. There is a serried host of settings there and amongst them, under Code Style, you will find `Resource not managed via try-with-resource (1.7 or higher)`. It's worth turning on. In any event, even without the warning, `try-with-resource` is the right thing to do.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35198083
  
    --- Diff: jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
    @@ -0,0 +1,141 @@
    +/*
    + * 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 arq.examples.constructquads;
    +
    +import java.util.Iterator;
    +
    +import org.apache.jena.graph.Triple;
    +import org.apache.jena.query.Dataset;
    +import org.apache.jena.query.DatasetFactory;
    +import org.apache.jena.query.Query;
    +import org.apache.jena.query.QueryExecution;
    +import org.apache.jena.query.QueryExecutionFactory;
    +import org.apache.jena.query.QueryFactory;
    +import org.apache.jena.query.Syntax;
    +import org.apache.jena.rdf.model.Model;
    +import org.apache.jena.rdf.model.ModelFactory;
    +import org.apache.jena.rdf.model.Property;
    +import org.apache.jena.rdf.model.Resource;
    +import org.apache.jena.sparql.core.Quad;
    +import org.apache.jena.util.PrintUtil;
    +
    +public class ExampleConstructQuads {
    +	public static void main(String[] args) {
    +
    +		// create testing data :
    +		// 1) default graph data
    +		Model model = ModelFactory.createDefaultModel();
    +		Resource s = model.createResource("http://eg.com/s");
    +		Property p = model.createProperty("http://eg.com/p");
    +		Resource o = model.createResource("http://eg.com/o");
    +		model.add(s, p, o);
    +		Dataset dataset = DatasetFactory.create(model);
    +		// 2) named graph data
    +		Model model1 = ModelFactory.createDefaultModel();
    +		Resource s1 = model.createResource("http://eg.com/s1");
    +		Property p1 = model.createProperty("http://eg.com/p1");
    +		Resource o1 = model.createResource("http://eg.com/o1");
    +		model1.add(s1, p1, o1);
    +		dataset.addNamedModel("<http://eg.com/g1>", model1);
    +
    +
    +		// construct named graph
    +		System.out.println("construct named graph:");
    +		String queryString = "CONSTRUCT { GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
    +		Iterator<Quad> quads = qexec.execConstructQuads();
    +		PrintUtil.printOut(quads);
    +		qexec.close();
    +		
    +		// construct default graph 1
    +		System.out.println("construct default graph 1:");
    +		queryString = "CONSTRUCT {  {<http://eg.com/s1> <http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		qexec = QueryExecutionFactory.create(query, dataset);
    +		quads = qexec.execConstructQuads();
    +		PrintUtil.printOut(quads);
    +		qexec.close();
    +		
    +		// construct default graph 2
    +		System.out.println("construct default graph 2:");
    +		queryString = "CONSTRUCT {<http://eg.com/s1> <http://eg.com/p1> ?o}  WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		qexec = QueryExecutionFactory.create(query, dataset);
    +		quads = qexec.execConstructQuads();
    +		PrintUtil.printOut(quads);
    +		qexec.close();
    +		
    +		// construct triples
    +		System.out.println("construct default graph 2:");
    +		queryString = "CONSTRUCT {<http://eg.com/s1> <http://eg.com/p1> ?o}  WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		qexec = QueryExecutionFactory.create(query, dataset);
    +		Iterator<Triple> triples = qexec.execConstructTriples();
    +		PrintUtil.printOut(triples);
    +		qexec.close();
    +		
    +		//construct dataset
    +		System.out.println("construct dataset:");
    +		queryString = "CONSTRUCT { GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		qexec = QueryExecutionFactory.create(query, dataset);
    +		Dataset d = qexec.execConstructDataset();
    +		PrintUtil.printOut(d.getNamedModel("<http://eg.com/g1>").listStatements());
    --- End diff --
    
    Datasets can be printed: for example:
    ```
            RDFDataMgr.write(System.out, dataset, Lang.TRIG) ;
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35197024
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/QueryExecution.java ---
    @@ -18,16 +18,25 @@
     
     package org.apache.jena.query;
     
    -import java.util.Iterator ;
    -import java.util.concurrent.TimeUnit ;
    +import java.util.Iterator;
    +import java.util.concurrent.TimeUnit;
     
    -import org.apache.jena.graph.Triple ;
    -import org.apache.jena.rdf.model.Model ;
    -import org.apache.jena.sparql.util.Context ;
    +import org.apache.jena.graph.Triple;
    +import org.apache.jena.rdf.model.Model;
    +import org.apache.jena.sparql.core.Quad;
    +import org.apache.jena.sparql.util.Context;
     
     /** A interface for a single execution of a query. */
     
     
    +/**
    + * @author Administrator
    --- End diff --
    
    Please remove all @author tags.  We don't use them in the codebase.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on the pull request:

    https://github.com/apache/jena/pull/89#issuecomment-123643767
  
    Running `arq.qparse` on "CONSTRUCT { GRAPH ?g { ?s ?p ?o } }"
    yields problems.  This query does to print correctly.
    
    `arq.qparse` is useful in development because it does some checking - it parses and prints the input query but also reparses the output. It also calls `Query::hashCode` and `Query::equals` on the parsed and reparsed versions and expected them to match.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on the pull request:

    https://github.com/apache/jena/pull/89#issuecomment-123644119
  
    Running ExampleConstructQuads and the first output is:
    
    ```
    construct named graph:
       [<http://eg.com/g1> http://eg.com/s1 http://eg.com/p1 http://eg.com/o1]
    ```
    Note the graph name has `<>` around it.  Debugging, I found that the graph node has `<>` as part of it's URI.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35203280
  
    --- Diff: jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
    @@ -0,0 +1,141 @@
    +/*
    + * 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 arq.examples.constructquads;
    +
    +import java.util.Iterator;
    +
    +import org.apache.jena.graph.Triple;
    +import org.apache.jena.query.Dataset;
    +import org.apache.jena.query.DatasetFactory;
    +import org.apache.jena.query.Query;
    +import org.apache.jena.query.QueryExecution;
    +import org.apache.jena.query.QueryExecutionFactory;
    +import org.apache.jena.query.QueryFactory;
    +import org.apache.jena.query.Syntax;
    +import org.apache.jena.rdf.model.Model;
    +import org.apache.jena.rdf.model.ModelFactory;
    +import org.apache.jena.rdf.model.Property;
    +import org.apache.jena.rdf.model.Resource;
    +import org.apache.jena.sparql.core.Quad;
    +import org.apache.jena.util.PrintUtil;
    +
    +public class ExampleConstructQuads {
    +	public static void main(String[] args) {
    +
    +		// create testing data :
    +		// 1) default graph data
    +		Model model = ModelFactory.createDefaultModel();
    +		Resource s = model.createResource("http://eg.com/s");
    +		Property p = model.createProperty("http://eg.com/p");
    +		Resource o = model.createResource("http://eg.com/o");
    +		model.add(s, p, o);
    +		Dataset dataset = DatasetFactory.create(model);
    +		// 2) named graph data
    +		Model model1 = ModelFactory.createDefaultModel();
    +		Resource s1 = model.createResource("http://eg.com/s1");
    +		Property p1 = model.createProperty("http://eg.com/p1");
    +		Resource o1 = model.createResource("http://eg.com/o1");
    +		model1.add(s1, p1, o1);
    +		dataset.addNamedModel("<http://eg.com/g1>", model1);
    +
    +
    +		// construct named graph
    +		System.out.println("construct named graph:");
    +		String queryString = "CONSTRUCT { GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
    --- End diff --
    
    The Java7 form try-with-resources can be used:
    ```
                try ( QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ) {
                    Iterator<Quad> quads = qexec.execConstructQuads();
                    PrintUtil.printOut(quads);
                }
    ```
    It will remove the Eclipse warning that is usually enabled.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35211560
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQParserBase.java ---
    @@ -67,4 +79,25 @@ protected void jsonValueString(String image, long currLine, long currCol)
         protected void jsonValueNull(long currLine, long currCol)                    { handler.valueNull(currLine, currCol) ; }
         
         protected void jsonValueVar(String image, long currLine, long currCol)       { throw new NotImplemented("yet") ; }
    +    protected ElementGroup createQueryPattern(Template t){
    +        ElementGroup elg = new ElementGroup();
    +        List<Quad> quads = t.getQuads();
    +        HashMap<Node, BasicPattern> graphs = new HashMap<Node, BasicPattern>();
    --- End diff --
    
    Just `new HashMap<>` is okay after Java 7.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35197111
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/QueryExecution.java ---
    @@ -101,6 +110,19 @@
          * by applying the CONSTRUCT template of the query to the bindings in the WHERE clause.
          */
         public Iterator<Triple> execConstructTriples();
    +    
    +    
    --- End diff --
    
    Minor: 2 blank lines.  Elsewhere it's one.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35211501
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java ---
    @@ -242,6 +257,49 @@ public Model execConstruct(Model model)
             Template template = query.getConstructTemplate() ;
             return TemplateLib.calcTriples(template.getTriples(), queryIterator);
         }
    +    
    +    @Override
    +    public Iterator<Quad> execConstructQuads()
    +    {
    +        checkNotClosed() ;
    +        if ( ! query.isConstructType() )
    +            throw new QueryExecException("Attempt to get a CONSTRUCT model from a "+labelForQuery(query)+" query") ;
    +        // This causes there to be no PROJECT around the pattern.
    +        // That in turn, exposes the initial bindings.  
    +        if ( ! Syntax.syntaxARQ.equals( query.getSyntax() ) )
    +        	throw new QueryExecException("Attempt to CONSTRUCT quads from a "+labelForQuery(query)+" query, which is not ARQ Syntax") ;
    +        	
    +        query.setQueryResultStar(true) ;
    +
    +        startQueryIterator() ;
    +        
    +        Template template = query.getConstructTemplate() ;
    +        return TemplateLib.calcQuads(template.getQuads(), queryIterator);
    +    }
    +    
    +    @Override
    +    public Dataset execConstructDataset(){
    +    	
    +    	DatasetGraph graph = DatasetGraphFactory.createMem();
    +    	
    +        checkNotClosed() ;
    +        try
    +        {
    +            Iterator<Quad> it = execConstructQuads();
    +                        
    +            while (it.hasNext())
    +            {
    +                Quad q = it.next();
    +                graph.add(q);
    --- End diff --
    
    Given Java 8 this iterator loop could be just `execConstructQuads().forEachRemaining(graph::add);`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35211148
  
    --- Diff: jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
    @@ -0,0 +1,141 @@
    +/*
    + * 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 arq.examples.constructquads;
    +
    +import java.util.Iterator;
    +
    +import org.apache.jena.graph.Triple;
    +import org.apache.jena.query.Dataset;
    +import org.apache.jena.query.DatasetFactory;
    +import org.apache.jena.query.Query;
    +import org.apache.jena.query.QueryExecution;
    +import org.apache.jena.query.QueryExecutionFactory;
    +import org.apache.jena.query.QueryFactory;
    +import org.apache.jena.query.Syntax;
    +import org.apache.jena.rdf.model.Model;
    +import org.apache.jena.rdf.model.ModelFactory;
    +import org.apache.jena.rdf.model.Property;
    +import org.apache.jena.rdf.model.Resource;
    +import org.apache.jena.sparql.core.Quad;
    +import org.apache.jena.util.PrintUtil;
    +
    +public class ExampleConstructQuads {
    +	public static void main(String[] args) {
    +
    +		// create testing data :
    +		// 1) default graph data
    +		Model model = ModelFactory.createDefaultModel();
    +		Resource s = model.createResource("http://eg.com/s");
    +		Property p = model.createProperty("http://eg.com/p");
    +		Resource o = model.createResource("http://eg.com/o");
    +		model.add(s, p, o);
    +		Dataset dataset = DatasetFactory.create(model);
    +		// 2) named graph data
    +		Model model1 = ModelFactory.createDefaultModel();
    +		Resource s1 = model.createResource("http://eg.com/s1");
    +		Property p1 = model.createProperty("http://eg.com/p1");
    +		Resource o1 = model.createResource("http://eg.com/o1");
    +		model1.add(s1, p1, o1);
    +		dataset.addNamedModel("<http://eg.com/g1>", model1);
    +
    --- End diff --
    
    This might read a little better by just adding quads directly to a DatasetGraph, but I suppose it's a matter of taste.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35198181
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/syntax/Template.java ---
    @@ -52,14 +63,43 @@ public Template(BasicPattern bgp)
     //    public void addTriplePath(int index, TriplePath path)
     //    { throw new ARQException("Triples-only collector") ; }
     
    -
    -    public BasicPattern getBGP()        { return bgp ; }
    -    public List<Triple> getTriples()    { return bgp.getList() ; }
    +    public BasicPattern getBGP()
    +    { 
    +    	if (this.bgp != null){
    +    		return this.bgp;
    +    	}
    +    	BasicPattern bgp = new BasicPattern();
    +    	for(Quad q: qp.getQuads()){
    +    		bgp.add(q.asTriple());
    +    	}
    +    	return bgp;
    +    }
    +    public List<Triple> getTriples()
    +    { 
    +    	if(this.bgp != null){
    +    		return this.bgp.getList();
    +    	}
    +    	List<Triple> triples = new ArrayList<Triple>();
    +    	for(Quad q: qp.getQuads()){
    +    		triples.add(q.asTriple());
    +    	}
    +    	return triples;
    +    }
    +    public List<Quad> getQuads() {
    +    	if( this.bgp != null){
    +    		List<Quad> quads = new ArrayList<Quad>();
    +    		for(Triple triple: this.bgp.getList()){
    +    			quads.add( new Quad( Quad.defaultGraphNodeGenerated, triple ) ); 
    --- End diff --
    
    Jena is now requiring Java8 -- this can be with streams.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

Posted by confidencesun <gi...@git.apache.org>.
Github user confidencesun commented on a diff in the pull request:

    https://github.com/apache/jena/pull/89#discussion_r35834125
  
    --- Diff: jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
    @@ -0,0 +1,141 @@
    +/*
    + * 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 arq.examples.constructquads;
    +
    +import java.util.Iterator;
    +
    +import org.apache.jena.graph.Triple;
    +import org.apache.jena.query.Dataset;
    +import org.apache.jena.query.DatasetFactory;
    +import org.apache.jena.query.Query;
    +import org.apache.jena.query.QueryExecution;
    +import org.apache.jena.query.QueryExecutionFactory;
    +import org.apache.jena.query.QueryFactory;
    +import org.apache.jena.query.Syntax;
    +import org.apache.jena.rdf.model.Model;
    +import org.apache.jena.rdf.model.ModelFactory;
    +import org.apache.jena.rdf.model.Property;
    +import org.apache.jena.rdf.model.Resource;
    +import org.apache.jena.sparql.core.Quad;
    +import org.apache.jena.util.PrintUtil;
    +
    +public class ExampleConstructQuads {
    +	public static void main(String[] args) {
    +
    +		// create testing data :
    +		// 1) default graph data
    +		Model model = ModelFactory.createDefaultModel();
    +		Resource s = model.createResource("http://eg.com/s");
    +		Property p = model.createProperty("http://eg.com/p");
    +		Resource o = model.createResource("http://eg.com/o");
    +		model.add(s, p, o);
    +		Dataset dataset = DatasetFactory.create(model);
    +		// 2) named graph data
    +		Model model1 = ModelFactory.createDefaultModel();
    +		Resource s1 = model.createResource("http://eg.com/s1");
    +		Property p1 = model.createProperty("http://eg.com/p1");
    +		Resource o1 = model.createResource("http://eg.com/o1");
    +		model1.add(s1, p1, o1);
    +		dataset.addNamedModel("<http://eg.com/g1>", model1);
    +
    +
    +		// construct named graph
    +		System.out.println("construct named graph:");
    +		String queryString = "CONSTRUCT { GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> ?o} }";
    +		Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    +		QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
    --- End diff --
    
    I don't see any warnings in Eclipse regarding to try-catch here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---