@Override public void deleteProcessInstances(final Collection<ProcessInstanceUUID> instanceUUIDs) throws InstanceNotFoundException, UndeletableInstanceException { if (instanceUUIDs != null) { for (final ProcessInstanceUUID instanceUUID : instanceUUIDs) { deleteProcessInstance(instanceUUID); } } }
private void deleteAllProcessInstances(final ProcessDefinition process) throws ProcessNotFoundException, UndeletableInstanceException { FacadeUtil.checkArgsNotNull(process); final ProcessDefinitionUUID processUUID = process.getUUID(); final Querier querier = EnvTool.getAllQueriers(); List<InternalProcessInstance> parentProcessInstances = querier.getParentProcessInstances(processUUID, 0, 200); do { for (final InternalProcessInstance parentProcessInstance : parentProcessInstances) { try { deleteProcessInstance(parentProcessInstance.getUUID()); } catch (final InstanceNotFoundException infe) { final String message = ExceptionManager.getInstance().getFullMessage("bai_RAPII_6"); throw new BonitaInternalException(message, infe); } } parentProcessInstances = querier.getParentProcessInstances(processUUID, 0, 200); } while (!parentProcessInstances.isEmpty()); final Set<InternalProcessInstance> instances = querier.getProcessInstances(processUUID); if (instances != null && !instances.isEmpty()) { final ProcessInstance first = instances.iterator().next(); throw new UndeletableInstanceException("bai_RAPII_7", first.getUUID(), first.getParentInstanceUUID()); } }
public void deleteAllProcessInstances(ProcessDefinitionUUID processUUID) throws ProcessNotFoundException, UndeletableInstanceException { FacadeUtil.checkArgsNotNull(processUUID); Querier querier = EnvTool.getAllQueriers(); ProcessFullDefinition process = querier.getProcess(processUUID); if (process == null) { throw new ProcessNotFoundException(processUUID); } Set<ProcessFullInstance> instances = querier.getProcessInstances(processUUID); for (ProcessFullInstance instance : instances) { //deletes only parent instances if (instance.getParentInstanceUUID() == null) { try { deleteProcessInstance(instance.getUUID()); } catch (InstanceNotFoundException e) { throw new BonitaInternalException("Invalid state", e); } } } instances = querier.getProcessInstances(processUUID); if (instances != null && !instances.isEmpty()) { ProcessInstance first = instances.iterator().next(); throw new UndeletableInstanceException(first.getUUID(), first.getParentInstanceUUID()); } }
for (final InternalProcessInstance internalProcessInstance : parentInstances) { try { runtimeAPI.deleteProcessInstance(internalProcessInstance.getUUID()); } catch (final InstanceNotFoundException e) { throw new BonitaRuntimeException("Unable to delete process instance: " + internalProcessInstance.getUUID());