@Override public ProcessInstance launch(String processName, Object o, String comment, String bundleName) { ProcessDefinition processDefinition = getProcessDefinition(processName); if (processDefinition == null) { throw new WorkflowException("Failed to find process definition named "+processName); } ProcessInstance processInstance = new ProcessInstance(); processInstance.setComment(comment); processInstance.setBundleName(bundleName); return processInstance; }
public WorkflowForm getLaunchForm(String processName) { ProcessDefinition processDefinition = getProcessDefinition(processName); String launchForm = processDefinition.getLaunchForm(); Object context=null; try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); context = Class.forName(processDefinition.getFullClassName(),false,classLoader).newInstance(); } catch (Exception e) { throw new RuntimeException(e); } WorkflowForm workflowForm = m_formFactory.getForm(launchForm); workflowForm.setProcessDefinition(processDefinition); workflowForm.setContext(context); ProcessInstance processInstance = new ProcessInstance(); processInstance.setProcessDefinitionName(processDefinition.getName()); processInstance.setComment(" "); workflowForm.setProcessInstance(processInstance); return workflowForm; }
@Transactional public void processMessage(ProcessInstance processInstance, Message<?> message, MessageMapper messageMapper) { Object context = getContextDAO().getContext(processInstance.getObjectInstance()); processInstance.setStatus(TaskStatus.GO); try { messageMapper.unpackMessage(message, context); } catch (Exception e) { processInstance.setStatus(TaskStatus.ABORTING); processInstance.setComment(e.getMessage()); } log.debug("set status to processInstance {} to {} {}",processInstance.getId(),processInstance.getStatus(),context); getContextDAO().mergeContext(context); getWorkflowDAO().mergeProcessInstance(processInstance); getWorkflowDAO().flush(); if (log.isDebugEnabled()) { getWorkflowDAO().getActiveProcesses(); } }
@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; }
case FORCE_ABORT: ProcessInstanceUtils.clearQueue(processInstance, TaskStatus.ABORTING); processInstance.setComment("Sibling aborted"); break; case SUBPROCESS_END: if (sibling.getStatus() == TaskStatus.ABORTED) { processInstance.setStatus(TaskStatus.ABORTING); processInstance.setComment("Child aborted");