protected Map<String, List<VariableInstance>> getSortedVariableInstances(Collection<String> variableNames, Collection<String> variableScopeIds) { List<VariableInstance> variableInstances = queryVariablesInstancesByVariableScopeIds(variableNames, variableScopeIds); Map<String, List<VariableInstance>> sortedVariableInstances = new HashMap<>(); for (VariableInstance variableInstance : variableInstances) { String variableScopeId = ((VariableInstanceEntity) variableInstance).getVariableScopeId(); if (!sortedVariableInstances.containsKey(variableScopeId)) { sortedVariableInstances.put(variableScopeId, new ArrayList<VariableInstance>()); } sortedVariableInstances.get(variableScopeId).add(variableInstance); } return sortedVariableInstances; }
public static VariableInstanceEntity create(String name, TypedValue value, boolean isTransient) { return new VariableInstanceEntity(name, value, isTransient); }
public void addVariableInternal(VariableInstanceEntity variable) { if (variableStore.containsKey(variable.getName())) { VariableInstanceEntity existingVariable = variableStore.getVariable(variable.getName()); existingVariable.setValue(variable.getTypedValue()); variable.delete(); } else { variableStore.addVariable(variable); } }
public void clearValueFields() { this.longValue = null; this.doubleValue = null; this.textValue = null; this.textValue2 = null; typedValueField.clear(); if(byteArrayField.getByteArrayId() != null) { deleteByteArrayValue(); setByteArrayValueId(null); } }
evt.setVariableInstanceId(variableInstance.getId()); evt.setProcessInstanceId(variableInstance.getProcessInstanceId()); evt.setExecutionId(variableInstance.getExecutionId()); evt.setCaseInstanceId(variableInstance.getCaseInstanceId()); evt.setCaseExecutionId(variableInstance.getCaseExecutionId()); evt.setTaskId(variableInstance.getTaskId()); evt.setRevision(variableInstance.getRevision()); evt.setVariableName(variableInstance.getName()); evt.setSerializerName(variableInstance.getSerializerName()); evt.setTenantId(variableInstance.getTenantId()); evt.setUserOperationId(Context.getCommandContext().getOperationId()); ExecutionEntity execution = variableInstance.getExecution(); if (execution != null) { ProcessDefinitionEntity definition = execution.getProcessDefinition(); CaseExecutionEntity caseExecution = variableInstance.getCaseExecution(); if (caseExecution != null) { CaseDefinitionEntity definition = (CaseDefinitionEntity) caseExecution.getCaseDefinition(); evt.setTextValue(variableInstance.getTextValue()); evt.setTextValue2(variableInstance.getTextValue2()); evt.setDoubleValue(variableInstance.getDoubleValue()); evt.setLongValue(variableInstance.getLongValue()); if (variableInstance.getByteArrayValueId() != null) { evt.setByteValue(variableInstance.getByteArrayValue());
public String getVariableName() { return variable.getName(); }
@Override public Void execute(CommandContext commandContext) { //create a variable VariableInstanceEntity variable = VariableInstanceEntity.createAndInsert("aVariable", Variables.byteArrayValue(new byte[0])); String byteArrayId = variable.getByteArrayValueId(); //delete the variable variable.delete(); //check if the variable is deleted transient //-> no insert and delete stmt will be flushed DbEntityManager dbEntityManager = commandContext.getDbEntityManager(); CachedDbEntity cachedEntity = dbEntityManager.getDbEntityCache().getCachedEntity(ByteArrayEntity.class, byteArrayId); DbEntityState entityState = cachedEntity.getEntityState(); assertEquals(DbEntityState.DELETED_TRANSIENT, entityState); return null; } });
@Override public String toString() { return this.getClass().getSimpleName() + "[id=" + id + ", revision=" + revision + ", name=" + name + ", processInstanceId=" + processInstanceId + ", executionId=" + executionId + ", caseInstanceId=" + caseInstanceId + ", caseExecutionId=" + caseExecutionId + ", taskId=" + taskId + ", activityInstanceId=" + activityInstanceId + ", tenantId=" + tenantId + ", longValue=" + longValue + ", doubleValue=" + doubleValue + ", textValue=" + textValue + ", textValue2=" + textValue2 + ", byteArrayValueId=" + getByteArrayValueId() + ", configuration=" + configuration + ", isConcurrentLocal=" + isConcurrentLocal + "]"; }
protected void moveVariableTo(VariableInstanceEntity variable, ExecutionEntity other) { if (other.variableStore.containsKey(variable.getName())) { CoreVariableInstance existingInstance = other.variableStore.getVariable(variable.getName()); existingInstance.setValue(variable.getTypedValue(false)); invokeVariableLifecycleListenersUpdate(existingInstance, this); invokeVariableLifecycleListenersDelete( variable, this, Collections.singletonList(getVariablePersistenceListener())); } else { other.variableStore.addVariable(variable); } }
public Void execute(CommandContext commandContext) { ExecutionEntity execution = commandContext.getExecutionManager() .findExecutionById(executionId); // fetch the variable instance but not the value (make sure the byte array is lazily fetched) VariableInstanceEntity varInstance = (VariableInstanceEntity) execution.getVariableInstanceLocal(varName); String byteArrayValueId = varInstance.getByteArrayValueId(); assertNotNull("Byte array id is expected to be not null", byteArrayValueId); CachedDbEntity cachedByteArray = commandContext.getDbEntityManager().getDbEntityCache() .getCachedEntity(ByteArrayEntity.class, byteArrayValueId); assertNull("Byte array is expected to be not fetched yet / lazily fetched.", cachedByteArray); monitor.sync(); // now update the value execution.setVariableLocal(varInstance.getName(), newValue); return null; }
@Override public void onDelete(VariableInstanceEntity variable, AbstractVariableScope sourceScope) { variable.delete(); }
public void delete() { if (!isTransient()) { typedValueField.notifyImplicitValueUpdate(); } // clear value clearValueFields(); if (!isTransient) { // delete variable Context.getCommandContext().getDbEntityManager().delete(this); } }
public Void execute(CommandContext commandContext) { ExecutionEntity execution = commandContext.getExecutionManager() .findExecutionById(executionId); // fetch the variable instance but not the value (make sure the byte array is lazily fetched) VariableInstanceEntity varInstance = (VariableInstanceEntity) execution.getVariableInstanceLocal(varName); String byteArrayValueId = varInstance.getByteArrayValueId(); assertNotNull("Byte array id is expected to be not null", byteArrayValueId); CachedDbEntity cachedByteArray = commandContext.getDbEntityManager().getDbEntityCache() .getCachedEntity(ByteArrayEntity.class, byteArrayValueId); assertNull("Byte array is expected to be not fetched yet / lazily fetched.", cachedByteArray); monitor.sync(); // now trigger the fetching of the byte array Object value = varInstance.getValue(); assertNull("Expecting the value to be null (deleted)", value); return null; }
task4.setId("107"); variable1 = new VariableInstanceEntity(); variable1.setId("108"); variable2 = new VariableInstanceEntity(); variable2.setId("109"); variable3 = new VariableInstanceEntity(); variable3.setId("110"); variable4 = new VariableInstanceEntity(); variable4.setId("111");
public Void execute(CommandContext commandContext) { ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(processInstanceId); VariableInstanceEntity varInstance = (VariableInstanceEntity) execution.getVariableInstance(VARIABLE_NAME); HistoricVariableInstanceEntity historicVariableInstance = commandContext.getHistoricVariableInstanceManager() .findHistoricVariableInstanceByVariableInstanceId(varInstance.getId()); historicByteArrayId[0] = historicVariableInstance.getByteArrayValueId(); return null; } });
public void setValue(TypedValue value) { // clear value fields clearValueFields(); typedValueField.setValue(value); }
public ExecutionEntity getExecution() { ensureExecutionInitialized(); return execution; }
@Override public VariableInstanceEntity build(String name, TypedValue value, boolean isTransient) { return VariableInstanceEntity.create(name, value, isTransient); }
evt.setVariableInstanceId(variableInstance.getId()); evt.setProcessInstanceId(variableInstance.getProcessInstanceId()); evt.setExecutionId(variableInstance.getExecutionId()); evt.setCaseInstanceId(variableInstance.getCaseInstanceId()); evt.setCaseExecutionId(variableInstance.getCaseExecutionId()); evt.setTaskId(variableInstance.getTaskId()); evt.setRevision(variableInstance.getRevision()); evt.setVariableName(variableInstance.getName()); evt.setSerializerName(variableInstance.getSerializerName()); evt.setTenantId(variableInstance.getTenantId()); evt.setUserOperationId(Context.getCommandContext().getOperationId()); ExecutionEntity execution = variableInstance.getExecution(); if (execution != null) { ProcessDefinitionEntity definition = execution.getProcessDefinition(); CaseExecutionEntity caseExecution = variableInstance.getCaseExecution(); if (caseExecution != null) { CaseDefinitionEntity definition = (CaseDefinitionEntity) caseExecution.getCaseDefinition(); evt.setTextValue(variableInstance.getTextValue()); evt.setTextValue2(variableInstance.getTextValue2()); evt.setDoubleValue(variableInstance.getDoubleValue()); evt.setLongValue(variableInstance.getLongValue()); if (variableInstance.getByteArrayValueId() != null) { evt.setByteValue(variableInstance.getByteArrayValue());