private void reconnectFlows ( ) { // create the reverse id map: for ( Entry < Object , List < String > > entry : _outgoingFlows . entrySet ( ) ) { for ( String flowId : entry . getValue ( ) ) { if ( entry . getKey ( ) instanceof SequenceFlow ) { // if it is a sequence flow, we can tell its targets if ( _idMap . get ( flowId ) instanceof FlowNode ) { ( ( SequenceFlow ) entry . getKey ( ) ) . setTargetRef ( ( FlowNode ) _idMap . get ( flowId ) ) ; } if ( _idMap . get ( flowId ) instanceof Association ) { ( ( Association ) _idMap . get ( flowId ) ) . setTargetRef ( ( SequenceFlow ) entry . getKey ( ) ) ; } } else if ( entry . getKey ( ) instanceof Association ) { ( ( Association ) entry . getKey ( ) ) . setTargetRef ( ( BaseElement ) _idMap . get ( flowId ) ) ; } else { // if it is a node, we can map it to its outgoing sequence flows if ( _idMap . get ( flowId ) instanceof SequenceFlow ) { ( ( FlowNode ) entry . getKey ( ) ) . getOutgoing ( ) . add ( ( SequenceFlow ) _idMap . get ( flowId ) ) ; } else if ( _idMap . get ( flowId ) instanceof Association ) { ( ( Association ) _idMap . get ( flowId ) ) . setSourceRef ( ( BaseElement ) entry . getKey ( ) ) ; } } } } }
Reconnect the sequence flows and the flow nodes . Done after the initial pass so that we have all the target information .