cancel
Showing results for 
Search instead for 
Did you mean: 

How to find next UserTask across two sub-processes

xuemzhan
Champ in-the-making
Champ in-the-making
Hi Export(s),

I built a process with two sub-processes A and B. There is a ErrorEndEvent EE1 in A, and with a ErrorBoundaryEvent EB1 in pairs. The EB1 connect to sub-process B. I want to find the first UesrTask in B with path EE1 -> EB1 -> Sub-process B -> (UserTasks).

But the path is end with EE1, and no way is found to connect EB1. I don't know how to use error event signal to find EB1 through EE1's errorCode. And also have no idea to find the next UserTask across sub-processes A and B.

I build a method as follow:

public void iteratorNextNodes(Process process, FlowNode sourceFlowElement, Map<String, FlowNode> nodeMap) throws Exception {
       List<SequenceFlow> list = sourceFlowElement.getOutgogingFlows();
       for (SequenceFlow sf : list) {
             sourceFlowElement = (FlowNode) process.getFlowElementRecursive(sf.getTargetRef());
             if (sourceFlowElement instanceof UserTask) {
                   nodeMap.put(sourceFlowElement.getId(), sourceFlowElement);
                   continue;
             } else {
                   iteratorNextNodes(process, sourceFlowElement, nodeMap);
             }
       }
       if (sourceElement instanceof UserTask) {
             nodeMap.put(sourceFlowElement.getId(), sourceFlowElement);
             return;
        }
}
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
The error end event and the error boundary event should reference the same error (defined on the root level) OR both use the same errorCode.

xuemzhan
Champ in-the-making
Champ in-the-making
Many thanks for your help. I have got the "errorCode" value in EE1 in sub-process A. I traversed all activities in ROOT level trying to get BE1(ErrorBoudanryEvent) activityImpl with the same "errorCode". But I failed on it. I could get all ErrorBoundaryEvent activities through "type" property. But I couldn't make a decision which one is BE1. There is no property called "errorCode" in activityImpl. Or no ErrorBoundaryEventActivityBehavior like ErrorEndEventBehavior having getErrorCode method. I only got BoundaryEventActivityBehavior via activityImpl.getActivityBehavior() method, but there is no property or method for me to subscribe "errorCode". Seem there is no extend class inherited from BoundaryEventActivityBehavior to handle ErrorBoundaryEvent.

iam
Champ in-the-making
Champ in-the-making
You can find error definitions in activity properties:
[java]
    ActivityImpl subprocessA = processDefinition.findActivity("subprocessA");
   
    List<ErrorEventDefinition> errorEventDefinitions = (List<ErrorEventDefinition>) subprocessA.getProperty("errorEventDefinitions");
    ErrorEventDefinition firstErrorEventDefinition = errorEventDefinitions.get(0);

    String errorCode = firstErrorEventDefinition.getErrorCode();
[/java]

xuemzhan
Champ in-the-making
Champ in-the-making
It works, thank you very much.