public static void reConnect(BPMNShape shape, Diagram diagram) {
try {
ModelHandler handler = ModelHandler.getInstance(diagram);
for (BPMNEdge bpmnEdge : handler.getAll(BPMNEdge.class)) {
DiagramElement sourceElement = bpmnEdge.getSourceElement();
DiagramElement targetElement = bpmnEdge.getTargetElement();
if (sourceElement != null && targetElement != null) {
boolean sourceMatches = sourceElement.getId().equals(shape.getId());
boolean targetMatches = targetElement.getId().equals(shape.getId());
if (sourceMatches || targetMatches) {
updateEdge(bpmnEdge, diagram);
}
}
}