Skip to content

Commit

Permalink
Added method sparqlConstructRemote allowing CONSTRUCT queries returni…
Browse files Browse the repository at this point in the history
…ng RDF/XML
  • Loading branch information
samuell committed Sep 14, 2010
1 parent 5a1ab12 commit 73fb23e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Expand Up @@ -188,6 +188,16 @@ public void saveRDFNTriple(IRDFStore store, String fileName)
public IStringMatrix sparqlRemote(String url, String SPARQL)
throws BioclipseException;

@Recorded
@PublishedMethod(
params = "String url, String SPARQL",
methodSummary = "Queries a remote SPARQL endpoint and returns RDF/XML. " +
"Assumes that the query is creating an RDF graph with the " +
"CONSTRUCT keyword"
)
public String sparqlConstructRemote(String url, String SPARQL)
throws BioclipseException;

@Recorded
@PublishedMethod(
params = "IRDFStore targetStore, IRDFStore sourceStore",
Expand Down
Expand Up @@ -18,10 +18,13 @@
******************************************************************************/
package net.bioclipse.rdf.business;

import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
Expand Down Expand Up @@ -382,6 +385,30 @@ public StringMatrix sparqlRemote(
return table;
}

public String sparqlConstructRemote(
String serviceURL,
String sparqlQueryString, IProgressMonitor monitor) {
if (monitor == null)
monitor = new NullProgressMonitor();

This comment has been minimized.

Copy link
@egonw

egonw Sep 16, 2010

Should we do a simple test to see of 'construct' is part of the input SPARQL?

This comment has been minimized.

Copy link
@samuell

samuell Sep 16, 2010

Author Owner

Yeah, indeed. I had something like that first, but it got lost when refactoring ...

monitor.beginTask("Sparqling the remote service..", 100);
Query query = QueryFactory.create(sparqlQueryString);
QueryExecution qexec = QueryExecutionFactory.sparqlService(serviceURL, query);
monitor.worked(80);

String rdfxml = "";
try {
Model results = qexec.execConstruct();
StringWriter sw = new StringWriter();
results.write(sw, "RDF/XML");
rdfxml = sw.toString();
} finally {
qexec.close();
}
monitor.worked(20);
return rdfxml;
}

public IRDFStore importRDFa(IRDFStore store, String url,
IProgressMonitor monitor)
throws IOException, BioclipseException, CoreException {
Expand Down

0 comments on commit 73fb23e

Please sign in to comment.