Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getVariable()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getVariable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetExecutionVariableCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
  ensureNotNull("executionId", executionId);
  ensureNotNull("variableName", variableName);

  ExecutionEntity execution = commandContext
    .getExecutionManager()
    .findExecutionById(executionId);

  ensureNotNull("execution " + executionId + " doesn't exist", "execution", execution);

  checkGetExecutionVariable(execution, commandContext);

  Object value;

  if (isLocal) {
    value = execution.getVariableLocal(variableName, true);
  } else {
    value = execution.getVariable(variableName, true);
  }

  return value;
}
 
Example 2
Source File: DefaultContextAssociationManager.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void setVariable(String variableName, Object value) {
  ExecutionEntity execution = getExecutionFromContext();
  if(execution != null) {
    execution.setVariable(variableName, value);
    execution.getVariable(variableName);
  } else {
    getScopedAssociation().setVariable(variableName, value);
  }
}
 
Example 3
Source File: FormPropertyHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public FormProperty createFormProperty(ExecutionEntity execution) {
  FormPropertyImpl formProperty = new FormPropertyImpl(this);
  Object modelValue = null;

  if (execution!=null) {
    if (variableName != null || variableExpression == null) {
      final String varName = variableName != null ? variableName : id;
      if (execution.hasVariable(varName)) {
        modelValue = execution.getVariable(varName);
      } else if (defaultExpression != null) {
        modelValue = defaultExpression.getValue(execution);
      }
    } else {
      modelValue = variableExpression.getValue(execution);
    }
  } else {
    // Execution is null, the form-property is used in a start-form. Default value
    // should be available (ACT-1028) even though no execution is available.
    if (defaultExpression != null) {
      modelValue = defaultExpression.getValue(StartProcessVariableScope.getSharedInstance());
    }
  }

  if (modelValue instanceof String) {
    formProperty.setValue((String) modelValue);
  } else if (type != null) {
    String formValue = type.convertModelValueToFormValue(modelValue);
    formProperty.setValue(formValue);
  } else if (modelValue != null) {
    formProperty.setValue(modelValue.toString());
  }

  return formProperty;
}
 
Example 4
Source File: ProcessScope.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public java.lang.Object get(java.lang.Object o) {

	Assert.isInstanceOf(String.class, o, "the 'key' must be a String");

	String varName = (String) o;

	ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance();
	ExecutionEntity executionEntity = (ExecutionEntity) processInstance;
	if (executionEntity.getVariableNames().contains(varName)) {
		return executionEntity.getVariable(varName);
	}
	throw new RuntimeException("no processVariable by the name of '" + varName + "' is available!");
}