// get the activity itself to determine its boundary events
final Activity activity = (Activity) getBusinessObjectForPictogramElement(shape);
ILocation shapeLocationAfterMove = Graphiti.getLayoutService().getLocationRelativeToDiagram(shape);
moveActivityChilds(activity, shapeLocationAfterMove);
Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
if (context.getSourceContainer() != context.getTargetContainer()) {
if (context.getSourceContainer() instanceof Diagram == false) {
Object containerBo = getFeatureProvider().getBusinessObjectForPictogramElement(context.getSourceContainer());
if (containerBo instanceof SubProcess) {
SubProcess subProcess = (SubProcess) containerBo;
subProcess.removeFlowElement(activity.getId());
for (SequenceFlow flow : activity.getOutgoingFlows()) {
subProcess.removeFlowElement(flow.getId());
}
for (BoundaryEvent event : activity.getBoundaryEvents()) {
subProcess.removeFlowElement(event.getId());
}
} else if (containerBo instanceof Lane) {
Lane lane = (Lane) containerBo;
lane.getFlowReferences().remove(activity.getId());
lane.getParentProcess().removeFlowElement(activity.getId());
for (SequenceFlow flow : activity.getOutgoingFlows()) {
lane.getParentProcess().removeFlowElement(flow.getId());
}
for (BoundaryEvent event : activity.getBoundaryEvents()) {
lane.getParentProcess().removeFlowElement(event.getId());
}
}
} else {
if (model.getBpmnModel().getMainProcess() != null) {
model.getBpmnModel().getMainProcess().removeFlowElement(activity.getId());
for (SequenceFlow flow : activity.getOutgoingFlows()) {
model.getBpmnModel().getMainProcess().removeFlowElement(flow.getId());
}
for (BoundaryEvent event : activity.getBoundaryEvents()) {
model.getBpmnModel().getMainProcess().removeFlowElement(event.getId());
}
}
}
if (context.getTargetContainer() instanceof Diagram == false) {
Object containerBo = getFeatureProvider().getBusinessObjectForPictogramElement(context.getTargetContainer());
if (containerBo instanceof SubProcess) {
SubProcess subProcess = (SubProcess) containerBo;
subProcess.addFlowElement(activity);
for (SequenceFlow flow : activity.getOutgoingFlows()) {
subProcess.addFlowElement(flow);
}
for (BoundaryEvent event : activity.getBoundaryEvents()) {
subProcess.addFlowElement(event);
}
} else if (containerBo instanceof Lane) {
Lane lane = (Lane) containerBo;
lane.getFlowReferences().add(activity.getId());
lane.getParentProcess().addFlowElement(activity);
for (SequenceFlow flow : activity.getOutgoingFlows()) {
lane.getParentProcess().addFlowElement(flow);
}
for (BoundaryEvent event : activity.getBoundaryEvents()) {
lane.getParentProcess().addFlowElement(event);
}
}
} else {
if (model.getBpmnModel().getMainProcess() == null) {
model.addMainProcess();
}
model.getBpmnModel().getMainProcess().addFlowElement(activity);
for (SequenceFlow flow : activity.getOutgoingFlows()) {
model.getBpmnModel().getMainProcess().addFlowElement(flow);
}
for (BoundaryEvent event : activity.getBoundaryEvents()) {
model.getBpmnModel().getMainProcess().addFlowElement(event);
}
}
}
}