public void removeArc(Object id) {
ArcModel arcToDelete = getElementContainer().getArcById(id);
if (arcToDelete != null) {
AbstractPetriNetElementModel sourceElement = getElementContainer()
.getElementById(arcToDelete.getSourceId());
AbstractPetriNetElementModel targetElement = getElementContainer()
.getElementById(arcToDelete.getTargetId());
if (sourceElement.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
OperatorTransitionModel currentOperator = (OperatorTransitionModel) sourceElement;
// Register the removal of an outgoing arc
currentOperator.registerOutgoingConnectionRemoval(this,
targetElement);
currentOperator.getSimpleTransContainer()
.removeSourceArcsFromElement(arcToDelete.getTargetId());
// Each inner transition container contains a local copy of each
// element connecting to an operator
// We have to remove this local copy
currentOperator.getSimpleTransContainer().removeElement(
targetElement.getId());
} else if (targetElement.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
OperatorTransitionModel currentOperator = (OperatorTransitionModel) targetElement;
// Register the removal of an incoming arc
currentOperator.registerIncomingConnectionRemoval(this,
sourceElement);
currentOperator.getSimpleTransContainer()
.removeTargetArcsFromElement(arcToDelete.getSourceId());
// Each inner transition container contains a local copy of each
// element connecting to an operator
// We have to remove this local copy
currentOperator.getSimpleTransContainer().removeElement(
sourceElement.getId());
LoggerManager.debug(Constants.CORE_LOGGER,
"INNER ARC TO SOURCE deleted");
}
// remove element from the subprocess model
if (targetElement.getType() == AbstractPetriNetElementModel.SUBP_TYPE) {
((SubProcessModel) targetElement).getSimpleTransContainer()
.removeElement(sourceElement.getId());
}
if (sourceElement.getType() == AbstractPetriNetElementModel.SUBP_TYPE) {
((SubProcessModel) sourceElement).getSimpleTransContainer()
.removeElement(targetElement.getId());
}
getElementContainer().removeArc(arcToDelete);
}