- for (Resource connector : graph.getObjects(flag2, STR.IsConnectedTo)) {\r
- connector2 = graph.getPossibleObject(connector, DIA.AreConnected);\r
- connection2 = ConnectionUtil.getConnection(graph, connector2);\r
- }\r
- if (connection1 == null || connector1 == null || connection2 == null || connector2 == null)\r
- continue;\r
-\r
- // Disconnect flags from their respective edges\r
- // This code relies on the fact that flag terminals are\r
- // functional and can only be connected once. This implies\r
- // that their :DIA.Connectors cannot have more than one\r
- // AreConnected relation.\r
+ }\r
+ }\r
+\r
+ private boolean joinFlagPair(WriteGraph graph, Resource flag1, Resource flag2) throws DatabaseException {\r
+ Type type1 = FlagUtil.getFlagType(graph, flag1);\r
+ Type type2 = FlagUtil.getFlagType(graph, flag2);\r
+\r
+ Resource connector1 = null;\r
+ Resource connector2 = null;\r
+\r
+ Resource connection1 = null;\r
+ Resource connection2 = null;\r
+\r
+ // #7781: prevent joining of flags where one of them or both\r
+ // have no connections to them, i.e. are disconnected.\r
+ // First ensure that both flags are connected to something,\r
+ // even considering joining them.\r
+ for (Resource connector : graph.getObjects(flag1, STR.IsConnectedTo)) {\r
+ connector1 = graph.getPossibleObject(connector, DIA.AreConnected);\r
+ connection1 = ConnectionUtil.getConnection(graph, connector1);\r
+ }\r
+ for (Resource connector : graph.getObjects(flag2, STR.IsConnectedTo)) {\r
+ connector2 = graph.getPossibleObject(connector, DIA.AreConnected);\r
+ connection2 = ConnectionUtil.getConnection(graph, connector2);\r
+ }\r
+ if (connection1 == null || connector1 == null || connection2 == null || connector2 == null)\r
+ return false;\r
+\r
+ // If a flag has more than 1 counterpart it must not be\r
+ // removed because it is a merged flag that has multiple\r
+ // connection joins attached to it.\r
+ boolean removeFlag1 = FlagUtil.countCounterparts(graph, flag1) <= 1;\r
+ boolean removeFlag2 = FlagUtil.countCounterparts(graph, flag2) <= 1;\r
+\r
+ // Disconnect flags from their respective edges\r
+ // This code relies on the fact that flag terminals are\r
+ // functional and can only be connected once. This implies\r
+ // that their :DIA.Connectors cannot have more than one\r
+ // AreConnected relation.\r
+ if (removeFlag1) {\r