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.Destination;
12  import org.andromda.metafacades.uml.Role;
13  import org.andromda.metafacades.uml.Service;
14  import org.andromda.metafacades.uml.ServiceOperation;
15  import org.apache.log4j.Logger;
16  import org.omg.uml.foundation.core.Operation;
17  
18  /**
19   * Reprsents an operation of a service.
20   * MetafacadeLogic for ServiceOperation
21   *
22   * @see ServiceOperation
23   */
24  public abstract class ServiceOperationLogic
25      extends OperationFacadeLogicImpl
26      implements ServiceOperation
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 ServiceOperationLogic(Object metaObjectIn, String context)
39      {
40          super((Operation)metaObjectIn, getContext(context));
41          this.metaObject = metaObjectIn;
42      }
43  
44      /**
45       * The logger instance.
46       */
47      private static final Logger logger = Logger.getLogger(ServiceOperationLogic.class);
48  
49      /**
50       * Gets the context for this metafacade logic instance.
51       * @param context String. Set to ServiceOperation 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.ServiceOperation";
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 ServiceOperation
79       */
80      public boolean isServiceOperationMetaType()
81      {
82          return true;
83      }
84  
85      // --------------- attributes ---------------------
86  
87     /**
88      * @see ServiceOperation#isIncomingMessageOperation()
89      * @return boolean
90      */
91      protected abstract boolean handleIsIncomingMessageOperation();
92  
93      private boolean __incomingMessageOperation1a;
94      private boolean __incomingMessageOperation1aSet = false;
95  
96      /**
97       * Whether or not this operation represents an "incoming" message operation (i.e. it receives
98       * messages from Queues or Topics).
99       * @return (boolean)handleIsIncomingMessageOperation()
100      */
101     public final boolean isIncomingMessageOperation()
102     {
103         boolean incomingMessageOperation1a = this.__incomingMessageOperation1a;
104         if (!this.__incomingMessageOperation1aSet)
105         {
106             // incomingMessageOperation has no pre constraints
107             incomingMessageOperation1a = handleIsIncomingMessageOperation();
108             // incomingMessageOperation has no post constraints
109             this.__incomingMessageOperation1a = incomingMessageOperation1a;
110             if (isMetafacadePropertyCachingEnabled())
111             {
112                 this.__incomingMessageOperation1aSet = true;
113             }
114         }
115         return incomingMessageOperation1a;
116     }
117 
118    /**
119     * @see ServiceOperation#isOutgoingMessageOperation()
120     * @return boolean
121     */
122     protected abstract boolean handleIsOutgoingMessageOperation();
123 
124     private boolean __outgoingMessageOperation2a;
125     private boolean __outgoingMessageOperation2aSet = false;
126 
127     /**
128      * Whether or not this service operation represents an "outgoing" messaging operation (i.e. it
129      * sends messages to Queues or Topics).
130      * @return (boolean)handleIsOutgoingMessageOperation()
131      */
132     public final boolean isOutgoingMessageOperation()
133     {
134         boolean outgoingMessageOperation2a = this.__outgoingMessageOperation2a;
135         if (!this.__outgoingMessageOperation2aSet)
136         {
137             // outgoingMessageOperation has no pre constraints
138             outgoingMessageOperation2a = handleIsOutgoingMessageOperation();
139             // outgoingMessageOperation has no post constraints
140             this.__outgoingMessageOperation2a = outgoingMessageOperation2a;
141             if (isMetafacadePropertyCachingEnabled())
142             {
143                 this.__outgoingMessageOperation2aSet = true;
144             }
145         }
146         return outgoingMessageOperation2a;
147     }
148 
149    /**
150     * @see ServiceOperation#isMessageOperation()
151     * @return boolean
152     */
153     protected abstract boolean handleIsMessageOperation();
154 
155     private boolean __messageOperation3a;
156     private boolean __messageOperation3aSet = false;
157 
158     /**
159      * Whether or not this is operation accepts incoming or outgoing messages.
160      * @return (boolean)handleIsMessageOperation()
161      */
162     public final boolean isMessageOperation()
163     {
164         boolean messageOperation3a = this.__messageOperation3a;
165         if (!this.__messageOperation3aSet)
166         {
167             // messageOperation has no pre constraints
168             messageOperation3a = handleIsMessageOperation();
169             // messageOperation has no post constraints
170             this.__messageOperation3a = messageOperation3a;
171             if (isMetafacadePropertyCachingEnabled())
172             {
173                 this.__messageOperation3aSet = true;
174             }
175         }
176         return messageOperation3a;
177     }
178 
179     // ------------- associations ------------------
180 
181     /**
182      * Reprsents an operation of a service.
183      * @return (Collection<Role>)handleGetRoles()
184      */
185     public final Collection<Role> getRoles()
186     {
187         Collection<Role> getRoles1r = null;
188         // serviceOperation has no pre constraints
189         Collection result = handleGetRoles();
190         List shieldedResult = this.shieldedElements(result);
191         try
192         {
193             getRoles1r = (Collection<Role>)shieldedResult;
194         }
195         catch (ClassCastException ex)
196         {
197             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
198             ServiceOperationLogic.logger.warn("incorrect metafacade cast for ServiceOperationLogic.getRoles Collection<Role> " + result + ": " + shieldedResult);
199         }
200         // serviceOperation has no post constraints
201         return getRoles1r;
202     }
203 
204     /**
205      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
206      * @return  Collection
207      */
208     protected abstract Collection handleGetRoles();
209 
210     /**
211      * Reprsents an operation of a service.
212      * @return (Service)handleGetService()
213      */
214     public final Service getService()
215     {
216         Service getService2r = null;
217         // serviceOperation has no pre constraints
218         Object result = handleGetService();
219         MetafacadeBase shieldedResult = this.shieldedElement(result);
220         try
221         {
222             getService2r = (Service)shieldedResult;
223         }
224         catch (ClassCastException ex)
225         {
226             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
227             ServiceOperationLogic.logger.warn("incorrect metafacade cast for ServiceOperationLogic.getService Service " + result + ": " + shieldedResult);
228         }
229         // serviceOperation has no post constraints
230         return getService2r;
231     }
232 
233     /**
234      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
235      * @return Object
236      */
237     protected abstract Object handleGetService();
238 
239     /**
240      * Reprsents an operation of a service.
241      * @return (Destination)handleGetOutgoingDestination()
242      */
243     public final Destination getOutgoingDestination()
244     {
245         Destination getOutgoingDestination3r = null;
246         // serviceOperation has no pre constraints
247         Object result = handleGetOutgoingDestination();
248         MetafacadeBase shieldedResult = this.shieldedElement(result);
249         try
250         {
251             getOutgoingDestination3r = (Destination)shieldedResult;
252         }
253         catch (ClassCastException ex)
254         {
255             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
256             ServiceOperationLogic.logger.warn("incorrect metafacade cast for ServiceOperationLogic.getOutgoingDestination Destination " + result + ": " + shieldedResult);
257         }
258         // serviceOperation has no post constraints
259         return getOutgoingDestination3r;
260     }
261 
262     /**
263      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
264      * @return Object
265      */
266     protected abstract Object handleGetOutgoingDestination();
267 
268     /**
269      * Reprsents an operation of a service.
270      * @return (Destination)handleGetIncomingDestination()
271      */
272     public final Destination getIncomingDestination()
273     {
274         Destination getIncomingDestination4r = null;
275         // serviceOperation has no pre constraints
276         Object result = handleGetIncomingDestination();
277         MetafacadeBase shieldedResult = this.shieldedElement(result);
278         try
279         {
280             getIncomingDestination4r = (Destination)shieldedResult;
281         }
282         catch (ClassCastException ex)
283         {
284             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
285             ServiceOperationLogic.logger.warn("incorrect metafacade cast for ServiceOperationLogic.getIncomingDestination Destination " + result + ": " + shieldedResult);
286         }
287         // serviceOperation has no post constraints
288         return getIncomingDestination4r;
289     }
290 
291     /**
292      * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
293      * @return Object
294      */
295     protected abstract Object handleGetIncomingDestination();
296 
297     /**
298      * @param validationMessages Collection<ModelValidationMessage>
299      * @see OperationFacadeLogicImpl#validateInvariants(Collection validationMessages)
300      */
301     @Override
302     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
303     {
304         super.validateInvariants(validationMessages);
305     }
306 }