From 60b1c19ed45029edd23d3b2e7a724e6cd5b70c1e Mon Sep 17 00:00:00 2001
From: Simon Barner <barner@fortiss.org>
Date: Wed, 30 Nov 2016 14:13:45 +0000
Subject: [PATCH] Element connection compositors: Do not explicitly prepare IDs
 for newly created connectors. - This will be performed by the
 IElementCompositorService that is called from createNewSourceDropContext(). -
 Doing it here already, will trigger an expensive check for duplicate IDs when
 the ID assignment is issued for the second time from the
 IElementCompositorService refs 2759

---
 ...torHierarchicElementConnectionCompositorBase.java | 11 +++++------
 .../HierarchicElementConnectionCompositorBase.java   | 12 +++++-------
 ...chicElementConnectorConnectionCompositorBase.java | 10 +++++-----
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/ConnectorHierarchicElementConnectionCompositorBase.java b/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/ConnectorHierarchicElementConnectionCompositorBase.java
index d5e620c4d..3d49531e9 100644
--- a/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/ConnectorHierarchicElementConnectionCompositorBase.java
+++ b/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/ConnectorHierarchicElementConnectionCompositorBase.java
@@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
  * @author igna
  * @author $Author: hoelzl $
  * @version $Rev: 18709 $
- * @ConQAT.Rating GREEN Hash: 527D8AA1B59F1A259BADEA1609C00555
+ * @ConQAT.Rating YELLOW Hash: B65DD76817032940B5C3BC3BF3B1125D
  */
 public abstract class ConnectorHierarchicElementConnectionCompositorBase<HE extends IHierarchicElement, S extends IConnector, T extends IHierarchicElement>
 		extends ConnectionCompositorBase<HE, S, T> {
@@ -56,16 +56,15 @@ public abstract class ConnectorHierarchicElementConnectionCompositorBase<HE exte
 	/** {@inheritDoc} */
 	@Override
 	public boolean connect(S source, T target, HE parent, IConnectionCompositionContext context) {
-		ITopLevelElement topElement =
-				IPersistencyService.getInstance().getTopLevelElementFor(parent);
 		boolean isSrcEntry = source instanceof EntryConnectorBase;
 		isSrcEntry = sameParent(target, source) ? isSrcEntry : !isSrcEntry;
 		IConnector conn = isSrcEntry ? createEntryConnector() : createExitConnector();
 		avoidDuplicateConnectorName(target, conn);
-		if(topElement != null) {
-			topElement.prepareIDs(conn);
-		}
+
 		createNewTargetDropContext(target, context, conn);
+
+		ITopLevelElement topElement =
+				IPersistencyService.getInstance().getTopLevelElementFor(parent);
 		createConnection(source, conn, parent, topElement);
 		return true;
 	}
diff --git a/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectionCompositorBase.java b/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectionCompositorBase.java
index bf48d2cd0..6f072034b 100644
--- a/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectionCompositorBase.java
+++ b/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectionCompositorBase.java
@@ -29,7 +29,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
  * @author hoelzl
  * @author $Author$
  * @version $Rev$
- * @ConQAT.Rating YELLOW Hash: 7A3C53940D04EA617F6AB4B38AB87C9E
+ * @ConQAT.Rating YELLOW Hash: 6DB675BD3A0953264509F4D152177632
  */
 public abstract class HierarchicElementConnectionCompositorBase<HE extends IHierarchicElement, S extends IHierarchicElement, T extends IHierarchicElement>
 		extends ConnectionCompositorBase<HE, S, T> {
@@ -59,14 +59,12 @@ public abstract class HierarchicElementConnectionCompositorBase<HE extends IHier
 		// And conversely entry connectors are target connectors.
 		IConnector targetConnector = createEntryConnector();
 		avoidDuplicateConnectorName(target, targetConnector);
-		ITopLevelElement topElement =
-				IPersistencyService.getInstance().getTopLevelElementFor(parent);
-		if(topElement != null) {
-			topElement.prepareIDs(sourceConnector);
-			topElement.prepareIDs(targetConnector);
-		}
+
 		createNewSourceDropContext(source, context, sourceConnector);
 		createNewTargetDropContext(target, context, targetConnector);
+
+		ITopLevelElement topElement =
+				IPersistencyService.getInstance().getTopLevelElementFor(parent);
 		createConnection(sourceConnector, targetConnector, parent, topElement);
 		return true;
 	}
diff --git a/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectorConnectionCompositorBase.java b/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectorConnectionCompositorBase.java
index d14d0ee4d..6638bab26 100644
--- a/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectorConnectionCompositorBase.java
+++ b/org.fortiss.tooling.base/trunk/src/org/fortiss/tooling/base/compose/HierarchicElementConnectorConnectionCompositorBase.java
@@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
  * @author igna
  * @author $Author: hoelzl $
  * @version $Rev: 18709 $
- * @ConQAT.Rating GREEN Hash: BE31FD9962A2EA352648CB1EA34FDEAE
+ * @ConQAT.Rating YELLOW Hash: 2A6272E51C04314F65C60044D767BCB4
  */
 public abstract class HierarchicElementConnectorConnectionCompositorBase<HE extends IHierarchicElement, S extends IHierarchicElement, T extends IConnector>
 		extends ConnectionCompositorBase<HE, S, T> {
@@ -63,15 +63,15 @@ public abstract class HierarchicElementConnectorConnectionCompositorBase<HE exte
 	/** {@inheritDoc} */
 	@Override
 	public boolean connect(S source, T target, HE parent, IConnectionCompositionContext context) {
-		ITopLevelElement topElement = IPersistencyService.getInstance().getTopLevelElementFor(parent);
 		boolean isTargetEntry = target instanceof EntryConnectorBase;
 		isTargetEntry = sameParent(source, target) ? isTargetEntry : !isTargetEntry;
 		IConnector conn = isTargetEntry ? createEntryConnector() : createExitConnector();
 		avoidDuplicateConnectorName(source, conn);
-		if(topElement != null) {
-			topElement.prepareIDs(conn);
-		}
+
 		createNewSourceDropContext(source, context, conn);
+
+		ITopLevelElement topElement =
+				IPersistencyService.getInstance().getTopLevelElementFor(parent);
 		createConnection(conn, target, parent, topElement);
 		return true;
 	}
-- 
GitLab