This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new cbf5c5e  JENA-2212: Common root DatasetAssembler
     new da5921b  Merge pull request #1132 from afs/ds-assembler
cbf5c5e is described below

commit cbf5c5ed5d43c690601a002c41d24f6e47f6ef98
Author: Andy Seaborne <a...@apache.org>
AuthorDate: Sat Dec 11 16:11:16 2021 +0000

    JENA-2212: Common root DatasetAssembler
---
 .../java/org/apache/jena/query/DatasetFactory.java |   4 +-
 .../jena/rdfs/assembler/DatasetRDFSAssembler.java  |  16 +--
 .../jena/sparql/core/DatasetGraphFactory.java      |   4 +-
 .../org/apache/jena/sparql/core/DatasetOne.java    |  12 +-
 .../jena/sparql/core/assembler/AssemblerUtils.java |   2 +-
 .../sparql/core/assembler/DatasetAssembler.java    |  60 ++--------
 ...Assembler.java => DatasetAssemblerGeneral.java} |  14 +--
 .../core/assembler/DatasetNullAssembler.java       |  13 +--
 .../sparql/core/assembler/DatasetOneAssembler.java |  43 ++++---
 .../core/assembler/InMemDatasetAssembler.java      |  21 ++--
 ...AssemblerTDB.java => DatasetAssemblerTDB2.java} |  17 +--
 ...GraphAssembler.java => TDB2GraphAssembler.java} |  34 +++---
 .../org/apache/jena/tdb2/assembler/VocabTDB2.java  |   8 +-
 .../jena/test/assembler/TestDatasetAssembler.java  |  54 ++++-----
 ...AssemblerTDB.java => DatasetAssemblerTDB1.java} |  43 ++++---
 .../jena/tdb/assembler/TDB1GraphAssembler.java     |  56 ++++-----
 .../jena/tdb/assembler/TDBGraphAssembler.java      | 125 ---------------------
 .../org/apache/jena/tdb/assembler/VocabTDB.java    |  22 ++--
 .../query/text/assembler/TextDatasetAssembler.java |  11 +-
 19 files changed, 191 insertions(+), 368 deletions(-)

diff --git a/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java 
b/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java
index 7fba7a0..f0a7fd2 100644
--- a/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java
+++ b/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java
@@ -28,8 +28,8 @@ import org.apache.jena.riot.RDFDataMgr;
 import org.apache.jena.sparql.ARQException;
 import org.apache.jena.sparql.core.DatasetGraph;
 import org.apache.jena.sparql.core.DatasetGraphFactory;
+import org.apache.jena.sparql.core.DatasetGraphOne;
 import org.apache.jena.sparql.core.DatasetImpl;
-import org.apache.jena.sparql.core.DatasetOne;
 import org.apache.jena.sparql.core.assembler.DatasetAssembler;
 import org.apache.jena.sparql.util.DatasetUtils;
 import org.apache.jena.sparql.util.graph.GraphUtils;
