Search in sources :

Example 1 with CorrelationPropertyInfo

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));
}
Also used : CorrelationPropertyInfo(org.jbpm.persistence.correlation.CorrelationPropertyInfo) CorrelationKeyInfo(org.jbpm.persistence.correlation.CorrelationKeyInfo) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ProcessPersistenceContextManager(org.jbpm.persistence.api.ProcessPersistenceContextManager) ProcessPersistenceContext(org.jbpm.persistence.api.ProcessPersistenceContext) ProcessInstanceView(org.jbpm.persistence.api.integration.model.ProcessInstanceView)

Aggregations

ProcessPersistenceContext (org.jbpm.persistence.api.ProcessPersistenceContext)1 ProcessPersistenceContextManager (org.jbpm.persistence.api.ProcessPersistenceContextManager)1 ProcessInstanceView (org.jbpm.persistence.api.integration.model.ProcessInstanceView)1 CorrelationKeyInfo (org.jbpm.persistence.correlation.CorrelationKeyInfo)1 CorrelationPropertyInfo (org.jbpm.persistence.correlation.CorrelationPropertyInfo)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)1