Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 8 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
View
12 plugins/net.bioclipse.rdf/src/net/bioclipse/rdf/business/IRDFManager.java
@@ -27,6 +27,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import com.hp.hpl.jena.rdf.model.Model;
+
@PublishedClass("Contains RDF related methods")
@TestClasses(
"net.bioclipse.rdf.tests.APITest," +
@@ -198,6 +200,16 @@ public IStringMatrix sparqlRemote(String url, String SPARQL)
@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 IRDFStore sparqlConstructRemote(String url, String SPARQL)
+ throws BioclipseException;
+
+ @Recorded
+ @PublishedMethod(
params = "IRDFStore targetStore, IRDFStore sourceStore",
methodSummary = "Copies the triples from the sourceStore into the " +
"targetStore."
View
9 plugins/net.bioclipse.rdf/src/net/bioclipse/rdf/business/JenaModel.java
@@ -18,10 +18,17 @@
private Model model;
- protected JenaModel() {
+ public JenaModel() {
RDFReaderFImpl.setClassLoader(this.getClass().getClassLoader());
model = ModelFactory.createOntologyModel();
}
+
+ public JenaModel( Model jenaTypeModel ) {
+ RDFReaderFImpl.setClassLoader(this.getClass().getClassLoader());
+ model = ModelFactory.createOntologyModel();
+ model.add( jenaTypeModel );
+ }
+
public Model getModel() {
return this.model;
View
41 plugins/net.bioclipse.rdf/src/net/bioclipse/rdf/business/RDFManager.java
@@ -171,16 +171,19 @@ private StringMatrix convertIntoTable(
PrefixMapping prefixMap, ResultSet results) {
StringMatrix table = new StringMatrix();
int rowCount = 0;
- int colCount = 0;
while (results.hasNext()) {
- colCount = 0;
rowCount++;
QuerySolution soln = results.nextSolution();
Iterator<String> varNames = soln.varNames();
while (varNames.hasNext()) {
- colCount++;
String varName = varNames.next();
- table.setColumnName(colCount, varName);
+ int colCount = -1;
+ if (table.hasColumn(varName)) {
+ colCount = table.getColumnNumber(varName);
+ } else {
+ colCount = table.getColumnCount() + 1;
+ table.setColumnName(colCount, varName);
+ }
RDFNode node = soln.get(varName);
if (node != null) {
String nodeStr = node.toString();
@@ -449,6 +452,36 @@ public StringMatrix sparqlRemote(
return table;
}
+ public IRDFStore sparqlConstructRemote(
+ String serviceURL,
+ String sparqlQueryString, IProgressMonitor monitor)
+ throws BioclipseException {
+ if ( !sparqlQueryString.contains( "CONSTRUCT" ) )
+ throw new BioclipseException( "This method can only be used together " +
+ "with CONSTRUCT queries." );
+ if (monitor == null)
+ monitor = new NullProgressMonitor();
+
+ Model sparqlOutput = null;
+ JenaModel rdfStore = null;
+
+ monitor.beginTask("Sparqling the remote service..", 100);
+ Query query = QueryFactory.create(sparqlQueryString);
+ QueryExecution qexec = QueryExecutionFactory.sparqlService(serviceURL, query);
+ monitor.worked(80);
+
+ try {
+ sparqlOutput = qexec.execConstruct();
+ monitor.worked(20);
+ rdfStore = new JenaModel( sparqlOutput );
+ } finally {
+ qexec.close();
+ monitor.done();
+ }
+
+ return rdfStore;
+ }
+
public IRDFStore importRDFa(IRDFStore store, String url,
IProgressMonitor monitor)
throws IOException, BioclipseException, CoreException {

No commit comments for this range

Something went wrong with that request. Please try again.