View Javadoc
1   package org.andromda.metafacades.emf.uml22;
2   
3   import java.util.ArrayList;
4   import java.util.Collection;
5   import java.util.List;
6   import org.andromda.metafacades.uml.OperationFacade;
7   import org.eclipse.uml2.uml.Activity;
8   import org.eclipse.uml2.uml.ActivityNode;
9   import org.eclipse.uml2.uml.CallOperationAction;
10  import org.eclipse.uml2.uml.Operation;
11  
12  /**
13   * MetafacadeLogic implementation for
14   * org.andromda.metafacades.uml.CallEventFacade. UML1.4 Event is mapped to UML2
15   * Activity (because UML2 Event doesn't contain parameters)
16   *
17   * @see org.andromda.metafacades.uml.CallEventFacade
18   */
19  public class CallEventFacadeLogicImpl extends CallEventFacadeLogic
20  {
21      private static final long serialVersionUID = 7223650138117667366L;
22  
23      /**
24       * @param metaObject
25       * @param context
26       */
27      public CallEventFacadeLogicImpl(final Activity metaObject,
28              final String context)
29      {
30          super(metaObject, context);
31      }
32  
33      /**
34       * @see org.andromda.metafacades.uml.CallEventFacade#getOperation()
35       */
36      @Override
37      protected OperationFacade handleGetOperation()
38      {
39          final Collection<OperationFacade> operations = this.getOperations();
40          return operations.isEmpty() ? null : operations.iterator().next();
41      }
42  
43      /**
44       * @see org.andromda.metafacades.uml.CallEventFacade#getOperations()
45       */
46      @Override
47      public List<Operation> handleGetOperations()
48      {
49          // We get every operation from each CallOperationAction instance.
50          final List<Operation> operations = new ArrayList<Operation>();
51          Collection<ActivityNode> nodes = this.metaObject.getNodes();
52          // UML2 v3: What previously was in getNodes is now in getOwnedNodes, while getNodes returns null
53          // This causes JSF cartridge to fail unless getOwnedNodes exists in UML2 metamodel.
54          // Activity Node operation parameters will have the incorrect owner type.
55          if (nodes==null || nodes.isEmpty())
56          {
57              nodes = this.metaObject.getOwnedNodes();
58          }
59          for (final ActivityNode nextNode : nodes)
60          {
61              if (nextNode instanceof CallOperationAction)
62              {
63                  final Operation operation = ((CallOperationAction) nextNode).getOperation();
64                  if (operation != null)
65                  {
66                      operations.add(operation);
67                  }
68              }
69          }
70          return operations;
71      }
72  
73  }