use of org.jbpm.persistence.correlation.CorrelationKeyInfo 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));
}
use of org.jbpm.persistence.correlation.CorrelationKeyInfo in project jbpm by kiegroup.
the class JpaProcessPersistenceContext method remove.
public void remove(PersistentProcessInstance processInstanceInfo) {
getEntityManager().remove(processInstanceInfo);
TransactionManagerHelper.removeFromUpdatableSet(txm, processInstanceInfo);
List<CorrelationKeyInfo> correlations = getEntityManager().createNamedQuery("GetCorrelationKeysByProcessInstanceId").setParameter("pId", processInstanceInfo.getId()).getResultList();
if (correlations != null) {
for (CorrelationKeyInfo key : correlations) {
getEntityManager().remove(key);
}
}
}
Aggregations