public static void removeLegacyNonScopesFromMapping ( Map < ScopeImpl , PvmExecutionImpl > mapping ) { Map < PvmExecutionImpl , List < ScopeImpl > > scopesForExecutions = new HashMap < PvmExecutionImpl , List < ScopeImpl > > ( ) ; for ( Map . Entry < ScopeImpl , PvmExecutionImpl > mappingEntry : mapping . entrySet ( ) ) { List < ScopeImpl > scopesForExecution = scopesForExecutions . get ( mappingEntry . getValue ( ) ) ; if ( scopesForExecution == null ) { scopesForExecution = new ArrayList < ScopeImpl > ( ) ; scopesForExecutions . put ( mappingEntry . getValue ( ) , scopesForExecution ) ; } scopesForExecution . add ( mappingEntry . getKey ( ) ) ; } for ( Map . Entry < PvmExecutionImpl , List < ScopeImpl > > scopesForExecution : scopesForExecutions . entrySet ( ) ) { List < ScopeImpl > scopes = scopesForExecution . getValue ( ) ; if ( scopes . size ( ) > 1 ) { ScopeImpl topMostScope = getTopMostScope ( scopes ) ; for ( ScopeImpl scope : scopes ) { if ( scope != scope . getProcessDefinition ( ) && scope != topMostScope ) { mapping . remove ( scope ) ; } } } } }
Remove all entries for legacy non - scopes given that the assigned scope execution is also responsible for another scope