ProcessDefinitionBehavior processDefinition = null;
if (processDefinitionId != null) {
processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new FixFlowException("通过 processDefinitionId 没有找到指定流程 = '" + processDefinitionId + "'");
}
} else if (processDefinitionKey != null) {
processDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(processDefinitionKey);
if (processDefinition == null) {
throw new FixFlowException("通过 processDefinitionKey 没有找到指定流程 '" + processDefinitionKey + "'");
}
} else {
throw new FixFlowException("processDefinitionKey 和 processDefinitionId 不能都为空");
}
ProcessInstanceEntity processInstanceEntity = null;
try {
/*if(parentProcessInstance!=null){
if(parentProcessInstanceToken!=null){
processInstanceEntity=new ProcessInstanceEntity(processDefinition, businessKey, parentProcessInstance, (TokenEntity) parentProcessInstanceToken);
}
else{
throw new FixFlowException("子流程启动失败");
}
}
else{
processInstanceEntity = processDefinition.createProcessInstance(businessKey);
}*/
processInstanceEntity = processDefinition.createProcessInstance(businessKey);
processInstanceEntity.setStartAuthor(startAuthor);
if(this.initiator!=null&&!this.initiator.equals("")){
processInstanceEntity.setInitiatorWithoutCascade(this.initiator);
}
processInstanceEntity.getContextInstance().setTransientVariableMap(transientVariables);
processInstanceEntity.getContextInstance().setVariableMap(variables);
processInstanceEntity.noneStart();
commandContext.getProcessInstanceManager().saveProcessInstance(processInstanceEntity);
} catch (Exception e) {
throw new FixFlowException("流程实例启动异常! "+ e.getMessage(), e);
}
return processInstanceEntity;
}