@Override
  protected Object doExecute() throws Exception {
    ProcessEngine processEngine = this.getProcessEngine();
    if (processEngine == null) {
      out().println("Process Engine NOT Found!");
      return null;
    }

    RuntimeService runtimeService = processEngine.getRuntimeService();

    if (this.instanceIDs != null && this.instanceIDs.length > 0) {
      for (String instanceID : instanceIDs) {
        runtimeService.deleteProcessInstance(instanceID, "Forcefully terminating the instance");
        out().printf("Process instance %s terminated\n", instanceID);
      }
      return null;
    }

    if (!killAll) {
      out().println("Process instance IDs required or use the command with -a or --all option");
      return null;
    } else {
      out().println("Signalling all executions in all active process instances...");
      List<ProcessInstance> piList =
          runtimeService.createProcessInstanceQuery().orderByProcessInstanceId().asc().list();
      for (ProcessInstance pi : piList) {
        String instanceID = pi.getProcessInstanceId();
        runtimeService.deleteProcessInstance(instanceID, "Forcefully terminating the instance");
        out().printf("Process instance %s terminated\n", instanceID);
      }
    }

    return null;
  }
 @Override
 public void deleteProcessInstance(Long dossierId) {
   ProcessInstance pi =
       runtimeService
           .createProcessInstanceQuery()
           .processInstanceBusinessKey(dossierId.toString())
           .singleResult();
   if (pi != null) {
     runtimeService.deleteProcessInstance(pi.getProcessInstanceId(), "delete from back office");
   }
 }
示例#3
0
 /**
  * 删除部署的流程实例
  *
  * @param procInsId 流程实例ID
  * @param deleteReason 删除原因,可为空
  */
 @Transactional(readOnly = false)
 public void deleteProcIns(String procInsId, String deleteReason) {
   runtimeService.deleteProcessInstance(procInsId, deleteReason);
 }
示例#4
0
  public String removeProcessInstance() {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.deleteProcessInstance(processInstanceId, deleteReason);

    return RELOAD_PROCESS_INSTANCE;
  }