public Object getPersistentState() { List<Object> state = new ArrayList<Object>(8); state.add(getSerializerName()); state.add(textValue); state.add(textValue2); state.add(this.state); state.add(doubleValue); state.add(longValue); state.add(processDefinitionId); state.add(processDefinitionKey); state.add(getByteArrayId()); return state; }
public String getVariableTypeName() { return getTypeName(); }
protected void deleteHistoricVariableInstancesByProcessCaseInstanceId(String historicProcessInstanceId, String historicCaseInstanceId) { ensureOnlyOneNotNull("Only the process instance or case instance id should be set", historicProcessInstanceId, historicCaseInstanceId); if (isHistoryEnabled()) { // delete entries in DB List<HistoricVariableInstance> historicVariableInstances; if (historicProcessInstanceId != null) { historicVariableInstances = findHistoricVariableInstancesByProcessInstanceId(historicProcessInstanceId); } else { historicVariableInstances = findHistoricVariableInstancesByCaseInstanceId(historicCaseInstanceId); } for (HistoricVariableInstance historicVariableInstance : historicVariableInstances) { ((HistoricVariableInstanceEntity) historicVariableInstance).delete(); } // delete entries in Cache List <HistoricVariableInstanceEntity> cachedHistoricVariableInstances = getDbEntityManager().getCachedEntitiesByType(HistoricVariableInstanceEntity.class); for (HistoricVariableInstanceEntity historicVariableInstance : cachedHistoricVariableInstances) { // make sure we only delete the right ones (as we cannot make a proper query in the cache) if ((historicProcessInstanceId != null && historicProcessInstanceId.equals(historicVariableInstance.getProcessInstanceId())) || (historicCaseInstanceId != null && historicCaseInstanceId.equals(historicVariableInstance.getCaseInstanceId()))) { historicVariableInstance.delete(); } } } }
@Override public void checkDeleteHistoricVariableInstance(HistoricVariableInstanceEntity variable) { if (variable != null && !getTenantManager().isAuthenticatedTenant(variable.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("delete the historic variable instance '" + variable.getId() + "'"); } }
HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if(historicVariableInstanceEntity != null) { historicVariableInstanceEntity.updateFromEvent(historyEvent); historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_CREATED); HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if(historicVariableInstanceEntity != null) { historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_DELETED);
@Deployment public void testTwoSubProcessInParallelWithinSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoSubProcessInParallelWithinSubProcess"); assertProcessEnded(processInstance.getId()); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().orderByVariableName().asc().list(); assertEquals(2, variables.size()); HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0); assertEquals("myVar", historicVariable.getName()); assertEquals("test101112", historicVariable.getTextValue()); assertEquals("string", historicVariable.getVariableTypeName()); assertEquals("string", historicVariable.getTypeName()); HistoricVariableInstanceEntity historicVariable1 = (HistoricVariableInstanceEntity) variables.get(1); assertEquals("myVar1", historicVariable1.getName()); assertEquals("test789", historicVariable1.getTextValue()); assertEquals("string", historicVariable1.getVariableTypeName()); assertEquals("string", historicVariable1.getTypeName()); assertEquals(18, historyService.createHistoricActivityInstanceQuery().count()); if (isFullHistoryEnabled()) { assertEquals(7, historyService.createHistoricDetailQuery().count()); } }
@Test public void shouldResolveByteArray_SetVariable() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when runtimeService.setVariable(processInstance.getId(), "aVariableName", new ByteArrayInputStream("hello world".getBytes())); HistoricVariableInstanceEntity historicVariableInstance = (HistoricVariableInstanceEntity) historyService.createHistoricVariableInstanceQuery().singleResult(); ByteArrayEntity byteArray = findByteArrayById(historicVariableInstance.getByteArrayId()); // assume assertThat(byteArray, notNullValue()); // then assertThat(byteArray.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
public void deleteHistoricVariableInstanceByVariableInstanceId(String historicVariableInstanceId) { if (isHistoryEnabled()) { HistoricVariableInstanceEntity historicVariableInstance = findHistoricVariableInstanceByVariableInstanceId(historicVariableInstanceId); if (historicVariableInstance != null) { historicVariableInstance.delete(); } } }
protected boolean shouldFetchValue(HistoricVariableInstanceEntity entity) { // do not fetch values for byte arrays eagerly (unless requested by the user) return isByteArrayFetchingEnabled || !AbstractTypedValueSerializer.BINARY_VALUE_TYPES.contains(entity.getSerializer().getType().getName()); }
@Override public void checkDeleteHistoricVariableInstance(HistoricVariableInstanceEntity variable) { if (variable != null && variable.getProcessDefinitionKey() != null) { getAuthorizationManager().checkAuthorization(DELETE_HISTORY, PROCESS_DEFINITION, variable.getProcessDefinitionKey()); } // XXX if CAM-6570 is implemented, there should be a check for variables of standalone tasks here as well }
HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if(historicVariableInstanceEntity != null) { historicVariableInstanceEntity.updateFromEvent(historyEvent); historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_CREATED); HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if(historicVariableInstanceEntity != null) { historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_DELETED);
@Deployment public void testTwoSubProcessInParallelWithinSubProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoSubProcessInParallelWithinSubProcess"); assertProcessEnded(processInstance.getId()); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().orderByVariableName().asc().list(); assertEquals(2, variables.size()); HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0); assertEquals("myVar", historicVariable.getName()); assertEquals("test101112", historicVariable.getTextValue()); assertEquals("string", historicVariable.getVariableTypeName()); assertEquals("string", historicVariable.getTypeName()); HistoricVariableInstanceEntity historicVariable1 = (HistoricVariableInstanceEntity) variables.get(1); assertEquals("myVar1", historicVariable1.getName()); assertEquals("test789", historicVariable1.getTextValue()); assertEquals("string", historicVariable1.getVariableTypeName()); assertEquals("string", historicVariable1.getTypeName()); assertEquals(18, historyService.createHistoricActivityInstanceQuery().count()); if (isFullHistoryEnabled()) { assertEquals(7, historyService.createHistoricDetailQuery().count()); } }
@Test public void shouldResolveByteArray_SetVariable() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when runtimeService.setVariable(processInstance.getId(), "aVariableName", new ByteArrayInputStream("hello world".getBytes())); HistoricVariableInstanceEntity historicVariableInstance = (HistoricVariableInstanceEntity) historyService.createHistoricVariableInstanceQuery().singleResult(); ByteArrayEntity byteArray = findByteArrayById(historicVariableInstance.getByteArrayId()); // assume assertThat(byteArray, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Override public void checkDeleteHistoricVariableInstance(HistoricVariableInstanceEntity variable) { if (variable != null && !getTenantManager().isAuthenticatedTenant(variable.getTenantId())) { throw LOG.exceptionCommandWithUnauthorizedTenant("delete the historic variable instance '" + variable.getId() + "'"); } }
public void deleteHistoricVariableInstanceByVariableInstanceId(String historicVariableInstanceId) { if (isHistoryEnabled()) { HistoricVariableInstanceEntity historicVariableInstance = findHistoricVariableInstanceByVariableInstanceId(historicVariableInstanceId); if (historicVariableInstance != null) { historicVariableInstance.delete(); } } }
protected boolean shouldFetchValue(HistoricVariableInstanceEntity entity) { // do not fetch values for byte arrays eagerly (unless requested by the user) return isByteArrayFetchingEnabled || !AbstractTypedValueSerializer.BINARY_VALUE_TYPES.contains(entity.getSerializer().getType().getName()); }
@Override public void checkDeleteHistoricVariableInstance(HistoricVariableInstanceEntity variable) { if (variable != null && variable.getProcessDefinitionKey() != null) { getAuthorizationManager().checkAuthorization(DELETE_HISTORY, PROCESS_DEFINITION, variable.getProcessDefinitionKey()); } // XXX if CAM-6570 is implemented, there should be a check for variables of standalone tasks here as well }
public Object getPersistentState() { List<Object> state = new ArrayList<Object>(8); state.add(getSerializerName()); state.add(textValue); state.add(textValue2); state.add(this.state); state.add(doubleValue); state.add(longValue); state.add(processDefinitionId); state.add(processDefinitionKey); state.add(getByteArrayId()); return state; }
protected void deleteHistoricVariableInstancesByProcessCaseInstanceId(String historicProcessInstanceId, String historicCaseInstanceId) { ensureOnlyOneNotNull("Only the process instance or case instance id should be set", historicProcessInstanceId, historicCaseInstanceId); if (isHistoryEnabled()) { // delete entries in DB List<HistoricVariableInstance> historicVariableInstances; if (historicProcessInstanceId != null) { historicVariableInstances = findHistoricVariableInstancesByProcessInstanceId(historicProcessInstanceId); } else { historicVariableInstances = findHistoricVariableInstancesByCaseInstanceId(historicCaseInstanceId); } for (HistoricVariableInstance historicVariableInstance : historicVariableInstances) { ((HistoricVariableInstanceEntity) historicVariableInstance).delete(); } // delete entries in Cache List <HistoricVariableInstanceEntity> cachedHistoricVariableInstances = getDbEntityManager().getCachedEntitiesByType(HistoricVariableInstanceEntity.class); for (HistoricVariableInstanceEntity historicVariableInstance : cachedHistoricVariableInstances) { // make sure we only delete the right ones (as we cannot make a proper query in the cache) if ((historicProcessInstanceId != null && historicProcessInstanceId.equals(historicVariableInstance.getProcessInstanceId())) || (historicCaseInstanceId != null && historicCaseInstanceId.equals(historicVariableInstance.getCaseInstanceId()))) { historicVariableInstance.delete(); } } } }
HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if(historicVariableInstanceEntity != null) { historicVariableInstanceEntity.updateFromEvent(historyEvent); historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_CREATED); HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if(historicVariableInstanceEntity != null) { historicVariableInstanceEntity.setState(HistoricVariableInstance.STATE_DELETED);