View Javadoc
1   package org.andromda.metafacades.uml14;
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.DependencyFacade;
10  import org.andromda.metafacades.uml.FilteredCollection;
11  import org.andromda.metafacades.uml.FrontEndAction;
12  import org.andromda.metafacades.uml.FrontEndActivityGraph;
13  import org.andromda.metafacades.uml.FrontEndControllerOperation;
14  import org.andromda.metafacades.uml.OperationFacade;
15  import org.andromda.metafacades.uml.Service;
16  import org.andromda.metafacades.uml.StateMachineFacade;
17  import org.andromda.metafacades.uml.UMLProfile;
18  import org.andromda.metafacades.uml.UseCaseFacade;
19  
20  /**
21   * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndController.
22   *
23   * @see org.andromda.metafacades.uml.FrontEndController
24   * @author Bob Fields
25   */
26  public class FrontEndControllerLogicImpl
27      extends FrontEndControllerLogic
28  {
29      private static final long serialVersionUID = 8320339804450106876L;
30  
31      /**
32       * @param metaObject
33       * @param context
34       */
35      public FrontEndControllerLogicImpl(
36          Object metaObject,
37          String context)
38      {
39          super(metaObject, context);
40      }
41  
42      /**
43       * @see org.andromda.metafacades.uml.FrontEndController#getServiceReferences()
44       */
45      @Override
46      protected List<DependencyFacade> handleGetServiceReferences()
47      {
48          return new FilteredCollection(this.getSourceDependencies())
49              {
50              private static final long serialVersionUID = 2214453181869436835L;
51  
52              public boolean evaluate(Object object)
53                  {
54                      return ((DependencyFacade)object).getTargetElement() instanceof Service;
55                  }
56              };
57      }
58  
59      /**
60       * @see org.andromda.metafacades.uml.FrontEndController#getUseCase()
61       */
62      @Override
63      protected UseCaseFacade handleGetUseCase()
64      {
65          UseCaseFacade useCase = null;
66          final StateMachineFacade graphContext = this.getStateMachineContext();
67          if (graphContext instanceof FrontEndActivityGraph)
68          {
69              useCase = ((ActivityGraphFacade)graphContext).getUseCase();
70          }
71          else
72          {
73              final Object useCaseTaggedValue = findTaggedValue(
74                      UMLProfile.TAGGEDVALUE_PRESENTATION_CONTROLLER_USECASE);
75              if (useCaseTaggedValue != null)
76              {
77                  final String tag = useCaseTaggedValue.toString();
78  
79                  // - return the first use-case with this name
80                  useCase = this.getModel().findUseCaseWithNameAndStereotype(
81                          tag, UMLProfile.STEREOTYPE_FRONT_END_USECASE);
82              }
83          }
84          return useCase;
85      }
86  
87      /**
88       * @see org.andromda.metafacades.uml.FrontEndController#getDeferringActions()
89       */
90      @Override
91      protected List<FrontEndAction> handleGetDeferringActions()
92      {
93          final Collection<FrontEndAction> deferringActions = new LinkedHashSet<FrontEndAction>();
94  
95          final Collection<OperationFacade> operations = getOperations();
96          for (final Iterator<OperationFacade> operationIterator = operations.iterator(); operationIterator.hasNext();)
97          {
98              final FrontEndControllerOperation operation = (FrontEndControllerOperation)operationIterator.next();
99              deferringActions.addAll(operation.getDeferringActions());
100         }
101         return new ArrayList<FrontEndAction>(deferringActions);
102     }
103 }