cancel
Showing results for 
Search instead for 
Did you mean: 

how to get all possible flows from current activity?

tse
Champ in-the-making
Champ in-the-making
Hi,
Is it possible to retrieve all possible flows/transitions branching from active activity, for example: event gateway branches to 4 possible flows activated by intermediate signals -> how to determine programatically those 4 activities/signals
runtimeService.getActiveActivityIds(processId) returns only the Event Gateway acitvity
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
The getActiveActivityId() indeed only returns the active activities at that point in time. If you're using activiti 5.12, you can use the repository-service to get a model based on the process-defintion id:


/**
   * Returns the {@link BpmnModel} corresponding with the process definition with
   * the provided process definition id. The {@link BpmnModel} is a pojo versions
   * of the BPMN 2.0 xml and can be used to introspect the process definition
   * using regular Java.
   */
  BpmnModel getBpmnModel(String processDefinitionId);

You can run through this and find out what outgoing flows the gateway has and fine out what possible next activities are present. Prior to activiti 5.11, you can use the RepositoryService(impl):


public ReadOnlyProcessDefinition getDeployedProcessDefinition(String processDefinitionId) {
    return commandExecutor.execute(new GetDeploymentProcessDefinitionCmd(processDefinitionId));
  }

tse
Champ in-the-making
Champ in-the-making
Thanks for help, it works great.

Should anyone else need it, here is the code:

        rt = getProcessEngine().getRuntimeService();
        Execution parentExec = rt.createProcessInstanceQuery().variableValueEquals(variableName, variableValue).singleResult();
        RepositoryServiceImpl repoServiceImpl = (RepositoryServiceImpl) getProcessEngine().getRepositoryService();
       
        for (Execution e : rt.createExecutionQuery().processInstanceId(parentExec.getProcessInstanceId()).list()) {
            ExecutionEntity ee = (ExecutionEntity) e;
            ReadOnlyProcessDefinition processDef = repoServiceImpl.getDeployedProcessDefinition(ee.getProcessDefinitionId());
            PvmActivity activity = processDef.findActivity(ee.getActivityId());
            List<org.activiti.engine.impl.pvm.PvmTransition> transitions = activity.getOutgoingTransitions();
      }