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.ActivityGraph;
6   import org.omg.uml.behavioralelements.activitygraphs.Partition;
7   import org.omg.uml.behavioralelements.statemachines.CompositeState;
8   import org.omg.uml.behavioralelements.statemachines.StateMachine;
9   import org.omg.uml.behavioralelements.statemachines.StateVertex;
10  
11  /**
12   * MetafacadeLogic implementation.
13   *
14   * @see org.andromda.metafacades.uml.StateVertexFacade
15   * @author Bob Fields
16   */
17  public class StateVertexFacadeLogicImpl
18          extends StateVertexFacadeLogic
19  {
20      private static final long serialVersionUID = 34L;
21      /**
22       * @param metaObject
23       * @param context
24       */
25      public StateVertexFacadeLogicImpl(StateVertex metaObject,
26                                        String context)
27      {
28          super(metaObject, context);
29      }
30  
31      /**
32       * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetStateMachine()
33       */
34      protected StateMachine handleGetStateMachine()
35      {
36          // throws NullPointer if metaObject has no Container... Need to check for null on return.
37          if (metaObject.getContainer()==null)
38          {
39              return null;
40          }
41          return metaObject.getContainer().getStateMachine();
42      }
43  
44      /**
45       * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetContainer()
46       */
47      protected CompositeState handleGetContainer()
48      {
49          return metaObject.getContainer();
50      }
51  
52      /**
53       * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetIncomings()
54       */
55      protected Collection handleGetIncomings()
56      {
57          return metaObject.getIncoming();
58      }
59  
60      /**
61       * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetOutgoings()
62       */
63      protected Collection handleGetOutgoings()
64      {
65          return metaObject.getOutgoing();
66      }
67  
68      /**
69       * @return getStateMachine
70       */
71      public Object handleGetValidationOwner()
72      {
73          return getStateMachine();
74      }
75  
76      /**
77       * @see org.andromda.metafacades.uml14.StateVertexFacadeLogic#handleGetPartition()
78       */
79      protected Partition handleGetPartition()
80      {
81          Partition thePartition = null;
82  
83          final StateMachine stateMachine = metaObject.getContainer().getStateMachine();
84          if (stateMachine instanceof ActivityGraph)
85          {
86              final ActivityGraph activityGraph = (ActivityGraph)stateMachine;
87              final Collection<Partition> partitions = activityGraph.getPartition();
88              for (final Iterator<Partition> partitionIterator = partitions.iterator(); partitionIterator.hasNext() && thePartition == null;)
89              {
90                  final Partition partition = partitionIterator.next();
91                  if (partition.getContents().contains(metaObject))
92                  {
93                      thePartition = partition;
94                  }
95              }
96          }
97  
98          return thePartition;
99      }
100 }