All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.camunda.bpm.engine.impl.cmd.RemoveExecutionVariablesCmd Maven / Gradle / Ivy

There is a newer version: 7.23.0-alpha2
Show newest version
package org.camunda.bpm.engine.impl.cmd;

import java.io.Serializable;
import java.util.Collection;

import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.impl.interceptor.Command;
import org.camunda.bpm.engine.impl.interceptor.CommandContext;
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity;

/**
 * @author roman.smirnov
 * @author Joram Barrez
 */
public class RemoveExecutionVariablesCmd implements Command, Serializable {

  private static final long serialVersionUID = 1L;

  private String executionId;
  private Collection variableNames;
  private boolean isLocal;
  
  public RemoveExecutionVariablesCmd(String executionId, Collection variableNames, boolean isLocal) {
    this.executionId = executionId;
    this.variableNames = variableNames;
    this.isLocal = isLocal;
  }
  
  @Override
  public Void execute(CommandContext commandContext) {
    if (executionId == null) {
      throw new ProcessEngineException("executionId is null");
    }
    
    ExecutionEntity execution = commandContext
            .getExecutionManager()
            .findExecutionById(executionId);
          
    if (execution==null) {
      throw new ProcessEngineException("execution "+executionId+" doesn't exist");
    }
    
    if (isLocal) {
      execution.removeVariablesLocal(variableNames);
    } else {
      execution.removeVariables(variableNames);
    }
    
    return null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy