+ Resource connectionToKeep = attachToConnection;\r
+ Resource connectionToRemove = flagConnection;\r
+ if (!connectionToKeep.equals(connectionToRemove)) {\r
+ Resource hasElementToComponent1 = graph.getPossibleObject(attachToConnection, MOD.ElementToComponent);\r
+ Resource hasElementToComponent2 = graph.getPossibleObject(flagConnection, MOD.ElementToComponent);\r
+ Type flagType = FlagUtil.getFlagType(graph, flagToRemove);\r
+ if (hasElementToComponent1 != null && hasElementToComponent2 != null)\r
+ throw new UnsupportedOperationException(\r
+ "Both attached connection " + attachToConnection + " and flag connection " + flagConnection\r
+ + " have mapped components, can't decide which connection to remove in join operation");\r
+ if (hasElementToComponent2 != null || flagType == Type.Out) {\r
+ connectionToKeep = flagConnection;\r
+ connectionToRemove = attachToConnection;\r
+ }\r
+ }\r
+\r