@@ -126,7 +126,7 @@ public class DatasetFactory {
      */
     public static Dataset wrap(Model model) {
         Objects.requireNonNull(model, "Can't wrap a null Model reference") ;
-        return DatasetOne.create(model);
+        return wrap(DatasetGraphOne.create(model.getGraph()));
     }
 
     /**
diff --git 
a/jena-arq/src/main/java/org/apache/jena/rdfs/assembler/DatasetRDFSAssembler.java
 
b/jena-arq/src/main/java/org/apache/jena/rdfs/assembler/DatasetRDFSAssembler.java
index c9149d0..2fd9c18 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/rdfs/assembler/DatasetRDFSAssembler.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/rdfs/assembler/DatasetRDFSAssembler.java
@@ -22,32 +22,23 @@ import static 
org.apache.jena.sparql.util.graph.GraphUtils.getAsStringValue;
 import static org.apache.jena.sparql.util.graph.GraphUtils.getResourceValue;
 
 import org.apache.jena.assembler.Assembler;
-import org.apache.jena.assembler.Mode;
-import org.apache.jena.assembler.assemblers.AssemblerBase;
 import org.apache.jena.assembler.exceptions.AssemblerException;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.query.Dataset;
-import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdf.model.Resource;
 import org.apache.jena.rdfs.DatasetGraphRDFS;
 import org.apache.jena.rdfs.RDFSFactory;
 import org.apache.jena.rdfs.SetupRDFS;
 import org.apache.jena.riot.RDFDataMgr;
 import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.assembler.DatasetAssembler;
 
-public class DatasetRDFSAssembler extends AssemblerBase implements Assembler {
+public class DatasetRDFSAssembler extends DatasetAssembler {
 
     public static Resource getType() {
         return VocabRDFS.tDatasetRDFS;
     }
 
-    @Override
-    public Object open(Assembler a, Resource root, Mode mode) {
-        DatasetGraph dsg = createDataset(a, root, mode) ;
-        Dataset ds = DatasetFactory.wrap(dsg);
-        return ds ;
-    }
-
     /**
      * <pre>
      * &lt;#rdfsDS&gt; rdf:type ja:DatasetRDFS ;
@@ -62,7 +53,8 @@ public class DatasetRDFSAssembler extends AssemblerBase 
implements Assembler {
      * </pre>
      */
 
-    public DatasetGraph createDataset(Assembler a, Resource root, Mode mode) {
+    @Override
+    public DatasetGraph createDataset(Assembler a, Resource root) {
 
         Resource dataset = getResourceValue(root, VocabRDFS.pDataset) ;
         if ( dataset == null )
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphFactory.java 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphFactory.java
index a66fa95..6322531 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphFactory.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphFactory.java
@@ -107,8 +107,8 @@ public class DatasetGraphFactory
      * Create a DatasetGraph starting with a single graph.
      * New graphs must be explicitly added.
      */
-    public static DatasetGraph create(Graph graph) {
-        return new DatasetGraphMapLink(graph) ;
+    public static DatasetGraph create(Graph dftGraph) {
+        return new DatasetGraphMapLink(dftGraph);
     }
 
     /**
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetOne.java 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetOne.java
index 53e5830..f22e947 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetOne.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetOne.java
@@ -21,24 +21,30 @@ package org.apache.jena.sparql.core;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.NodeFactory;
 import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdf.model.Model;
 import org.apache.jena.rdf.model.Resource;
 
 /**
- * A dataset that just hold a single model as the default graph. 
+ * A dataset that just hold a single model as the default graph.
  * It is particularly appropriate for use with inference models.
- * 
+ *
  * @apiNote
  * This class makes the use of DatasetImpl with one fixed model clearer. It may
  * become useful to have a separate implementation altogether at some time.
+ *
+ * @deprecated Use {@link DatasetFactory#wrap(Model)}
  */
+@Deprecated
 public class DatasetOne extends DatasetImpl {
     public static Dataset create(Model model) {
-        return new DatasetOne(model);
+        return DatasetFactory.wrap(model);
     }
 
     private final Model defaultModel;
 
+    /** @deprecated Use {@link DatasetFactory#wrap(Model)} */
+    @Deprecated
     public DatasetOne(Model model) {
         super(DatasetGraphOne.create(model.getGraph()));
         this.defaultModel = model;
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
index c7e218f..73af182 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
@@ -59,7 +59,7 @@ public class AssemblerUtils
         if ( initialized )
             return ;
         initialized = true ;
-        registerDataset(tDataset,         new DatasetAssembler());
+        registerDataset(tDataset,         new DatasetAssemblerGeneral());
         registerDataset(tDatasetOne,      new DatasetOneAssembler());
         registerDataset(tDatasetZero,     new 
DatasetNullAssembler(tDatasetZero));
         registerDataset(tDatasetSink,     new 
DatasetNullAssembler(tDatasetSink));
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
index 652bd1a..d90b0de 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
@@ -18,68 +18,24 @@
 
 package org.apache.jena.sparql.core.assembler ;
 
-import java.util.List ;
-
 import org.apache.jena.assembler.Assembler ;
 import org.apache.jena.assembler.Mode ;
 import org.apache.jena.assembler.assemblers.AssemblerBase ;
-import org.apache.jena.atlas.logging.Log ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.RDFNode ;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdf.model.Resource ;
-import org.apache.jena.sparql.graph.GraphFactory ;
-import org.apache.jena.sparql.util.FmtUtils ;
-import org.apache.jena.sparql.util.graph.GraphUtils ;
+import org.apache.jena.sparql.core.DatasetGraph;
 
-public class DatasetAssembler extends AssemblerBase implements Assembler {
+public abstract class DatasetAssembler extends AssemblerBase implements 
Assembler {
     public static Resource getType() {
         return DatasetAssemblerVocab.tDataset ;
     }
 
     @Override
-    public Object open(Assembler a, Resource root, Mode mode) {
-        Dataset ds = createDataset(a, root, mode) ;
-        return ds ;
+    public Dataset open(Assembler a, Resource root, Mode mode) {
+        DatasetGraph dsg = createDataset(a, root) ;
+        return DatasetFactory.wrap(dsg);
     }
 
-    public Dataset createDataset(Assembler a, Resource root, Mode mode) {
-        // -------- Default graph
-        // Can use ja:graph or ja:defaultGraph
-        Resource dftGraph = GraphUtils.getResourceValue(root, 
DatasetAssemblerVocab.pDefaultGraph) ;
-        if ( dftGraph == null )
-            dftGraph = GraphUtils.getResourceValue(root, 
DatasetAssemblerVocab.pGraph) ;
-
-        Model dftModel = null ;
-        if ( dftGraph != null )
-            dftModel = a.openModel(dftGraph) ;
-        else
-            // Assembler description did not define one.
-            dftModel = GraphFactory.makeDefaultModel() ;
-        Dataset ds = DatasetFactory.create(dftModel) ;
-        // -------- Named graphs
-        List<RDFNode> nodes = GraphUtils.multiValue(root, 
DatasetAssemblerVocab.pNamedGraph) ;
-        for ( RDFNode n : nodes ) {
-            if ( !(n instanceof Resource) )
-                throw new DatasetAssemblerException(root, "Not a resource: " + 
FmtUtils.stringForRDFNode(n));
-            Resource r = (Resource)n;
-
-            String gName = GraphUtils.getAsStringValue(r, 
DatasetAssemblerVocab.pGraphName);
-            Resource g = GraphUtils.getResourceValue(r, 
DatasetAssemblerVocab.pGraph);
-            if ( g == null ) {
-                g = GraphUtils.getResourceValue(r, 
DatasetAssemblerVocab.pGraphAlt);
-                if ( g != null ) {
-                    Log.warn(this, "Use of old vocabulary: use :graph not 
:graphData");
-                } else {
-                    throw new DatasetAssemblerException(root, "no graph for: " 
+ gName);
-                }
-            }
-
-            Model m = a.openModel(g);
-            ds.addNamedModel(gName, m);
-        }
-        AssemblerUtils.mergeContext(root, ds.getContext()) ;
-        return ds ;
-    }
+    public abstract DatasetGraph createDataset(Assembler a, Resource root);
 }
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssemblerGeneral.java
similarity index 88%
copy from 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
copy to 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssemblerGeneral.java
index 652bd1a..4bfaf96 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssemblerGeneral.java
@@ -21,30 +21,24 @@ package org.apache.jena.sparql.core.assembler ;
 import java.util.List ;
 
 import org.apache.jena.assembler.Assembler ;
-import org.apache.jena.assembler.Mode ;
-import org.apache.jena.assembler.assemblers.AssemblerBase ;
 import org.apache.jena.atlas.logging.Log ;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.query.DatasetFactory ;
 import org.apache.jena.rdf.model.Model ;
 import org.apache.jena.rdf.model.RDFNode ;
 import org.apache.jena.rdf.model.Resource ;
+import org.apache.jena.sparql.core.DatasetGraph;
 import org.apache.jena.sparql.graph.GraphFactory ;
 import org.apache.jena.sparql.util.FmtUtils ;
 import org.apache.jena.sparql.util.graph.GraphUtils ;
 
-public class DatasetAssembler extends AssemblerBase implements Assembler {
+public class DatasetAssemblerGeneral extends DatasetAssembler implements 
Assembler {
     public static Resource getType() {
         return DatasetAssemblerVocab.tDataset ;
     }
 
     @Override
-    public Object open(Assembler a, Resource root, Mode mode) {
-        Dataset ds = createDataset(a, root, mode) ;
-        return ds ;
-    }
-
-    public Dataset createDataset(Assembler a, Resource root, Mode mode) {
+    public DatasetGraph createDataset(Assembler a, Resource root) {
         // -------- Default graph
         // Can use ja:graph or ja:defaultGraph
         Resource dftGraph = GraphUtils.getResourceValue(root, 
DatasetAssemblerVocab.pDefaultGraph) ;
@@ -80,6 +74,6 @@ public class DatasetAssembler extends AssemblerBase 
implements Assembler {
             ds.addNamedModel(gName, m);
         }
         AssemblerUtils.mergeContext(root, ds.getContext()) ;
-        return ds ;
+        return ds.asDatasetGraph() ;
     }
 }
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetNullAssembler.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetNullAssembler.java
index aa6d3a8..38de944 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetNullAssembler.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetNullAssembler.java
@@ -19,11 +19,7 @@
 package org.apache.jena.sparql.core.assembler;
 
 import org.apache.jena.assembler.Assembler;
-import org.apache.jena.assembler.Mode;
-import org.apache.jena.assembler.assemblers.AssemblerBase;
 import org.apache.jena.atlas.lib.InternalErrorException;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdf.model.Resource;
 import org.apache.jena.sparql.core.DatasetGraph;
 import org.apache.jena.sparql.core.DatasetGraphSink;
@@ -36,7 +32,7 @@ import org.apache.jena.sparql.core.DatasetGraphZero;
  * @see DatasetGraphZero
  */
 
-public class DatasetNullAssembler extends AssemblerBase {
+public class DatasetNullAssembler extends DatasetAssembler {
     private final Resource tDataset;
 
     public DatasetNullAssembler(Resource tDataset) {
@@ -44,7 +40,7 @@ public class DatasetNullAssembler extends AssemblerBase {
     }
 
     @Override
-    public Object open(Assembler a, Resource root, Mode mode) {
+    public DatasetGraph createDataset(Assembler a, Resource root) {
         DatasetGraph dsg;
         if ( DatasetAssemblerVocab.tDatasetSink.equals(tDataset) )
             dsg = DatasetGraphSink.create();
@@ -52,8 +48,7 @@ public class DatasetNullAssembler extends AssemblerBase {
             dsg = DatasetGraphZero.create();
         else
             throw new InternalErrorException();
-        Dataset ds = DatasetFactory.wrap(dsg);
-        AssemblerUtils.mergeContext(root, ds.getContext());
-        return ds;
+        AssemblerUtils.mergeContext(root, dsg.getContext());
+        return dsg;
     }
 }
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetOneAssembler.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetOneAssembler.java
index a792442..ef5a448 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetOneAssembler.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetOneAssembler.java
@@ -21,14 +21,13 @@ package org.apache.jena.sparql.core.assembler;
 import java.util.List;
 
 import org.apache.jena.assembler.Assembler;
-import org.apache.jena.assembler.Mode;
-import org.apache.jena.assembler.assemblers.AssemblerBase;
 import org.apache.jena.assembler.exceptions.AssemblerException;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.graph.Graph;
 import org.apache.jena.rdf.model.Model;
 import org.apache.jena.rdf.model.RDFNode;
 import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
 import org.apache.jena.sparql.graph.GraphFactory;
 import org.apache.jena.sparql.util.graph.GraphUtils;
 
@@ -39,29 +38,30 @@ import org.apache.jena.sparql.util.graph.GraphUtils;
  * <p>
  * General datasets and SPARQL Update can create graphs by inserting a quad.
  * The dataset returned by this assembler does not support that.
- * 
+ *
  * @see DatasetAssembler {@code DatasetAssembler}, for a general dataset.
  * @see InMemDatasetAssembler {@code InMemDatasetAssembler}, for a fully 
transactional, in-memory dataset.
  */
-public class DatasetOneAssembler extends AssemblerBase {
+public class DatasetOneAssembler extends DatasetAssembler  {
     public static Resource getType() {
         return DatasetAssemblerVocab.tDatasetOne;
     }
 
     @Override
-    public Object open(Assembler a, Resource root, Mode mode) {
-        Dataset ds = createDataset(a, root, mode);
-        return ds;
-    }
-
-    public Dataset createDataset(Assembler a, Resource root, Mode mode) {
+    public DatasetGraph createDataset(Assembler a, Resource root) {
         // Can use ja:graph or ja:defaultGraph but not both.
         Resource dftGraphDesc1 = GraphUtils.getResourceValue(root, 
DatasetAssemblerVocab.pDefaultGraph);
         Resource dftGraphDesc2 = GraphUtils.getResourceValue(root, 
DatasetAssemblerVocab.pGraph);
-        
+
         if ( dftGraphDesc1 != null && dftGraphDesc2 != null )
-            throw new AssemblerException(root, "Found both ja:graph and 
ja:defaultGraph"); 
-        
+            throw new AssemblerException(root, "Found both ja:graph and 
ja:defaultGraph");
+
+        List<RDFNode> nodes = GraphUtils.multiValue(root, 
DatasetAssemblerVocab.pNamedGraph);
+        if ( ! nodes.isEmpty() ) {
+            String x = DatasetAssemblerVocab.tDatasetOne.getLocalName();
+            throw new AssemblerException(root, "A "+x+" dataset can only hold 
a default graph, and no named graphs");
+        }
+
         Resource graphDesc = ( dftGraphDesc1 != null) ? dftGraphDesc1 : 
dftGraphDesc2 ;
         Model model;
         if ( graphDesc != null )
@@ -69,14 +69,9 @@ public class DatasetOneAssembler extends AssemblerBase {
         else
             // Assembler description did not define one.
             model = GraphFactory.makeDefaultModel();
-        Dataset ds = DatasetFactory.wrap(model);
-        
-        List<RDFNode> nodes = GraphUtils.multiValue(root, 
DatasetAssemblerVocab.pNamedGraph);
-        if ( ! nodes.isEmpty() ) {
-            String x = DatasetAssemblerVocab.tDatasetOne.getLocalName();
-            throw new AssemblerException(root, "A "+x+" dataset can only hold 
a default graph, and no named graphs");
-        }
-        AssemblerUtils.mergeContext(root, ds.getContext());
-        return ds;
+        Graph dftGraph = model.getGraph();
+        DatasetGraph dsg = DatasetGraphFactory.wrap(dftGraph);
+        AssemblerUtils.mergeContext(root, dsg.getContext());
+        return dsg;
     }
 }
diff --git 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
index b0c5f9b..fedea54 100644
--- 
a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
+++ 
b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
@@ -19,7 +19,6 @@
 package org.apache.jena.sparql.core.assembler;
 
 import static org.apache.jena.assembler.JA.data;
-import static org.apache.jena.query.DatasetFactory.createTxnMem;
 import static org.apache.jena.riot.RDFDataMgr.read;
 import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.mergeContext;
 import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.pGraphName;
@@ -29,31 +28,34 @@ import static 
org.apache.jena.sparql.util.graph.GraphUtils.multiValueAsString;
 import static org.apache.jena.sparql.util.graph.GraphUtils.multiValueResource;
 
 import org.apache.jena.assembler.Assembler;
-import org.apache.jena.assembler.Mode;
-import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
 import org.apache.jena.query.Dataset;
 import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
 import org.apache.jena.system.Txn;
 import org.apache.jena.vocabulary.RDF;
 
 /**
  * An {@link Assembler} that creates in-memory {@link Dataset}s.
  */
-public class InMemDatasetAssembler extends AssemblerBase implements Assembler {
+public class InMemDatasetAssembler extends DatasetAssembler {
 
     public static Resource getType() {
         return DatasetAssemblerVocab.tMemoryDataset ;
     }
 
+
     @Override
-    public Dataset open(final Assembler assembler, final Resource root, final 
Mode mode) {
+    public DatasetGraph createDataset(Assembler a, Resource root) {
         // Old name : bypass.
         if ( ! root.hasProperty( RDF.type, 
DatasetAssemblerVocab.tDatasetTxnMem ) )
             checkType(root, DatasetAssemblerVocab.tMemoryDataset);
-        final Dataset dataset = createTxnMem();
+        final DatasetGraph dataset = DatasetGraphFactory.createTxnMem();
         mergeContext(root, dataset.getContext());
 
-        Txn.executeWrite(dataset, ()->{ 
+        Txn.executeWrite(dataset, ()->{
             // Load data into the default graph
             // This also loads quads into the dataset.
             multiValueAsString(root, data)
@@ -64,7 +66,10 @@ public class InMemDatasetAssembler extends AssemblerBase 
implements Assembler {
                 final String graphName = getAsStringValue(namedGraphResource, 
pGraphName);
                 if (namedGraphResource.hasProperty(data)) {
                     multiValueAsString(namedGraphResource, data)
-                        .forEach(namedGraphData -> 
read(dataset.getNamedModel(graphName), namedGraphData));
+                            .forEach(namedGraphData -> {
+                                Node gn = NodeFactory.createURI(graphName);
+                                read(dataset.getGraph(gn), namedGraphData);
+                            });
                 }
             });
         });
diff --git 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/DatasetAssemblerTDB.java
 
b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/DatasetAssemblerTDB2.java
similarity index 84%
rename from 
jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/DatasetAssemblerTDB.java
rename to 
jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/DatasetAssemblerTDB2.java
index 00b684f..3e4b8ef 100644
--- 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/DatasetAssemblerTDB.java
+++ 
b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/DatasetAssemblerTDB2.java
@@ -24,13 +24,10 @@ import static 
org.apache.jena.tdb2.assembler.VocabTDB2.pLocation;
 import static org.apache.jena.tdb2.assembler.VocabTDB2.pUnionDefaultGraph;
 
 import org.apache.jena.assembler.Assembler;
-import org.apache.jena.assembler.Mode;
 import org.apache.jena.assembler.exceptions.AssemblerException;
 import org.apache.jena.atlas.logging.Log;
 import org.apache.jena.dboe.base.file.Location;
 import org.apache.jena.graph.Node;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.query.DatasetFactory;
 import org.apache.jena.rdf.model.Resource;
 import org.apache.jena.sparql.core.DatasetGraph;
 import org.apache.jena.sparql.core.assembler.AssemblerUtils;
@@ -40,17 +37,16 @@ import org.apache.jena.sys.JenaSystem;
 import org.apache.jena.tdb2.DatabaseMgr;
 import org.apache.jena.tdb2.TDB2;
 
-public class DatasetAssemblerTDB extends DatasetAssembler
+public class DatasetAssemblerTDB2 extends DatasetAssembler
 {
     static { JenaSystem.init(); }
 
     @Override
-    public Dataset createDataset(Assembler a, Resource root, Mode mode) {
-        TDB2.init();
-        return make(root);
+    public DatasetGraph createDataset(Assembler a, Resource root) {
+        return make(a, root);
     }
 
-    static Dataset make(Resource root) {
+    public static DatasetGraph make(Assembler a, Resource root) {
         if ( !exactlyOneProperty(root, pLocation) )
             throw new AssemblerException(root, "No location given");
 
@@ -64,7 +60,7 @@ public class DatasetAssemblerTDB extends DatasetAssembler
             if ( nv.isBoolean() )
                 dsg.getContext().set(TDB2.symUnionDefaultGraph, 
nv.getBoolean());
             else
-                Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value 
for union graph setting (ignored): " + b);
+                Log.warn(DatasetAssemblerTDB2.class, "Failed to recognize 
value for union graph setting (ignored): " + b);
         }
 
         /*
@@ -74,7 +70,6 @@ public class DatasetAssemblerTDB extends DatasetAssembler
             tdb:unionGraph true; # or "true"
         */
         AssemblerUtils.mergeContext(root, dsg.getContext());
-        return DatasetFactory.wrap(dsg);
+        return dsg;
     }
-
 }
diff --git 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDBGraphAssembler.java
 
b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDB2GraphAssembler.java
similarity index 77%
copy from 
jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDBGraphAssembler.java
copy to 
jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDB2GraphAssembler.java
index a5e8300..2b7aee7 100644
--- 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDBGraphAssembler.java
+++ 
b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDB2GraphAssembler.java
@@ -29,22 +29,26 @@ import org.apache.jena.assembler.assemblers.AssemblerBase;
 import org.apache.jena.assembler.exceptions.AssemblerException;
 import org.apache.jena.atlas.logging.Log;
 import org.apache.jena.dboe.base.file.Location;
-import org.apache.jena.query.Dataset;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.NodeFactory;
 import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
 import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.tdb2.TDB2;
-import org.apache.jena.tdb2.TDB2Factory;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sys.JenaSystem;
+import org.apache.jena.tdb2.DatabaseMgr;
 
-public class TDBGraphAssembler extends AssemblerBase implements Assembler
+public class TDB2GraphAssembler extends AssemblerBase implements Assembler
 {
+    static { JenaSystem.init(); }
+
     @Override
-    public Model open(Assembler a, Resource root, Mode mode)
-    {
-        // In case we go via explicit index construction,
-        // although given we got here, the assembler is wired in
-        // and that probably means TDB.init
-        TDB2.init();
+    public Model open(Assembler a, Resource root, Mode mode) {
+        Graph g = createGraph(a, root, mode);
+        return ModelFactory.createModelForGraph(g);
+    }
 
+    public Graph createGraph(Assembler a, Resource root, Mode mode) {
         // Make a model - the default model of the TDB dataset
         // [] rdf:type tdb:GraphTDB;
         //    tdb:location "dir";
@@ -73,21 +77,21 @@ public class TDBGraphAssembler extends AssemblerBase 
implements Assembler
         if ( root.hasProperty(pIndex) )
             Log.warn(this, "Custom indexes not implemented yet - ignored");
 
-        final Dataset ds;
+        DatasetGraph dsg;
 
         if ( locationDir != null )
         {
             Location location = Location.create(locationDir);
-            ds = TDB2Factory.connectDataset(location);
+            dsg = DatabaseMgr.connectDatasetGraph(location);
         }
         else
-            ds = DatasetAssemblerTDB.make(dataset);
+            dsg = DatasetAssemblerTDB2.make(a, dataset);
 
         try {
             if ( graphName != null )
-                return ds.getNamedModel(graphName);
+                return dsg.getGraph(NodeFactory.createURI(graphName));
             else
-                return ds.getDefaultModel();
+                return dsg.getDefaultGraph();
         } catch (RuntimeException ex)
         {
             ex.printStackTrace(System.err);
diff --git 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/VocabTDB2.java 
b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/VocabTDB2.java
index 44721b4..d1517dc 100644
--- 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/VocabTDB2.java
+++ 
b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/VocabTDB2.java
@@ -82,10 +82,10 @@ public class VocabTDB2
         // Wire in the extension assemblers (extensions relative to the Jena 
assembler framework)
         // Domain and range for properties.
         // Separated and use ja:imports
-        AssemblerUtils.registerDataset(tDatasetTDB, new DatasetAssemblerTDB());
-        AssemblerUtils.registerDataset(tDatasetTDB_alt, new 
DatasetAssemblerTDB());
-        AssemblerUtils.register(ConstAssembler.general(), tGraphTDB, new 
TDBGraphAssembler(), JA.Model);
-        AssemblerUtils.register(ConstAssembler.general(), tGraphTDB_alt, new 
TDBGraphAssembler(), JA.Model);
+        AssemblerUtils.registerDataset(tDatasetTDB, new 
DatasetAssemblerTDB2());
+        AssemblerUtils.registerDataset(tDatasetTDB_alt, new 
DatasetAssemblerTDB2());
+        AssemblerUtils.register(ConstAssembler.general(), tGraphTDB, new 
TDB2GraphAssembler(), JA.Model);
+        AssemblerUtils.register(ConstAssembler.general(), tGraphTDB_alt, new 
TDB2GraphAssembler(), JA.Model);
 
     }
 }
diff --git 
a/jena-integration-tests/src/test/java/org/apache/jena/test/assembler/TestDatasetAssembler.java
 
b/jena-integration-tests/src/test/java/org/apache/jena/test/assembler/TestDatasetAssembler.java
index c55b198..d1c2efa 100644
--- 
a/jena-integration-tests/src/test/java/org/apache/jena/test/assembler/TestDatasetAssembler.java
+++ 
b/jena-integration-tests/src/test/java/org/apache/jena/test/assembler/TestDatasetAssembler.java
@@ -31,7 +31,7 @@ import org.apache.jena.rdf.model.Property;
 import org.apache.jena.rdf.model.Resource;
 import org.apache.jena.rdf.model.Statement;
 import org.apache.jena.riot.RDFDataMgr;
-import org.apache.jena.sparql.core.DatasetOne;
+import org.apache.jena.sparql.core.DatasetGraphOne;
 import org.apache.jena.sparql.core.assembler.AssemblerUtils;
 import org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab;
 import org.apache.jena.sys.JenaSystem;
@@ -42,10 +42,10 @@ import org.junit.Test;
  * Tests of building datasets with assemblers.
  */
 public class TestDatasetAssembler {
-    static { JenaSystem.init(); } 
-    
+    static { JenaSystem.init(); }
+
     protected static String DIR = "testing/Assembler/";
-    
+
     static private Model     data = RDFDataMgr.loadModel(DIR + "data.ttl");
     static private Resource  s    = 
data.createResource("http://example/data/s";);
     static private Property  p    = 
data.createProperty("http://example/data/p";);
@@ -53,95 +53,95 @@ public class TestDatasetAssembler {
     static private Statement stmt = data.createStatement(s, p, o);
 
     // See also jena-arq/etc/...
-    
+
     // ---- Null dataset assemblers
 
     @Test public void dsg_zero() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg_zero.ttl", 
DatasetAssemblerVocab.tDatasetZero);
         assertNotNull(ds);
-        try { 
+        try {
             ds.getDefaultModel().add(stmt);
         } catch (UnsupportedOperationException ex) {}
     }
-    
+
     @Test public void dsg_sink() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg_sink.ttl", 
DatasetAssemblerVocab.tDatasetSink);
         assertNotNull(ds);
-        assertTrue(ds.getContext().isDefined(ARQ.queryTimeout)); 
+        assertTrue(ds.getContext().isDefined(ARQ.queryTimeout));
         ds.getDefaultModel().add(stmt);
         assertEquals(0, ds.getDefaultModel().size());
     }
 
     // ---- DatasetOneAssembler
-    
+
     @Test public void dsg1_1() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg1_1.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         useIt(ds);
     }
-    
+
     @Test public void dsg1_2() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg1_2.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         readIt(ds);
     }
-    
+
     @Test public void dsg1_3() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg1_3.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         readIt(ds);
     }
-    
+
     @Test(expected=AssemblerException.class)
-    public void dsg1_bad_1() { 
+    public void dsg1_bad_1() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg1_bad_1.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
-    } 
-    
+    }
+
     @Test public void dsg1_tdb1() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg1_tdb1.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         useIt(ds);
     }
-    
+
     @Test public void dsg1_tdb2() {
         Dataset ds = (Dataset)AssemblerUtils.build(DIR+"assem_dsg1_tdb2.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         useIt(ds);
     }
-    
+
     @Test public void dsg1_inf_tdb1() {
         Dataset ds = 
(Dataset)AssemblerUtils.build(DIR+"assem_dsg1_inf_tdb1.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         useIt(ds);
     }
-    
+
     @Test public void dsg1_inf_tdb2() {
         Dataset ds = 
(Dataset)AssemblerUtils.build(DIR+"assem_dsg1_inf_tdb2.ttl", 
DatasetAssemblerVocab.tDatasetOne);
         assertNotNull(ds);
         assertNotNull(ds.getDefaultModel());
-        assertTrue(ds instanceof DatasetOne);
+        assertTrue(ds.asDatasetGraph() instanceof DatasetGraphOne);
         useIt(ds);
     }
-    
+
     private void readIt(Dataset ds) {
         Txn.exec(ds, TxnType.READ, ()->{
             assertTrue(ds.getDefaultModel().contains(stmt));
         });
     }
-    
+
     private void useIt(Dataset ds) {
         Txn.executeWrite(ds, ()->{
             ds.getDefaultModel().add(data);
diff --git 
a/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/DatasetAssemblerTDB.java 
b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/DatasetAssemblerTDB1.java
similarity index 69%
rename from 
jena-tdb/src/main/java/org/apache/jena/tdb/assembler/DatasetAssemblerTDB.java
rename to 
jena-tdb/src/main/java/org/apache/jena/tdb/assembler/DatasetAssemblerTDB1.java
index 9c2feaf..33309d0 100644
--- 
a/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/DatasetAssemblerTDB.java
+++ 
b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/DatasetAssemblerTDB1.java
@@ -22,13 +22,11 @@ import static 
org.apache.jena.sparql.util.graph.GraphUtils.exactlyOneProperty ;
 import static org.apache.jena.sparql.util.graph.GraphUtils.getStringValue ;
 import static org.apache.jena.tdb.assembler.VocabTDB.pLocation ;
 import static org.apache.jena.tdb.assembler.VocabTDB.pUnionDefaultGraph ;
+
 import org.apache.jena.assembler.Assembler ;
-import org.apache.jena.assembler.Mode ;
 import org.apache.jena.assembler.exceptions.AssemblerException ;
 import org.apache.jena.atlas.logging.Log ;
 import org.apache.jena.graph.Node ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
 import org.apache.jena.rdf.model.Resource ;
 import org.apache.jena.sparql.core.DatasetGraph ;
 import org.apache.jena.sparql.core.assembler.AssemblerUtils ;
@@ -39,40 +37,39 @@ import org.apache.jena.tdb.TDB ;
 import org.apache.jena.tdb.TDBFactory ;
 import org.apache.jena.tdb.base.file.Location ;
 
-public class DatasetAssemblerTDB extends DatasetAssembler
+public class DatasetAssemblerTDB1 extends DatasetAssembler
 {
     static { JenaSystem.init(); }
-    
+
     @Override
-    public Dataset createDataset(Assembler a, Resource root, Mode mode) {
-        return make(root) ;
+    public DatasetGraph createDataset(Assembler a, Resource root) {
+        return make(a, root);
     }
 
-    static Dataset make(Resource root) {
+    public static DatasetGraph make(Assembler a, Resource root) {
         if ( !exactlyOneProperty(root, pLocation) )
-            throw new AssemblerException(root, "No location given") ;
+            throw new AssemblerException(root, "No location given");
 
-        String dir = getStringValue(root, pLocation) ;
-        Location loc = Location.create(dir) ;
-        DatasetGraph dsg = TDBFactory.createDatasetGraph(loc) ;
+        String dir = getStringValue(root, pLocation);
+        Location loc = Location.create(dir);
+        DatasetGraph dsg = TDBFactory.createDatasetGraph(loc);
 
         if ( root.hasProperty(pUnionDefaultGraph) ) {
-            Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode() 
;
-            NodeValue nv = NodeValue.makeNode(b) ;
+            Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode();
+            NodeValue nv = NodeValue.makeNode(b);
             if ( nv.isBoolean() )
-                dsg.getContext().set(TDB.symUnionDefaultGraph, 
nv.getBoolean()) ;
+                dsg.getContext().set(TDB.symUnionDefaultGraph, 
nv.getBoolean());
             else
-                Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value 
for union graph setting (ignored): " + b) ;
+                Log.warn(DatasetAssemblerTDB1.class, "Failed to recognize 
value for union graph setting (ignored): " + b);
         }
 
         /*
-        <r> rdf:type tdb:DatasetTDB ;
-            tdb:location "dir" ;
-            //ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue 
"10000" ] ;
-            tdb:unionGraph true ; # or "true"
-        */
+            <r> rdf:type tdb:DatasetTDB2;
+                tdb:location "dir";
+                //ja:context [ ja:cxtName "arq:queryTimeout";  ja:cxtValue 
"10000" ] ;
+                tdb:unionGraph true; # or "true"
+         */
         AssemblerUtils.mergeContext(root, dsg.getContext());
-        return DatasetFactory.wrap(dsg) ; 
+        return dsg;
     }
-    
 }
diff --git 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDBGraphAssembler.java
 b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/TDB1GraphAssembler.java
similarity index 66%
rename from 
jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDBGraphAssembler.java
rename to 
jena-tdb/src/main/java/org/apache/jena/tdb/assembler/TDB1GraphAssembler.java
index a5e8300..572dd70 100644
--- 
a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/assembler/TDBGraphAssembler.java
+++ 
b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/TDB1GraphAssembler.java
@@ -16,35 +16,39 @@
  * limitations under the License.
  */
 
-package org.apache.jena.tdb2.assembler;
+package org.apache.jena.tdb.assembler;
 
-import static org.apache.jena.sparql.util.graph.GraphUtils.getAsStringValue;
-import static org.apache.jena.sparql.util.graph.GraphUtils.getResourceValue;
-import static org.apache.jena.sparql.util.graph.GraphUtils.getStringValue;
-import static org.apache.jena.tdb2.assembler.VocabTDB2.*;
+import static org.apache.jena.sparql.util.graph.GraphUtils.getAsStringValue ;
+import static org.apache.jena.sparql.util.graph.GraphUtils.getResourceValue ;
+import static org.apache.jena.sparql.util.graph.GraphUtils.getStringValue ;
+import static org.apache.jena.tdb.assembler.VocabTDB.*;
 
-import org.apache.jena.assembler.Assembler;
-import org.apache.jena.assembler.Mode;
-import org.apache.jena.assembler.assemblers.AssemblerBase;
-import org.apache.jena.assembler.exceptions.AssemblerException;
-import org.apache.jena.atlas.logging.Log;
-import org.apache.jena.dboe.base.file.Location;
-import org.apache.jena.query.Dataset;
+import org.apache.jena.assembler.Assembler ;
+import org.apache.jena.assembler.Mode ;
+import org.apache.jena.assembler.assemblers.AssemblerBase ;
+import org.apache.jena.assembler.exceptions.AssemblerException ;
+import org.apache.jena.atlas.logging.Log ;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.NodeFactory;
 import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
 import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.tdb2.TDB2;
-import org.apache.jena.tdb2.TDB2Factory;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sys.JenaSystem;
+import org.apache.jena.tdb.TDBFactory ;
+import org.apache.jena.tdb.base.file.Location ;
 
-public class TDBGraphAssembler extends AssemblerBase implements Assembler
+public class TDB1GraphAssembler extends AssemblerBase implements Assembler
 {
+    static { JenaSystem.init(); }
+
     @Override
-    public Model open(Assembler a, Resource root, Mode mode)
-    {
-        // In case we go via explicit index construction,
-        // although given we got here, the assembler is wired in
-        // and that probably means TDB.init
-        TDB2.init();
+    public Model open(Assembler a, Resource root, Mode mode) {
+        Graph g = createGraph(a, root, mode);
+        return ModelFactory.createModelForGraph(g);
+    }
 
+    public Graph createGraph(Assembler a, Resource root, Mode mode) {
         // Make a model - the default model of the TDB dataset
         // [] rdf:type tdb:GraphTDB;
         //    tdb:location "dir";
@@ -73,21 +77,21 @@ public class TDBGraphAssembler extends AssemblerBase 
implements Assembler
         if ( root.hasProperty(pIndex) )
             Log.warn(this, "Custom indexes not implemented yet - ignored");
 
-        final Dataset ds;
+        DatasetGraph dsg;
 
         if ( locationDir != null )
         {
             Location location = Location.create(locationDir);
-            ds = TDB2Factory.connectDataset(location);
+            dsg = TDBFactory.createDatasetGraph(location);
         }
         else
-            ds = DatasetAssemblerTDB.make(dataset);
+            dsg = DatasetAssemblerTDB1.make(a, dataset);
 
         try {
             if ( graphName != null )
-                return ds.getNamedModel(graphName);
+                return dsg.getGraph(NodeFactory.createURI(graphName));
             else
-                return ds.getDefaultModel();
+                return dsg.getDefaultGraph();
         } catch (RuntimeException ex)
         {
             ex.printStackTrace(System.err);
diff --git 
a/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/TDBGraphAssembler.java 
b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/TDBGraphAssembler.java
deleted file mode 100644
index 9dffe04..0000000
--- 
a/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/TDBGraphAssembler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.tdb.assembler;
-
-import static org.apache.jena.sparql.util.graph.GraphUtils.getAsStringValue ;
-import static org.apache.jena.sparql.util.graph.GraphUtils.getResourceValue ;
-import static org.apache.jena.sparql.util.graph.GraphUtils.getStringValue ;
-import static org.apache.jena.tdb.assembler.VocabTDB.pDataset ;
-import static org.apache.jena.tdb.assembler.VocabTDB.pGraphName1 ;
-import static org.apache.jena.tdb.assembler.VocabTDB.pGraphName2 ;
-import static org.apache.jena.tdb.assembler.VocabTDB.pIndex ;
-import static org.apache.jena.tdb.assembler.VocabTDB.pLocation ;
-
-import org.apache.jena.assembler.Assembler ;
-import org.apache.jena.assembler.Mode ;
-import org.apache.jena.assembler.assemblers.AssemblerBase ;
-import org.apache.jena.assembler.exceptions.AssemblerException ;
-import org.apache.jena.atlas.logging.Log ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.rdf.model.* ;
-import org.apache.jena.riot.out.NodeFmtLib ;
-import org.apache.jena.tdb.TDBException ;
-import org.apache.jena.tdb.TDBFactory ;
-import org.apache.jena.tdb.base.file.Location ;
-
-public class TDBGraphAssembler extends AssemblerBase implements Assembler
-{
-    static IndexAssembler indexAssembler = null ; 
-    
-    @Override
-    public Model open(Assembler a, Resource root, Mode mode)
-    {
-        // Make a model - the default model of the TDB dataset
-        // [] rdf:type tdb:GraphTDB ;
-        //    tdb:location "dir" ;
-        
-        // Make a named model.
-        // [] rdf:type tdb:GraphTDB ;
-        //    tdb:location "dir" ;
-        //    tdb:graphName <http://example/name> ;
-
-        // Location or dataset reference.
-        String locationDir = getStringValue(root, pLocation) ;
-        Resource dataset = getResourceValue(root, pDataset) ;
-        
-        if ( locationDir != null && dataset != null )
-            throw new AssemblerException(root, "Both location and dataset 
given: exactly one required") ; 
-        
-        if ( locationDir == null && dataset == null )
-            throw new AssemblerException(root, "Must give location or refer to 
a dataset description") ;
-        
-        String graphName = null ;
-        if ( root.hasProperty(pGraphName1) )
-            graphName = getAsStringValue(root, pGraphName1) ;
-        if ( root.hasProperty(pGraphName2) )
-            graphName = getAsStringValue(root, pGraphName2) ;
-
-        if ( root.hasProperty(pIndex) )
-            Log.warn(this, "Custom indexes not implemented yet - ignored") ;
-
-        final Dataset ds ;
-        
-        if ( locationDir != null )
-        {
-            Location location = Location.create(locationDir) ;
-            ds = TDBFactory.createDataset(location) ;
-        }
-        else
-            ds = DatasetAssemblerTDB.make(dataset) ;
-
-        try {
-            if ( graphName != null )
-                return ds.getNamedModel(graphName) ;
-            else
-                return ds.getDefaultModel() ;
-        } catch (RuntimeException ex)
-        {
-            ex.printStackTrace(System.err) ;
-            throw ex ;
-        }
-    }
-    
-    //@Unused
-    private void indexes(Resource root)
-    {
-        // ---- API ways
-
-        StmtIterator sIter = root.listProperties(pIndex) ;
-        while(sIter.hasNext())
-        {
-            RDFNode obj = sIter.nextStatement().getObject() ;
-            if ( obj.isLiteral() )
-            {
-                String desc = ((Literal)obj).getString() ;
-                System.out.printf("Index: %s\n", desc) ; System.out.flush();
-                continue ;
-            }
-            throw new TDBException("Wrong format for tdb:index: should be a 
string: found: "+NodeFmtLib.displayStr(obj)) ; 
-            //          Resource x = (Resource)obj ;
-            //          String desc = x.getProperty(pDescription).getString() ;
-            //          String file = x.getProperty(pFile).getString() ;
-            //          System.out.printf("Index: %s in file %s\n", desc, 
file) ; System.out.flush();
-        }
-
-        System.out.flush();
-        throw new TDBException("Custom indexes turned off") ; 
-    }
-
-}
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/VocabTDB.java 
b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/VocabTDB.java
index 4fcd8bb..b7f9ba1 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/VocabTDB.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/assembler/VocabTDB.java
@@ -26,8 +26,8 @@ import org.apache.jena.tdb.TDB ;
 public class VocabTDB
 {
     private static final String NS = TDB.namespace ;
-    
-    public static String getURI() { return NS ; } 
+
+    public static String getURI() { return NS ; }
 
     // Types
     public static final Resource tDatasetTDB        = Vocab.type(NS, 
"DatasetTDB") ;
@@ -38,12 +38,12 @@ public class VocabTDB
 
     public static final Property pLocation          = Vocab.property(NS, 
"location") ;
     public static final Property pUnionDefaultGraph = Vocab.property(NS, 
"unionDefaultGraph") ;
-    
+
     public static final Property pIndex             = Vocab.property(NS, 
"index") ;
     public static final Property pGraphName1        = Vocab.property(NS, 
"graphName") ;
     public static final Property pGraphName2        = Vocab.property(NS, 
"namedGraph") ;
     public static final Property pDataset           = Vocab.property(NS, 
"dataset") ;
-    
+
     public static final Property pNodes             = Vocab.property(NS, 
"nodes") ;
 
     // Indexes
@@ -53,21 +53,21 @@ public class VocabTDB
     // Nodes
     public static final Property pNodeIndex         = Vocab.property(getURI(), 
"nodeIndex") ;
     public static final Property pNodeData          = Vocab.property(getURI(), 
"nodeData") ;
-    
+
     // Setting
     public static final Property pSetting           = Vocab.property(getURI(), 
"setting") ;
     public static final Property pName              = Vocab.property(getURI(), 
"name") ;
     public static final Property pValue             = Vocab.property(getURI(), 
"value") ;
-    
-    private static boolean initialized = false ; 
-    
+
+    private static boolean initialized = false ;
+
     static { init() ; }
-    
+
     static synchronized public void init() {
         if ( initialized )
             return;
         initialized = true;
-        AssemblerUtils.registerDataset(tDatasetTDB, new DatasetAssemblerTDB());
-        AssemblerUtils.registerModel(tGraphTDB, new TDBGraphAssembler());
+        AssemblerUtils.registerDataset(tDatasetTDB, new 
DatasetAssemblerTDB1());
+        AssemblerUtils.registerModel(tGraphTDB, new TDB1GraphAssembler());
     }
 }
diff --git 
a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextDatasetAssembler.java
 
b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextDatasetAssembler.java
index c444feb..1ede105 100644
--- 
a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextDatasetAssembler.java
+++ 
b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextDatasetAssembler.java
@@ -27,7 +27,6 @@ import java.lang.reflect.Constructor ;
 
 import org.apache.jena.assembler.Assembler ;
 import org.apache.jena.assembler.Mode ;
-import org.apache.jena.assembler.assemblers.AssemblerBase ;
 import org.apache.jena.atlas.logging.Log ;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.query.text.TextDatasetFactory ;
@@ -36,10 +35,11 @@ import org.apache.jena.query.text.TextIndex ;
 import org.apache.jena.rdf.model.Resource ;
 import org.apache.jena.sparql.ARQConstants ;
 import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.assembler.DatasetAssembler;
 import org.apache.jena.sparql.util.ClsLoader ;
 import org.apache.jena.sparql.util.graph.GraphUtils ;
 
-public class TextDatasetAssembler extends AssemblerBase implements Assembler
+public class TextDatasetAssembler extends DatasetAssembler implements Assembler
 {
     public static Resource getType() { return textDataset ; }
 
@@ -52,6 +52,12 @@ public class TextDatasetAssembler extends AssemblerBase 
implements Assembler
      */
 
     @Override
+    public DatasetGraph createDataset(Assembler a, Resource root) {
+        // Should have come via open();
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
     public Dataset open(Assembler a, Resource root, Mode mode)
     {
         Resource dataset = GraphUtils.getResourceValue(root, pDataset) ;
@@ -95,6 +101,5 @@ public class TextDatasetAssembler extends AssemblerBase 
implements Assembler
             return null;
         }
     }
-
 }
 

Reply via email to