final String creatorId, final String parentProcessInstanceId,
final String parentTaskInstanceId) throws EngineException,
KernelException {
final String wfprocessId = workflowProcessId;
final WorkflowDefinition workflowDef = runtimeContext.getDefinitionService().getTheLatestVersionOfWorkflowDefinition(wfprocessId);
final WorkflowProcess wfProcess = workflowDef.getWorkflowProcess();
if (wfProcess == null) {
throw new RuntimeException(
"Workflow process NOT found,id=[" + wfprocessId
+ "]");
}
IProcessInstance processInstance = (IProcessInstance) this.execute(new IWorkflowSessionCallback() {
public Object doInWorkflowSession(RuntimeContext ctx)
throws EngineException, KernelException {
ProcessInstance processInstance = new ProcessInstance();
processInstance.setCreatorId(creatorId);
processInstance.setProcessId(wfProcess.getId());
processInstance.setVersion(workflowDef.getVersion());
processInstance.setDisplayName(wfProcess.getDisplayName());
processInstance.setName(wfProcess.getName());
processInstance.setState(IProcessInstance.INITIALIZED);
processInstance.setCreatedTime(ctx.getCalendarService()
.getSysDate());