View Javadoc
1   package org.andromda.metafacades.uml14;
2   
3   import java.util.Collection;
4   import java.util.Iterator;
5   import org.omg.uml.behavioralelements.statemachines.State;
6   import org.omg.uml.behavioralelements.statemachines.Transition;
7   import org.omg.uml.behavioralelements.statemachines.Event;
8   
9   /**
10   * MetafacadeLogic implementation.
11   *
12   * @see org.andromda.metafacades.uml.EventFacade
13   * @author Bob Fields
14   */
15  public class EventFacadeLogicImpl
16      extends EventFacadeLogic
17  {
18      private static final long serialVersionUID = -6251731927740002930L;
19  
20      /**
21       * @param metaObject
22       * @param context
23       */
24      public EventFacadeLogicImpl(
25          Event metaObject,
26          String context)
27      {
28          super(metaObject, context);
29      }
30  
31      /**
32       * @see org.andromda.metafacades.uml.EventFacade#getParameters()
33       */
34      @Override
35      protected Collection handleGetParameters()
36      {
37          return metaObject.getParameter();
38      }
39  
40      /**
41       * @see org.andromda.metafacades.uml.EventFacade#getTransition()
42       */
43      @Override
44      protected Transition handleGetTransition()
45      {
46          Transition eventTransition = null;
47  
48          final Collection<Transition> allTransitions =
49              UML14MetafacadeUtils.getModel().getStateMachines().getTransition().refAllOfType();
50          for (final Iterator<Transition> iterator = allTransitions.iterator(); iterator.hasNext() && eventTransition == null;)
51          {
52              final Transition transition = iterator.next();
53              if (metaObject.equals(transition.getTrigger()))
54              {
55                  eventTransition = transition;
56              }
57          }
58  
59          return eventTransition;
60      }
61  
62      /**
63       * @see org.andromda.metafacades.uml.EventFacade#getState()
64       */
65      @Override
66      protected State handleGetState()
67      {
68          State eventState = null;
69  
70          final Collection<State> allStates = UML14MetafacadeUtils.getModel().getStateMachines().getState().refAllOfType();
71          for (final Iterator<State> stateIterator = allStates.iterator(); stateIterator.hasNext() && eventState == null;)
72          {
73              final State state = stateIterator.next();
74              if (state.getDeferrableEvent().contains(metaObject))
75              {
76                  eventState = state;
77              }
78          }
79  
80          return eventState;
81      }
82  
83      /**
84       * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
85       */
86      public Object getValidationOwner()
87      {
88          Object validationOwner = this.getTransition();
89          if (validationOwner == null)
90          {
91              validationOwner = this.getState();
92          }
93          return validationOwner;
94      }
95  }