public WorkflowInstanceImpl startInitialize(TriggerInstance triggerInstance) {
WorkflowId workflowId = getLatestWorkflowId(triggerInstance);
WorkflowImpl workflow = getWorkflowImpl(workflowId);
LockImpl lock = new LockImpl();
lock.setTime(Time.now());
lock.setOwner(getId());
WorkflowInstanceId workflowInstanceId = triggerInstance.getWorkflowInstanceId();
if (workflowInstanceId==null) {
workflowInstanceId = workflowInstanceStore.generateWorkflowInstanceId();
}
WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl(
configuration,
workflow,
workflowInstanceId,
triggerInstance,
lock,
triggerInstance.getTransientData());
if (log.isDebugEnabled()) log.debug("Created "+workflowInstance);
if (workflow.trigger!=null) {
workflow.trigger.applyTriggerData(workflowInstance, triggerInstance);
} else {
workflowInstance.setVariableValues(triggerInstance);
}
notifyWorkflowInstanceStarted(workflowInstance);
return workflowInstance;
}