jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [09/12] jena git commit: Add Dataset variations.
Date Wed, 10 Aug 2016 12:59:15 GMT
Add Dataset variations.

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

Branch: refs/heads/master
Commit: ff28bc6968a38cdb9eb3ce50c3466cc85b654217
Parents: 1acfc24
Author: Andy Seaborne <andy@apache.org>
Authored: Sun Aug 7 22:26:02 2016 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Sun Aug 7 22:26:02 2016 +0100

----------------------------------------------------------------------
 .../fuseki/embedded/FusekiEmbeddedServer.java   | 42 +++++++++++++++-----
 .../fuseki/embedded/TestEmbeddedFuseki.java     | 17 ++++++--
 2 files changed, 46 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/ff28bc69/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiEmbeddedServer.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiEmbeddedServer.java
b/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiEmbeddedServer.java
index 59c1364..aa206fa 100644
--- a/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiEmbeddedServer.java
+++ b/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiEmbeddedServer.java
@@ -36,6 +36,7 @@ import org.apache.jena.fuseki.server.DataAccessPointRegistry ;
 import org.apache.jena.fuseki.server.DataService ;
 import org.apache.jena.fuseki.server.OperationName ;
 import org.apache.jena.fuseki.servlets.FusekiFilter ;
+import org.apache.jena.query.Dataset ;
 import org.apache.jena.sparql.core.DatasetGraph ;
 import org.eclipse.jetty.server.HttpConnectionFactory ;
 import org.eclipse.jetty.server.Server ;
@@ -173,11 +174,22 @@ public class FusekiEmbeddedServer {
         }
 
         /* Add the dataset with given name and a default set of services including update
*/  
+        public Builder add(String name, Dataset ds) {
+            return add(name, ds.asDatasetGraph()) ;
+        }
+
+        /* Add the dataset with given name and a default set of services including update
*/  
         public Builder add(String name, DatasetGraph dsg) {
             return add(name, dsg, true) ;
         }
 
         /* Add the dataset with given name and a default set of services. */  
+        public Builder add(String name, Dataset ds, boolean allowUpdate) {
+            return add(name, ds.asDatasetGraph(), allowUpdate) ;
+        }
+            
+        
+        /* Add the dataset with given name and a default set of services. */  
         public Builder add(String name, DatasetGraph dsg, boolean allowUpdate) {
             DataService dSrv = FusekiBuilder.buildDataService(dsg, allowUpdate) ; 
             return add(name, dSrv) ;
@@ -191,6 +203,13 @@ public class FusekiEmbeddedServer {
         /* Add an operation, specifing it's endpoint name.
          * This adds endpoints to any existing data service already setup by the builder.
  
          */
+        public Builder add(String name, Dataset ds, OperationName opName, String epName)
{
+            return add(name, ds.asDatasetGraph(), opName, epName) ; 
+        }
+
+            /* Add an operation, specifing it's endpoint name.
+         * This adds endpoints to any existing data service already setup by the builder.
  
+         */
         public Builder add(String name, DatasetGraph dsg, OperationName opName, String epName)
{
             DataService dSrv = map.get(name) ;
             if ( dSrv == null ) {
@@ -203,15 +222,20 @@ public class FusekiEmbeddedServer {
 
         private Builder add$(String name, DataService dataService) {
             name = DataAccessPoint.canonical(name) ;
-            DataService dSrv = map.get(name) ;
-            if ( dSrv != null ) {
-                DatasetGraph dsg1 = dSrv.getDataset() ;
-                DatasetGraph dsg2 = dataService.getDataset() ;
-                if ( dsg1 != dsg2 ) // Object identity
-                    throw new FusekiConfigException("Attempt to add a DataService for a different
dataset: "+name) ;
-                dSrv.getOperations() ;
-            } else
-                map.put(name, dataService) ;
+            if ( map.containsKey(name) )
+                throw new FusekiConfigException("Attempt to add a DataService for a different
dataset: "+name) ;
+            map.put(name, dataService) ;
+            
+            // Merge endpoints : too complicated 
+//            DataService dSrv = map.get(name) ;
+//            if ( dSrv != null ) {
+//                DatasetGraph dsg1 = dSrv.getDataset() ;
+//                DatasetGraph dsg2 = dataService.getDataset() ;
+//                if ( dsg1 != dsg2 ) // Object identity
+//                    throw new FusekiConfigException("Attempt to add a DataService for a
different dataset: "+name) ;
+//                dSrv.getOperations() ;
+//            } else
+//                map.put(name, dataService) ;
             return this ;
         }
         

http://git-wip-us.apache.org/repos/asf/jena/blob/ff28bc69/jena-fuseki2/jena-fuseki-embedded/src/test/java/org/apache/jena/fuseki/embedded/TestEmbeddedFuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-embedded/src/test/java/org/apache/jena/fuseki/embedded/TestEmbeddedFuseki.java
b/jena-fuseki2/jena-fuseki-embedded/src/test/java/org/apache/jena/fuseki/embedded/TestEmbeddedFuseki.java
index 8341342..cbc0adb 100644
--- a/jena-fuseki2/jena-fuseki-embedded/src/test/java/org/apache/jena/fuseki/embedded/TestEmbeddedFuseki.java
+++ b/jena-fuseki2/jena-fuseki-embedded/src/test/java/org/apache/jena/fuseki/embedded/TestEmbeddedFuseki.java
@@ -37,10 +37,7 @@ import org.apache.jena.fuseki.server.DataAccessPointRegistry ;
 import org.apache.jena.fuseki.server.DataService ;
 import org.apache.jena.fuseki.server.OperationName ;
 import org.apache.jena.graph.Graph ;
-import org.apache.jena.query.QueryExecution ;
-import org.apache.jena.query.QueryExecutionFactory ;
-import org.apache.jena.query.ResultSet ;
-import org.apache.jena.query.ResultSetFormatter ;
+import org.apache.jena.query.* ;
 import org.apache.jena.riot.RDFDataMgr ;
 import org.apache.jena.riot.RDFFormat ;
 import org.apache.jena.riot.RDFLanguages ;
@@ -73,6 +70,18 @@ public class TestEmbeddedFuseki {
         server.stop() ;
     }
     
+    @Test public void embedded_01a() {
+        Dataset ds = DatasetFactory.createTxnMem() ;
+        FusekiEmbeddedServer server = FusekiEmbeddedServer.create().add("/ds", ds).build()
;
+        assertTrue(DataAccessPointRegistry.get().isRegistered("/ds")) ;
+        server.start() ;
+        query("http://localhost:3330/ds/query", "SELECT * { ?s ?p ?o}", qExec-> {
+            ResultSet rs = qExec.execSelect() ; 
+            assertFalse(rs.hasNext()) ;
+        }) ;
+        server.stop() ;
+    }
+
     @Test public void embedded_02() {
         DatasetGraph dsg = dataset() ;
         FusekiEmbeddedServer server = FusekiEmbeddedServer.make(3330, "/ds2", dsg) ;


Mime
View raw message