]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Only claim new identifier if instance L0.TypeWithIdentifier 53/1653/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 26 Mar 2018 08:29:34 +0000 (11:29 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 26 Mar 2018 11:57:42 +0000 (13:57 +0200)
Fixed long-standing bug from CopyComponentAdvisor which added
identifiers for non-STR.Component instances which has started causing
problems in team server products in version comparisons.

refs #7842

Change-Id: Iac3e604993ec579cd8feb443843af944a8fa01f3
(cherry picked from commit c912edf13bf5a91b2f6dc855f54d8728aa0a64f5)

bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java

index 6b4e59d176860bdeb53387818a00a8d1d696e6db..b7ed06795788877bbdd440ec20dc8c211543d35e 100644 (file)
@@ -11,9 +11,8 @@
  *******************************************************************************/
 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;
@@ -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);
 
-        Layer0Utils.claimNewIdentifier(graph, copy, false);
+        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;