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

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#getVariablesLocal() . 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: GetExecutionVariablesCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Map<String, Object> execute(CommandContext commandContext) {

    // Verify existance of execution
    if (executionId == null) {
      throw new ActivitiIllegalArgumentException("executionId is null");
    }

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

    if (execution == null) {
      throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
    }
    
    if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) {
      Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
      return activiti5CompatibilityHandler.getExecutionVariables(executionId, variableNames, isLocal);
    }

    if (variableNames == null || variableNames.isEmpty()) {

      // Fetch all

      if (isLocal) {
        return execution.getVariablesLocal();
      } else {
        return execution.getVariables();
      }

    } else {

      // Fetch specific collection of variables
      if (isLocal) {
        return execution.getVariablesLocal(variableNames, false);
      } else {
        return execution.getVariables(variableNames, false);
      }

    }

  }
 
Example 2
Source File: GetExecutionVariablesCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Object> execute(CommandContext commandContext) {

    // Verify existence of execution
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("executionId is null");
    }

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

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

    if (variableNames == null || variableNames.isEmpty()) {

        // Fetch all

        if (isLocal) {
            return execution.getVariablesLocal();
        } else {
            return execution.getVariables();
        }

    } else {

        // Fetch specific collection of variables
        if (isLocal) {
            return execution.getVariablesLocal(variableNames, false);
        } else {
            return execution.getVariables(variableNames, false);
        }

    }

}
 
Example 3
Source File: ScopeUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * creates an event scope for the given execution:
 * 
 * create a new event scope execution under the parent of the given execution and move all event subscriptions to that execution.
 * 
 * this allows us to "remember" the event subscriptions after finishing a scope
 */
public static void createEventScopeExecution(ExecutionEntity execution) {

    ExecutionEntity eventScope = ScopeUtil.findScopeExecutionForScope(execution, execution.getActivity().getParent());

    List<CompensateEventSubscriptionEntity> eventSubscriptions = execution.getCompensateEventSubscriptions();

    if (!eventSubscriptions.isEmpty()) {

        ExecutionEntity eventScopeExecution = eventScope.createExecution();
        eventScopeExecution.setActive(false);
        eventScopeExecution.setConcurrent(false);
        eventScopeExecution.setEventScope(true);
        eventScopeExecution.setActivity(execution.getActivity());

        execution.setConcurrent(false);

        // copy local variables to eventScopeExecution by value. This way,
        // the eventScopeExecution references a 'snapshot' of the local variables
        Map<String, Object> variables = execution.getVariablesLocal();
        for (Entry<String, Object> variable : variables.entrySet()) {
            eventScopeExecution.setVariableLocal(variable.getKey(), variable.getValue());
        }

        // set event subscriptions to the event scope execution:
        for (CompensateEventSubscriptionEntity eventSubscriptionEntity : eventSubscriptions) {
            eventSubscriptionEntity = eventSubscriptionEntity.moveUnder(eventScopeExecution);
        }

        CompensateEventSubscriptionEntity eventSubscription = CompensateEventSubscriptionEntity.createAndInsert(eventScope);
        eventSubscription.setActivity(execution.getActivity());
        eventSubscription.setConfiguration(eventScopeExecution.getId());

    }
}