]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGConfigurer.java
Clean up and support internal seed resources in tg export
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / TGConfigurer.java
index 350f4ca31d966b5bda61e7e570286e4488a8a0e6..4e23fa5750968ab64624843146da008ddc9ce9c9 100644 (file)
@@ -13,14 +13,15 @@ import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus;
-import org.simantics.db.layer0.util.TransferableGraphConfiguration2.RootSpec;
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2.SeedSpec;
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2.SeedSpec.SeedSpecType;
 import org.simantics.layer0.Layer0;
 
 public class TGConfigurer {
 
        final private ReadGraph graph;
-       final Collection<RootSpec> roots = new ArrayList<RootSpec>();
-       final Map<Resource, ExtentStatus> preStatus = new HashMap<Resource, ExtentStatus>();
+       final Collection<SeedSpec> roots = new ArrayList<>();
+       final Map<Resource, ExtentStatus> preStatus = new HashMap<>();
        final boolean ignoreVirtualResources;
        final boolean validate;
        
@@ -41,13 +42,12 @@ public class TGConfigurer {
                return this;
        }
 
-       public TGConfigurer roots(Collection<RootSpec> rs) throws DatabaseException {
+       public TGConfigurer roots(Collection<SeedSpec> rs) throws DatabaseException {
                Layer0 L0 = Layer0.getInstance(graph);
-               for(RootSpec root : rs) {
+               for(SeedSpec root : rs) {
                        Resource nameResource = graph.getPossibleObject(root.resource, L0.HasName);
                        if(nameResource != null) preStatus.put(nameResource, ExtentStatus.EXCLUDED);
-//                     String name = graph.getValue(nameResource, Bindings.STRING);
-                       roots.add(new RootSpec(root.resource, root.name, root.internal, root.type));
+                       roots.add(new SeedSpec(root.resource, root.name, root.specType, root.type));
                        preStatus.put(root.resource, ExtentStatus.INTERNAL);
                }
                return this;
@@ -63,7 +63,7 @@ public class TGConfigurer {
                                if(name == null) name = "<no name>";
                                preStatus.put(nameResource, ExtentStatus.EXCLUDED);
                        }
-                       roots.add(new RootSpec(root, name, true));
+                       roots.add(new SeedSpec(root, name, SeedSpecType.ROOT));
                        preStatus.put(root, ExtentStatus.INTERNAL);
                }
                return this;
@@ -73,8 +73,7 @@ public class TGConfigurer {
                Layer0 L0 = Layer0.getInstance(graph);
                for(NamedResource root : rs) {
                        Resource nameResource = graph.getPossibleObject(root.getResource(), L0.HasName);
-//                     String name = graph.getValue(nameResource, Bindings.STRING);
-                       roots.add(new RootSpec(root.getResource(), root.getName(), true));
+                       roots.add(new SeedSpec(root.getResource(), root.getName(), SeedSpecType.ROOT));
                        preStatus.put(root.getResource(), ExtentStatus.INTERNAL);
                        preStatus.put(nameResource, ExtentStatus.EXCLUDED);
                }
@@ -91,9 +90,9 @@ public class TGConfigurer {
 
                // -Exclude owners if not explicitly defined
                Layer0 L0 = Layer0.getInstance(graph);
-               ArrayList<Resource> rootList = new ArrayList<Resource>();
-               for (RootSpec root : roots) {
-                       if(root.internal) {
+               ArrayList<Resource> rootList = new ArrayList<>();
+               for (SeedSpec root : roots) {
+                       if(!SeedSpecType.SPECIAL_ROOT.equals(root.specType)) {
                                rootList.add(root.resource);
                                for (Resource owner : graph.getObjects(root.resource, L0.IsOwnedBy)) {
                                        ExtentStatus ownerStatus = preStatus.get(owner);