Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#hasVariable()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#hasVariable() . 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: HasExecutionVariableCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public Boolean execute(CommandContext commandContext) {
  if (executionId == null) {
    throw new ActivitiIllegalArgumentException("executionId is null");
  }
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }

  ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(executionId);

  if (execution == null) {
    throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
  }

  boolean hasVariable = false;

  if (isLocal) {
    hasVariable = execution.hasVariableLocal(variableName);
  } else {
    hasVariable = execution.hasVariable(variableName);
  }

  return hasVariable;
}
 
Example 2
Source File: FormPropertyHandler.java    From activiti6-boot2 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(NoExecutionVariableScope.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 3
Source File: FormPropertyHandler.java    From flowable-engine 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(NoExecutionVariableScope.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: HasExecutionVariableCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("executionId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }

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

    if (execution == null) {
        throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
    }

    boolean hasVariable = false;

    if (isLocal) {
        hasVariable = execution.hasVariableLocal(variableName);
    } else {
        hasVariable = execution.hasVariable(variableName);
    }

    return hasVariable;
}