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.activitygraphs.ActionState;
6   import org.omg.uml.behavioralelements.commonbehavior.Action;
7   import org.omg.uml.behavioralelements.statemachines.Transition;
8   
9   /**
10   * MetafacadeLogic implementation.
11   *
12   * @see org.andromda.metafacades.uml.ActionFacade
13   * @author Bob Fields
14   */
15  public class ActionFacadeLogicImpl
16          extends ActionFacadeLogic
17  {
18      private static final long serialVersionUID = 161746442702442292L;
19  
20      /**
21       * @param metaObject
22       * @param context
23       */
24      public ActionFacadeLogicImpl(Action metaObject,
25                                   String context)
26      {
27          super(metaObject, context);
28      }
29  
30      /**
31       * @see org.andromda.metafacades.uml14.ActionFacadeLogic#handleGetTransition()
32       */
33      protected Transition handleGetTransition()
34      {
35          Transition effectTransition = null;
36  
37          final Collection allTransitions = UML14MetafacadeUtils.getModel().getStateMachines().getTransition().refAllOfType();
38          for (final Iterator iterator = allTransitions.iterator(); iterator.hasNext() && effectTransition == null;)
39          {
40              Transition transition = (Transition)iterator.next();
41              if (metaObject.equals(transition.getEffect()))
42              {
43                  effectTransition = transition;
44              }
45          }
46  
47          return effectTransition;
48      }
49  
50      /**
51       * @see org.andromda.metafacades.uml14.ActionFacadeLogic#handleGetActionState()
52       */
53      protected ActionState handleGetActionState()
54      {
55          ActionState entryState = null;
56  
57          final Collection allActionStates = UML14MetafacadeUtils.getModel().getActivityGraphs().getActionState().refAllOfType();
58          for (final Iterator iterator = allActionStates.iterator(); iterator.hasNext() && entryState == null;)
59          {
60              final ActionState actionState = (ActionState)iterator.next();
61              if (metaObject.equals(actionState.getEntry()))
62              {
63                  entryState = actionState;
64              }
65          }
66  
67          return entryState;
68      }
69  
70      /**
71       * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
72       */
73      public Object getValidationOwner()
74      {
75          Object validationOwner = getTransition();
76  
77          if (validationOwner == null)
78          {
79              validationOwner = getActionState();
80          }
81  
82          return validationOwner;
83      }
84  }