]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java
Only claim new identifier if instance L0.TypeWithIdentifier
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / mapping / ComponentCopyAdvisor.java
index b58aef5ff395a13522e5ac3172079f11622cad9e..b7ed06795788877bbdd440ec20dc8c211543d35e 100644 (file)
  *******************************************************************************/
 package org.simantics.modeling.mapping;
 
-import gnu.trove.map.hash.THashMap;
-
 import java.util.Map;
+import java.util.Set;
 
 import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
-import org.simantics.datatypes.literal.GUID;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.diagram.synchronization.ISynchronizationContext;
 import org.simantics.diagram.synchronization.SynchronizationException;
 import org.simantics.diagram.synchronization.SynchronizationHints;
@@ -35,6 +34,8 @@ import org.simantics.modeling.services.NamingException;
 import org.simantics.project.IProject;
 import org.simantics.structural.stubs.StructuralResource2;
 
+import gnu.trove.map.hash.THashMap;
+
 /**
  * @author Tuukka Lehtonen
  */
@@ -59,7 +60,8 @@ public class ComponentCopyAdvisor extends GraphCopyAdvisor {
             Resource targetContainer, Map<Object, Object> map) throws DatabaseException {
         StructuralResource2 STR = StructuralResource2.getInstance(graph);
         Resource copy = null;
-        if (graph.isInstanceOf(source, STR.Connection)) {
+        Set<Resource> types = graph.getTypes(source);
+        if (types.contains(STR.Connection)) {
             // Configuration connections are not named, can't use TG copy for
             // them at the moment.
             copy = CopyAdvisorUtil.copy2(graph, source, null, map);
@@ -73,7 +75,8 @@ public class ComponentCopyAdvisor extends GraphCopyAdvisor {
         if (graph.hasStatement(sourceContainer, L0.ConsistsOf, source))
             graph.claim(targetContainer, L0.ConsistsOf, copy);
 
-        graph.claimLiteral(copy, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING);
+        if (types.contains(L0.TypeWithIdentifier))
+            Layer0Utils.claimNewIdentifier(graph, copy, false);
         if (context.get(SynchronizationHints.NO_RENAME) == null)
             renameComponent(context, graph, source, copy, sourceContainer, targetContainer);
         return copy;