View Javadoc
1   // license-header java merge-point
2   //
3   // Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
4   //
5   package org.andromda.metafacades.uml14;
6   
7   import java.util.Collection;
8   import java.util.List;
9   import org.andromda.core.metafacade.MetafacadeBase;
10  import org.andromda.core.metafacade.ModelValidationMessage;
11  import org.andromda.metafacades.uml.FrontEndAction;
12  import org.andromda.metafacades.uml.FrontEndControllerOperation;
13  import org.andromda.metafacades.uml.FrontEndEvent;
14  import org.apache.log4j.Logger;
15  import org.omg.uml.behavioralelements.statemachines.Event;
16  
17  /**
18   * A front-end event is represented by some kind of even on some kind of front-end (hyperlink,
19   * submit button, etc).
20   * MetafacadeLogic for FrontEndEvent
21   *
22   * @see FrontEndEvent
23   */
24  public abstract class FrontEndEventLogic
25      extends EventFacadeLogicImpl
26      implements FrontEndEvent
27  {
28      /**
29       * The underlying UML object
30       * @see Object
31       */
32      protected Object metaObject;
33  
34      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
35       * @param metaObjectIn
36       * @param context
37       */
38      protected FrontEndEventLogic(Object metaObjectIn, String context)
39      {
40          super((Event)metaObjectIn, getContext(context));
41          this.metaObject = metaObjectIn;
42      }
43  
44      /**
45       * The logger instance.
46       */
47      private static final Logger logger = Logger.getLogger(FrontEndEventLogic.class);
48  
49      /**
50       * Gets the context for this metafacade logic instance.
51       * @param context String. Set to FrontEndEvent if null
52       * @return context String
53       */
54      private static String getContext(String context)
55      {
56          if (context == null)
57          {
58              context = "org.andromda.metafacades.uml.FrontEndEvent";
59          }
60          return context;
61      }
62  
63      /** Reset context only for non-root metafacades
64       * @param context
65       */
66      @Override
67      public void resetMetafacadeContext(String context)
68      {
69          if (!this.contextRoot) // reset context only for non-root metafacades
70          {
71              context = getContext(context);  // to have same value as in original constructor call
72              setMetafacadeContext (context);
73          }
74      }
75  
76      /**
77       * @return boolean true always
78       * @see FrontEndEvent
79       */
80      public boolean isFrontEndEventMetaType()
81      {
82          return true;
83      }
84  
85      // --------------- attributes ---------------------
86  
87     /**
88      * @see FrontEndEvent#isContainedInFrontEndUseCase()
89      * @return boolean
90      */
91      protected abstract boolean handleIsContainedInFrontEndUseCase();
92  
93      private boolean __containedInFrontEndUseCase1a;
94      private boolean __containedInFrontEndUseCase1aSet = false;
95  
96      /**
97       * Indicates whether or not this front end event is contained within a FrontEndUseCase.
98       * @return (boolean)handleIsContainedInFrontEndUseCase()
99       */
100     public final boolean isContainedInFrontEndUseCase()
101     {
102         boolean containedInFrontEndUseCase1a = this.__containedInFrontEndUseCase1a;
103         if (!this.__containedInFrontEndUseCase1aSet)
104         {
105             // containedInFrontEndUseCase has no pre constraints
106             containedInFrontEndUseCase1a = handleIsContainedInFrontEndUseCase();
107             // containedInFrontEndUseCase has no post constraints
108             this.__containedInFrontEndUseCase1a = containedInFrontEndUseCase1a;
109             if (isMetafacadePropertyCachingEnabled())
110             {
111                 this.__containedInFrontEndUseCase1aSet = true;
112             }
113         }
114         return containedInFrontEndUseCase1a;
115     }
116 
117     // ------------- associations ------------------
118 
119     private FrontEndControllerOperation __getControllerCall1r;
120     private boolean __getControllerCall1rSet = false;
121 
122     /**
123      * A front-end event is represented by some kind of even on some kind of front-end (hyperlink,
124      * submit
125      * button, etc).
126      * @return (FrontEndControllerOperation)handleGetControllerCall()
127      */
128     public final FrontEndControllerOperation getControllerCall()
129     {
130         FrontEndControllerOperation getControllerCall1r = this.__getControllerCall1r;
131         if (!this.__getControllerCall1rSet)
132         {
133             // frontEndEvent has no pre constraints
134             Object result = handleGetControllerCall();
135             MetafacadeBase shieldedResult = this.shieldedElement(result);
136             try
137             {
138                 getControllerCall1r = (FrontEndControllerOperation)shieldedResult;
139             }
140             catch (ClassCastException ex)
141             {
142                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
143                 FrontEndEventLogic.logger.warn("incorrect metafacade cast for FrontEndEventLogic.getControllerCall FrontEndControllerOperation " + result + ": " + shieldedResult);
144             }
145             // frontEndEvent has no post constraints
146             this.__getControllerCall1r = getControllerCall1r;
147             if (isMetafacadePropertyCachingEnabled())
148             {
149                 this.__getControllerCall1rSet = true;
150             }
151         }
152         return getControllerCall1r;
153     }
154 
155     /**
156      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
157      * @return Object
158      */
159     protected abstract Object handleGetControllerCall();
160 
161     private FrontEndAction __getAction2r;
162     private boolean __getAction2rSet = false;
163 
164     /**
165      * A front-end event is represented by some kind of even on some kind of front-end (hyperlink,
166      * submit
167      * button, etc).
168      * @return (FrontEndAction)handleGetAction()
169      */
170     public final FrontEndAction getAction()
171     {
172         FrontEndAction getAction2r = this.__getAction2r;
173         if (!this.__getAction2rSet)
174         {
175             // frontEndEvent has no pre constraints
176             Object result = handleGetAction();
177             MetafacadeBase shieldedResult = this.shieldedElement(result);
178             try
179             {
180                 getAction2r = (FrontEndAction)shieldedResult;
181             }
182             catch (ClassCastException ex)
183             {
184                 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
185                 FrontEndEventLogic.logger.warn("incorrect metafacade cast for FrontEndEventLogic.getAction FrontEndAction " + result + ": " + shieldedResult);
186             }
187             // frontEndEvent has no post constraints
188             this.__getAction2r = getAction2r;
189             if (isMetafacadePropertyCachingEnabled())
190             {
191                 this.__getAction2rSet = true;
192             }
193         }
194         return getAction2r;
195     }
196 
197     /**
198      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
199      * @return Object
200      */
201     protected abstract Object handleGetAction();
202 
203     /**
204      * A front-end event is represented by some kind of even on some kind of front-end (hyperlink,
205      * submit
206      * button, etc).
207      * @return (List<FrontEndControllerOperation>)handleGetControllerCalls()
208      */
209     public final List<FrontEndControllerOperation> getControllerCalls()
210     {
211         List<FrontEndControllerOperation> getControllerCalls3r = null;
212         // frontEndEvent has no pre constraints
213         List result = handleGetControllerCalls();
214         List shieldedResult = this.shieldedElements(result);
215         try
216         {
217             getControllerCalls3r = (List<FrontEndControllerOperation>)shieldedResult;
218         }
219         catch (ClassCastException ex)
220         {
221             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
222             FrontEndEventLogic.logger.warn("incorrect metafacade cast for FrontEndEventLogic.getControllerCalls List<FrontEndControllerOperation> " + result + ": " + shieldedResult);
223         }
224         // frontEndEvent has no post constraints
225         return getControllerCalls3r;
226     }
227 
228     /**
229      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
230      * @return  List
231      */
232     protected abstract List handleGetControllerCalls();
233 
234     /**
235      * @param validationMessages Collection<ModelValidationMessage>
236      * @see EventFacadeLogicImpl#validateInvariants(Collection validationMessages)
237      */
238     @Override
239     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
240     {
241         super.validateInvariants(validationMessages);
242     }
243 }