private void deleteArchivedFlowNodeInstanceElements(final SAFlowNodeInstance activityInstance) throws SFlowNodeReadException, SBonitaSearchException, SConnectorInstanceDeletionException, SDataInstanceException { if (activityInstance instanceof SAActivityInstance) { dataInstanceService.deleteLocalArchivedDataInstances( activityInstance.getSourceObjectId(), DataInstanceContainer.ACTIVITY_INSTANCE.toString()); connectorInstanceService.deleteArchivedConnectorInstances( activityInstance.getSourceObjectId(), SConnectorInstance.FLOWNODE_TYPE); if (SFlowNodeType.USER_TASK.equals(activityInstance.getType()) || SFlowNodeType.MANUAL_TASK.equals(activityInstance.getType())) { try { activityService.deleteArchivedPendingMappings(activityInstance.getSourceObjectId()); } catch (final SActivityModificationException e) { throw new SFlowNodeReadException(e); } } } }
private void deleteFlowNodeInstanceElements( final SFlowNodeInstance flowNodeInstance, final SProcessDefinition processDefinition) throws SBonitaException { if (flowNodeInstance.getType().equals(SFlowNodeType.INTERMEDIATE_CATCH_EVENT)) { bpmEventInstanceService.deleteWaitingEvents(flowNodeInstance); } if (flowNodeInstance instanceof SEventInstance) { bpmEventInstanceService.deleteEventTriggerInstances(flowNodeInstance.getId()); } else if (flowNodeInstance instanceof SActivityInstance) { deleteDataInstancesIfNecessary(flowNodeInstance, processDefinition); deleteConnectorInstancesIfNecessary(flowNodeInstance, processDefinition); if (SFlowNodeType.USER_TASK.equals(flowNodeInstance.getType()) || SFlowNodeType.MANUAL_TASK.equals(flowNodeInstance.getType())) { activityService.deleteHiddenTasksForActivity(flowNodeInstance.getId()); try { activityService.deletePendingMappings(flowNodeInstance.getId()); } catch (final SActivityModificationException e) { throw new SFlowNodeReadException(e); } } else if (SFlowNodeType.CALL_ACTIVITY.equals(flowNodeInstance.getType()) || SFlowNodeType.SUB_PROCESS.equals(flowNodeInstance.getType())) { // in the case of a call activity or subprocess activity delete the child process instance try { deleteProcessInstance(getChildOfActivity(flowNodeInstance.getId())); } catch (final SProcessInstanceNotFoundException e) { final StringBuilder stb = new StringBuilder(); stb.append("Can't find the process instance called by the activity [id: "); stb.append(flowNodeInstance.getId()); stb.append(", name: "); stb.append(flowNodeInstance.getName()); stb.append("]. This process may be already finished"); // if the child process is not found, it's because it has already finished and archived or // it was not created if (logger.isLoggable(getClass(), TechnicalLogSeverity.DEBUG)) { logger.log(getClass(), TechnicalLogSeverity.DEBUG, stb.toString()); logger.log(getClass(), TechnicalLogSeverity.DEBUG, e); } } } } }