[
https://issues.apache.org/jira/browse/JENA-491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636748#comment-14636748
]
ASF GitHub Bot commented on JENA-491:
-------------------------------------
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.
> Extend CONSTRUCT to build quads
> -------------------------------
>
> Key: JENA-491
> URL: https://issues.apache.org/jira/browse/JENA-491
> Project: Apache Jena
> Issue Type: Improvement
> Components: ARQ, Fuseki
> Reporter: Andy Seaborne
> Labels: gsoc, gsoc2015, java, linked_data, rdf, sparql
>
> This would be an extension to SPARQL.
> 1/ Add use of GRAPH inside a CONSTRUCT template see SPARQL Update.
> 2/ Add conneg for quads to Fuseki.
> 3/ New QueryExecution operations execConstructQuads() and
> execConstructDataset()
> If asked for triples, and the CONSTRUCT generates quads, the named graph
> items are dropped - that is, only the default graph is returned. This is for
> commonality with RIOT.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)