use of org.jbpm.persistence.correlation.CorrelationPropertyInfo in project jbpm by kiegroup.
the class JPAProcessInstanceManager method addProcessInstance.
public void addProcessInstance(ProcessInstance processInstance, CorrelationKey correlationKey) {
ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo(processInstance, this.kruntime.getEnvironment());
ProcessPersistenceContext context = ((ProcessPersistenceContextManager) this.kruntime.getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER)).getProcessPersistenceContext();
processInstanceInfo = (ProcessInstanceInfo) context.persist(processInstanceInfo);
((org.jbpm.process.instance.ProcessInstance) processInstance).setId(processInstanceInfo.getId());
processInstanceInfo.updateLastReadDate();
// generate correlation key if not given which is same as process instance id to keep uniqueness
if (correlationKey == null) {
correlationKey = new CorrelationKeyInfo();
((CorrelationKeyInfo) correlationKey).addProperty(new CorrelationPropertyInfo(null, processInstanceInfo.getId().toString()));
((org.jbpm.process.instance.ProcessInstance) processInstance).getMetaData().put("CorrelationKey", correlationKey);
}
CorrelationKeyInfo correlationKeyInfo = (CorrelationKeyInfo) correlationKey;
correlationKeyInfo.setProcessInstanceId(processInstanceInfo.getId());
context.persist(correlationKeyInfo);
internalAddProcessInstance(processInstance);
EventManagerProvider.getInstance().get().create(new ProcessInstanceView(processInstance));
}
Aggregations