]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/NamespaceMigrationStep.java
(refs #7215) Preserve identity types in NamespaceMigrationStep
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / migration / NamespaceMigrationStep.java
index 1262f3909d92bf6895f5a13b15e86d86e103c15a..a0d4f9da5e202f87a893aa76556c942b83c81e1b 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.db.layer0.migration;
 
-import gnu.trove.set.hash.TIntHashSet;
-
 import java.util.ArrayList;
 
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -29,12 +27,19 @@ import org.simantics.graph.refactoring.GraphRefactoringException;
 import org.simantics.graph.refactoring.GraphRefactoringUtils;
 import org.simantics.graph.refactoring.MappingSpecification;
 import org.simantics.graph.refactoring.MappingSpecification.MappingRule;
+import org.simantics.graph.representation.Identity;
+import org.simantics.graph.representation.Internal;
 import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.graph.store.IdentityStore;
 import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import gnu.trove.set.hash.TIntHashSet;
 
 public class NamespaceMigrationStep implements MigrationStep {
-       
+    private static final Logger LOGGER = LoggerFactory.getLogger(NamespaceMigrationStep.class);
+
     final ArrayList<MappingRule> rules;
     
        public NamespaceMigrationStep(ReadGraph graph, Resource step) throws DatabaseException {
@@ -50,7 +55,7 @@ public class NamespaceMigrationStep implements MigrationStep {
                                if(fromURI != null && toURI != null)
                                        rules.add(new MappingRule(fromURI, toURI));
                                else
-                                       System.err.println("Namespace migration uri formation error: base " + base + " from " + from + " to " + to);
+                                   LOGGER.error("Namespace migration uri formation error: base " + base + " from " + from + " to " + to);
                        }
                }
        }
@@ -63,9 +68,13 @@ public class NamespaceMigrationStep implements MigrationStep {
         try {
             MappingSpecification mappingSpec = new MappingSpecification(rules);
             boolean fixed = GraphRefactoringUtils.fixIncorrectRoot(tg.identities);
-            System.err.println("fixed=" + fixed);
+            LOGGER.info("fixed=" + fixed);
             IdentityStore idStore = TransferableGraphConversion.extractIdentities(tg);
-            idStore.printChildMap();
+            // Mark internal identities new
+            for(Identity id : tg.identities)
+                if(id.definition instanceof Internal)
+                    idStore.markNew(id.resource);
+//            idStore.printChildMap();
 //            System.err.println("ids: " + idStore);
 //            System.err.println("rc: " + tg.resourceCount);
 //            System.err.println("idStore: " + idStore.toArray().length);
@@ -79,7 +88,7 @@ public class NamespaceMigrationStep implements MigrationStep {
             if(fixed)
                 GraphRefactoringUtils.unfixIncorrectRoot(tg.identities);
 
-            System.err.println("rc2: " + tg.resourceCount);
+            LOGGER.info("rc2: " + tg.resourceCount);
 //            System.err.println("idStore2: " + idStore.toArray().length);
 
         } catch (GraphRefactoringException e) {