Is it possible to pass all workflow variables to a called process in Activiti?

For a particular workflow, we have many variables from the parent that need to be passed to the called workflow. While they could be enumerated, would be very helpful to automatically pass all variables, without having to enumerate them in the "parent" workflow.

有帮助吗?

解决方案

Found a way to do this using an ExecutionListener attached to the Start event.

public class WorkflowVariableInjectorListener implements ExecutionListener {
  private static final long serialVersionUID = 1L;

  static Logger logger = Logger.getLogger(WorkflowVariableInjectorListener.class);

  @Override
  public void notify(DelegateExecution execution) throws Exception {
    logger.info("In notify");
    if (execution instanceof ExecutionEntity) {
      ExecutionEntity executionEntity = (ExecutionEntity) execution;
      ExecutionEntity parentEntity = executionEntity.getSuperExecution();
      if (parentEntity != null) {
        // Copy all the variables into me
        executionEntity.setVariables(parentEntity.getVariables());
      }
    }
  }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top