public PersistentWorkItem merge(PersistentWorkItem workItemInfo) { String key = createWorkItemKey(workItemInfo.getId()); workItemInfo.transform(); EntityHolder entityHolder = new EntityHolder(key, workItemInfo); cache.put(key, entityHolder); return workItemInfo; }
public PersistentWorkItem persist(PersistentWorkItem workItemInfo) { if (workItemInfo.getId() == null) { workItemInfo.setId(generateWorkItemInfoId()); } String key = createWorkItemKey(workItemInfo.getId()); workItemInfo.transform(); cache.put(key, new EntityHolder(key, workItemInfo)); return workItemInfo; }
public void commit(boolean transactionOwner) { // Do not check if the caller is the transactionOwner // because there's no need to "wait" for a commit try{ for(PersistentSession session : session.getStoredKnowledgeSessions()){ session.transform(); storage.saveOrUpdate(session); } for(PersistentWorkItem workItem : session.getStoredWorkItems()){ workItem.transform(); storage.saveOrUpdate( workItem ); } try{ transactionSynchronization.afterCompletion(TransactionManager.STATUS_COMMITTED); } catch (RuntimeException re){ logger.warn("Unable to synchronize transaction after commit, see cause.", re); } } catch (RuntimeException re) { transactionSynchronization.afterCompletion(TransactionManager.STATUS_ROLLEDBACK); } // We shouldn't clear session here because by doing so // we lose track of this objects on successive interactions }
public EntityHolder(String key, PersistentWorkItem workItem) { this.key = key; this.type = "workItemInfo"; workItem.transform(); this.workItemInfoId = workItem.getId(); WorkItemInfo workItemInfo = (WorkItemInfo) workItem; this.workItemInfoName = workItemInfo.getName(); this.workItemInfoVersion = workItemInfo.getVersion(); this.workItemInfoProcessInstanceId = workItemInfo.getProcessInstanceId(); this.workItemInfoState = workItemInfo.getState(); this.workItemInfoCreationDate = workItemInfo.getCreationDate(); this.workItemInfoByteArray = Base64.encodeBase64String(workItemInfo.getWorkItemByteArray()); }