How to get the sequence flow info of between two activity from BpmnInstance?

I am developing go back function.

For done this function I need to do three step

  1. get the squance flow id of before a specifed user task .
  2. Use that squance flow id start an activity instance.
  3. cancel the old user task activity instance

But in the first step i am facing some promble .
I am in the need of someone help me figure out how to get the sequence flow id

Thanks you all.
By the way my english is terrible forgive me please.

Maybe it is will be more clearly if change the question to “how to get the sequence flow between two activity ?”.

I finded the solution by myself.
Here is the code.

String givenActivityId = "activityId";
        BpmnModelInstance instance = repositoryService.getBpmnModelInstance("definitionId");
        Collection<SequenceFlow> sequenceFlows = instance.getModelElementsByType(SequenceFlow.class);
        for (SequenceFlow flow : sequenceFlows) {
            if (flow.getTarget().getId().equals(givenActivityId)) {
                LOG.info("Founded the sequenceFlow.");
                return flow;
            }
        }
        
        LOG.error("No such sequenceFlow");
1 Like