[
https://issues.apache.org/jira/browse/JENA-491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636896#comment-14636896
]
ASF GitHub Bot commented on JENA-491:
-------------------------------------
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);`
> 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)