clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject git commit: CLEREZZA-917: Added support for SPARQL Update
Date Thu, 15 May 2014 14:15:01 GMT
Repository: clerezza
Updated Branches:
  refs/heads/master ce92b088f -> cdb81c617


CLEREZZA-917: Added support for SPARQL Update


Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/cdb81c61
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/cdb81c61
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/cdb81c61

Branch: refs/heads/master
Commit: cdb81c6170df65e6898cf0c2e6a4788f038a1577
Parents: ce92b08
Author: Minto van der Sluis <misl@apache.org>
Authored: Thu May 15 16:14:25 2014 +0200
Committer: Minto van der Sluis <misl@apache.org>
Committed: Thu May 15 16:14:45 2014 +0200

----------------------------------------------------------------------
 .../rdf/jena/tdb/storage/BaseTdbTcProvider.java | 32 +++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/cdb81c61/rdf.jena.tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/BaseTdbTcProvider.java
----------------------------------------------------------------------
diff --git a/rdf.jena.tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/BaseTdbTcProvider.java
b/rdf.jena.tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/BaseTdbTcProvider.java
index 3de84f9..c8a7a5f 100644
--- a/rdf.jena.tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/BaseTdbTcProvider.java
+++ b/rdf.jena.tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/BaseTdbTcProvider.java
@@ -10,10 +10,14 @@ import org.apache.clerezza.rdf.jena.sparql.ResultSetWrapper;
 import org.apache.clerezza.rdf.jena.storage.JenaGraphAdaptor;
 
 import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.QueryException;
 import com.hp.hpl.jena.query.QueryExecException;
 import com.hp.hpl.jena.query.QueryExecution;
 import com.hp.hpl.jena.query.QueryExecutionFactory;
 import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.update.GraphStore;
+import com.hp.hpl.jena.update.GraphStoreFactory;
+import com.hp.hpl.jena.update.UpdateAction;
 import org.apache.clerezza.rdf.core.UriRef;
 
 abstract class BaseTdbTcProvider implements QueryableTcProvider{
@@ -41,12 +45,23 @@ abstract class BaseTdbTcProvider implements QueryableTcProvider{
 
 					@Override
 					public QueryExecution run() {
-						com.hp.hpl.jena.query.Query jenaQuery = QueryFactory
-								.create(query);
-						return QueryExecutionFactory.create(jenaQuery, getDataset());
+						try {
+							com.hp.hpl.jena.query.Query jenaQuery = QueryFactory
+									.create(query);
+							if (jenaQuery.isUnknownType()) {
+								return null;
+							}
+							return QueryExecutionFactory.create(jenaQuery, getDataset());
+						} catch (QueryException ex) {
+							return null;
+						}							
 					}
 				});
 
+		if (qexec == null) {
+			return executeUpdate(query);
+		}
+
 		try {
 			try {
 				return new ResultSetWrapper(qexec.execSelect());
@@ -67,7 +82,6 @@ abstract class BaseTdbTcProvider implements QueryableTcProvider{
 			qexec.close();
 		}
     }
-    
 
 	// ------------------------------------------------------------------------
 	// Getters / Setters
@@ -83,4 +97,14 @@ abstract class BaseTdbTcProvider implements QueryableTcProvider{
     public void setDataset(Dataset dataset) {
 		this.dataset = dataset;
 	}
+
+	// ------------------------------------------------------------------------
+	// Private methods
+	// ------------------------------------------------------------------------
+    
+	private Object executeUpdate(String query) {
+        GraphStore graphStore = GraphStoreFactory.create(getDataset()) ;
+        UpdateAction.parseExecute(query, graphStore) ;
+        return true;
+    }
 }


Mime
View raw message