View Javadoc
1   package org.andromda.metafacades.emf.uml22;
2   
3   import java.util.Collection;
4   import org.andromda.metafacades.uml.StateFacade;
5   import org.eclipse.uml2.uml.Element;
6   import org.eclipse.uml2.uml.Region;
7   import org.eclipse.uml2.uml.StateMachine;
8   import org.eclipse.uml2.uml.UseCase;
9   
10  /**
11   * MetafacadeLogic implementation for
12   * org.andromda.metafacades.uml.ActivityGraphFacade. It seem strange that
13   * ActivityGraph are mapped with StateMachine. UML 1.4's ActivityGraph are an
14   * extension of State Machine, whereas UML2's Activity is like petri-nets. This
15   * explain this choice.
16   *
17   * @see org.andromda.metafacades.uml.ActivityGraphFacade
18   */
19  public class ActivityGraphFacadeLogicImpl
20      extends ActivityGraphFacadeLogic
21  {
22      private static final long serialVersionUID = 34L;
23      /**
24       * @param metaObject
25       * @param context
26       */
27      public ActivityGraphFacadeLogicImpl(
28          final StateMachine metaObject,
29          final String context)
30      {
31          super(metaObject, context);
32      }
33  
34      /**
35       * @see org.andromda.metafacades.uml.ActivityGraphFacade#getActionStates()
36       */
37      @Override
38      protected Collection<StateFacade> handleGetActionStates()
39      {
40          // There is no action states within uml2's state machine.
41          // But "simple" states will do the jobs.
42          return this.getStates();
43      }
44  
45      /**
46       * @see org.andromda.metafacades.uml.ActivityGraphFacade#getObjectFlowStates()
47       */
48      @Override
49      protected Collection handleGetObjectFlowStates()
50      {
51          // TODO: add your implementation here!
52          return null;
53      }
54  
55      /**
56       * @see org.andromda.metafacades.uml.ActivityGraphFacade#getUseCase()
57       */
58      @Override
59      protected UseCase handleGetUseCase()
60      {
61          final Element owner = this.metaObject.getOwner();
62          if (owner instanceof UseCase)
63          {
64              return (UseCase)owner;
65          }
66  
67          return null;
68      }
69  
70      /**
71       * @see org.andromda.metafacades.uml.ActivityGraphFacade#getPartitions()
72       */
73      @Override
74      protected Collection<Region> handleGetPartitions()
75      {
76          // Since we mapped ActivityGraph to StateMachine, dividers are Regions,
77          // not Partitions
78          return this.metaObject.getRegions();
79      }
80  
81      /**
82       * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
83       */
84      @Override
85      public Object getValidationOwner()
86      {
87          Object validationOwner = getUseCase();
88  
89          if (validationOwner == null)
90          {
91              validationOwner = getStateMachineContext();
92          }
93          if (validationOwner == null)
94          {
95              validationOwner = getPackage();
96          }
97  
98          return validationOwner;
99      }
100 }