public boolean execute(ProcessInstance processInstance) { log.debug("{}",this); for (ProcessDefinition subProcess:m_subProcess) { ProcessInstance subprocessInstance = new ProcessInstance(); subprocessInstance.setBundleName(processInstance.getBundleName()); subProcess.startProcess(subprocessInstance); processInstance.getChildProcesses().add(subprocessInstance); subprocessInstance.setObjectInstance(processInstance.getObjectInstance()); subprocessInstance.setParentProcess(processInstance); log.debug("subprocess launched: {}",subprocessInstance.getProcessDefinitionName()); } ProcessInstanceUtils.clearQueue(processInstance); processInstance.setWaitCount(m_subProcess.size()); log.debug("{} subprocesses launched for: {} {}",processInstance.getWaitCount(),processInstance.getProcessDefinitionName(),processInstance.getId()); return false; }
protected void launchOneCyclicSubprocess(ProcessInstance processInstance) { ProcessInstance subProcess = new ProcessInstance(); subProcess.setBundleName(processInstance.getBundleName()); getSubProcess().startProcess(subProcess); processInstance.getChildProcesses().add(subProcess); subProcess.setObjectInstance(processInstance.getObjectInstance()); subProcess.setParentProcess(processInstance); log.debug("subprocess launched: {}",subProcess.getProcessDefinitionName()); ProcessInstanceUtils.clearQueue(processInstance); processInstance.setWaitCount(1); log.debug("subprocess launched for: {} {}",processInstance.getProcessDefinitionName(),processInstance.getId()); }
public boolean execute(ProcessInstance processInstance) { log.debug("{}",this); WorkflowManager workflowManager = getOwnerProcess().getWorkflowManager(); List<?> list = (List<?>)workflowManager.getField(processInstance, getFd()); if (!list.isEmpty()) { for (Object o:list) { ProcessInstance subProcess = new ProcessInstance(); subProcess.setBundleName(processInstance.getBundleName()); getSubProcess().startProcess(subProcess); processInstance.getChildProcesses().add(subProcess); subProcess.setObjectInstance(workflowManager.createContextDescriptor(o)); subProcess.setParentProcess(processInstance); log.debug("subprocess launched: {}",subProcess.getProcessDefinitionName()); } ProcessInstanceUtils.clearQueue(processInstance); processInstance.setWaitCount(list.size()); log.debug("{} subprocesses launched for: {} {}",processInstance.getWaitCount(),processInstance.getProcessDefinitionName(),processInstance.getId()); } return false; } }
@Transactional public ProcessInstance launch(String processName, Object context, String comment, String bundleName, ProcessInstance processInstance) { ProcessDefinition processDefinition = getProcessDefinition(processName); if (processDefinition == null) { throw new WorkflowException("Failed to find process definition named "+processName); } Object mergedContext = getContextDAO().mergeContext(context); processInstance.setComment(comment==null?" ":comment); processInstance.setBundleName(bundleName); processInstance.setObjectInstance(getContextDAO().createContextDescriptor(mergedContext)); if (!ContextUtils.getContextClass(processInstance.getObjectInstance()).equals(mergedContext.getClass())) { throw new WorkflowException("Context object does not match process context in "+processName); } processDefinition.startProcess(processInstance); ProcessInstance processInstanceRet = getWorkflowDAO().mergeProcessInstance(processInstance); getWorkflowDAO().flush(); return processInstanceRet; }
@Transactional public long save(WorkflowForm workflowForm) { Object context = getContextDAO().mergeContext(workflowForm.getContext()); ProcessInstance processInstance = workflowForm.getProcessInstance(); processInstance.setLastUpdated(new Timestamp(System.currentTimeMillis())); processInstance.setObjectInstance(createContextDescriptor(context)); ProcessInstance pi = null; if (processInstance.getId() == 0) { processInstance.setTaskId(0L); TaskBase task = getTask(workflowForm.getProcessDefinition(),0L); pi = getWorkflowDAO().mergeProcessInstance(processInstance); Audit audit = createAudit(pi, task); audit.setStatus(TaskStatus.DONE); } else { TaskBase task = getCurrentTask(processInstance); pi = getWorkflowDAO().mergeProcessInstance(processInstance); createAudit(pi, task); } return pi.getId(); } @Transactional