View Javadoc
1   package org.andromda.metafacades.emf.uml22;
2   
3   import java.util.ArrayList;
4   import java.util.Collection;
5   import java.util.Iterator;
6   import java.util.LinkedHashSet;
7   import java.util.List;
8   import org.andromda.metafacades.uml.ActivityGraphFacade;
9   import org.andromda.metafacades.uml.FrontEndAction;
10  import org.andromda.metafacades.uml.FrontEndActivityGraph;
11  import org.andromda.metafacades.uml.FrontEndForward;
12  import org.andromda.metafacades.uml.FrontEndUseCase;
13  import org.andromda.metafacades.uml.StateMachineFacade;
14  import org.andromda.metafacades.uml.TransitionFacade;
15  import org.andromda.metafacades.uml.UseCaseFacade;
16  
17  /**
18   * MetafacadeLogic implementation for
19   * org.andromda.metafacades.uml.FrontEndPseudostate.
20   *
21   * @see org.andromda.metafacades.uml.FrontEndPseudostate
22   */
23  public class FrontEndPseudostateLogicImpl
24      extends FrontEndPseudostateLogic
25  {
26      private static final long serialVersionUID = -4265098437803642987L;
27  
28      /**
29       * @param metaObject
30       * @param context
31       */
32      public FrontEndPseudostateLogicImpl(
33          final Object metaObject,
34          final String context)
35      {
36          super(metaObject, context);
37      }
38  
39      /**
40       * @see org.andromda.metafacades.uml.FrontEndPseudostate#isContainedInFrontEndUseCase()
41       */
42      @Override
43      protected boolean handleIsContainedInFrontEndUseCase()
44      {
45          return this.getStateMachine() instanceof FrontEndActivityGraph;
46      }
47  
48      /**
49       * @see org.andromda.metafacades.uml.FrontEndPseudostate#getContainerActions()
50       */
51      @Override
52      protected List<FrontEndAction> handleGetContainerActions()
53      {
54          final Collection<FrontEndAction> actionSet = new LinkedHashSet<FrontEndAction>();
55          final StateMachineFacade graphContext = this.getStateMachine();
56  
57          if (graphContext instanceof ActivityGraphFacade)
58          {
59              final UseCaseFacade useCase = ((ActivityGraphFacade)graphContext).getUseCase();
60  
61              if (useCase instanceof FrontEndUseCase)
62              {
63                  for (final Iterator<FrontEndAction> actionIterator = ((FrontEndUseCase)useCase).getActions().iterator();
64                      actionIterator.hasNext();)
65                  {
66                      final FrontEndAction action = actionIterator.next();
67                      final List<FrontEndForward> transitions = action.getTransitions();
68                      for (final Iterator<FrontEndForward> transitionIterator = transitions.iterator(); transitionIterator.hasNext();)
69                      {
70                          final TransitionFacade transition = (TransitionFacade)transitionIterator.next();
71                          if (this.equals(transition.getTarget()))
72                          {
73                              actionSet.add(action);
74                          }
75                      }
76                  }
77              }
78          }
79          return new ArrayList<FrontEndAction>(actionSet);
80      }
81  }