@SuppressWarnings("unchecked") public Object deleteProcessInstance( Context context, ProcessInstance pi, ProcessDefinition process) { Session session = context.getSession(); List<ProcessInstance> instances = session .createQuery("from " + ProcessInstance.class.getName() + " where parentId=:parentId") .setLong("parentId", pi.getId()) .list(); for (ProcessInstance instance : instances) { deleteProcessInstance(context, instance, process); session .createQuery("delete " + Variable.class.getName() + " where processInstanceId=:pIId") .setLong("pIId", instance.getId()) .executeUpdate(); } session .createQuery("delete " + Variable.class.getName() + " where processInstanceId=:pIId") .setLong("pIId", pi.getId()) .executeUpdate(); process.getNode(pi.getCurrentNode()).cancel(context, pi); session.delete(pi); context.getExpressionContext().removeContext(pi); return null; }
public Object execute(Context context) { ProcessDefinition process = context.getProcessService().getProcessById(processInstance.getProcessId()); deleteProcessInstance(context, processInstance, process); return null; }