View Javadoc
1   package org.andromda.metafacades.emf.uml22;
2   
3   import java.util.ArrayList;
4   import java.util.Collection;
5   import java.util.LinkedHashSet;
6   import java.util.List;
7   import org.andromda.metafacades.uml.DependencyFacade;
8   import org.andromda.metafacades.uml.FilteredCollection;
9   import org.andromda.metafacades.uml.FrontEndAction;
10  import org.andromda.metafacades.uml.FrontEndControllerOperation;
11  import org.andromda.metafacades.uml.OperationFacade;
12  import org.andromda.metafacades.uml.Service;
13  import org.eclipse.uml2.uml.Classifier;
14  import org.eclipse.uml2.uml.Element;
15  import org.eclipse.uml2.uml.UseCase;
16  
17  /**
18   * MetafacadeLogic implementation for
19   * org.andromda.metafacades.uml.FrontEndController.
20   *
21   * @see org.andromda.metafacades.uml.FrontEndController
22   */
23  public class FrontEndControllerLogicImpl
24      extends FrontEndControllerLogic
25  {
26      private static final long serialVersionUID = -8765076432370916838L;
27  
28      /**
29       * The logger instance.
30      private static final Logger LOGGER = Logger.getLogger(FrontEndControllerLogicImpl.class);
31       */
32  
33      /**
34       * @param metaObject
35       * @param context
36       */
37      public FrontEndControllerLogicImpl(
38          final Object metaObject,
39          final String context)
40      {
41          super(metaObject, context);
42      }
43  
44      /**
45       * @see org.andromda.metafacades.uml.FrontEndController#getServiceReferences()
46       */
47      @Override
48      protected List<DependencyFacade> handleGetServiceReferences()
49      {
50          return new FilteredCollection(this.getSourceDependencies())
51          {
52              private static final long serialVersionUID = 34L;
53              @Override
54              public boolean evaluate(final Object object)
55              {
56                  return ((DependencyFacade)object).getTargetElement() instanceof Service;
57              }
58          };
59      }
60  
61      /**
62       * @see org.andromda.metafacades.uml.FrontEndController#getUseCase()
63       */
64      @Override
65      protected Element handleGetUseCase()
66      {
67          Element owner = (Classifier)this.metaObject;
68          while (!(owner == null || owner instanceof UseCase))
69          {
70              owner = owner.getOwner();
71          }
72          return owner;
73      }
74  
75      /**
76       * @see org.andromda.metafacades.uml.FrontEndController#getDeferringActions()
77       */
78      @Override
79      protected List<FrontEndAction> handleGetDeferringActions()
80      {
81          final Collection<FrontEndAction> deferringActions = new LinkedHashSet<FrontEndAction>();
82  
83          for (final OperationFacade operation : this.getOperations())
84          {
85              final FrontEndControllerOperation controllerOperation = (FrontEndControllerOperation)operation;
86              deferringActions.addAll(controllerOperation.getDeferringActions());
87          }
88          return new ArrayList<FrontEndAction>(deferringActions);
89      }
90  
91      // TODO: We may want to override getPackageName here, since in uml2
92      // statemachine and usecase are "packages".
93      // We may return the getUseCase package name
94      // For now, in ModelElement, we are handling this case.
95  }