@ Override public void onInteractionEvent ( final InteractionEvent event ) { QName id = event . getId ( ) ; QName source = ( QName ) event . getSource ( ) ; final Set < Procedure > collection = procedures . get ( id ) ; Procedure execution = null ; if ( collection != null ) { for ( Procedure consumer : collection ) { // TODO: This isn't optimal (creation of new resource with every comparison) Resource < ResourceType > resource = new Resource < ResourceType > ( id , ResourceType . Interaction ) ; resource . setSource ( source ) ; boolean justified = consumer . getJustification ( ) == null || source . equals ( consumer . getJustification ( ) ) ; if ( consumer . doesConsume ( resource ) && justified ) { execution = consumer ; break ; } } } if ( null == execution ) { Window . alert ( "No procedure for " + event ) ; Log . warn ( "No procedure for " + event ) ; } else if ( execution . getPrecondition ( ) . isMet ( getStatementContext ( source ) ) ) // guarded { try { execution . getCommand ( ) . execute ( InteractionCoordinator . this . dialog , event . getPayload ( ) ) ; } catch ( Throwable e ) { Log . error ( "Failed to execute procedure " + execution , e ) ; } } }
Find the corresponding procedures and execute it .