void startProcessInstance ( ProcessInstance processInstanceVO , int delay ) throws ProcessException { try { Process process = getProcessDefinition ( processInstanceVO ) ; edao . setProcessInstanceStatus ( processInstanceVO . getId ( ) , WorkStatus . STATUS_PENDING_PROCESS ) ; // setProcessInstanceStatus will really set to STATUS_IN_PROGRESS - hint to set START_DT as well if ( logger . isInfoEnabled ( ) ) { logger . info ( logtag ( processInstanceVO . getProcessId ( ) , processInstanceVO . getId ( ) , processInstanceVO . getMasterRequestId ( ) ) , WorkStatus . LOGMSG_PROC_START + " - " + process . getQualifiedName ( ) + ( processInstanceVO . isEmbedded ( ) ? ( " (embedded process " + process . getId ( ) + ")" ) : ( "/" + process . getVersionString ( ) ) ) ) ; } notifyMonitors ( processInstanceVO , WorkStatus . LOGMSG_PROC_START ) ; // get start activity ID Long startActivityId ; if ( processInstanceVO . isEmbedded ( ) ) { edao . setProcessInstanceStatus ( processInstanceVO . getId ( ) , WorkStatus . STATUS_PENDING_PROCESS ) ; startActivityId = process . getStartActivity ( ) . getId ( ) ; } else { Activity startActivity = process . getStartActivity ( ) ; if ( startActivity == null ) { throw new ProcessException ( "Transition has not been defined for START event! ProcessID = " + process . getId ( ) ) ; } startActivityId = startActivity . getId ( ) ; } InternalEvent event = InternalEvent . createActivityStartMessage ( startActivityId , processInstanceVO . getId ( ) , null , processInstanceVO . getMasterRequestId ( ) , EventType . EVENTNAME_START + ":" ) ; if ( delay > 0 ) { String msgid = ScheduledEvent . INTERNAL_EVENT_PREFIX + processInstanceVO . getId ( ) + "start" + startActivityId ; this . sendDelayedInternalEvent ( event , delay , msgid , false ) ; } else sendInternalEvent ( event ) ; } catch ( Exception ex ) { logger . severeException ( ex . getMessage ( ) , ex ) ; throw new ProcessException ( ex . getMessage ( ) ) ; } }
Starting a process instance which has been created already . The method sets the status to In Progress find the start activity and sends an internal message to start the activity