1
2
3
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.FrontEndActionState;
13 import org.andromda.metafacades.uml.FrontEndExceptionHandler;
14 import org.andromda.metafacades.uml.FrontEndForward;
15 import org.andromda.metafacades.uml.OperationFacade;
16 import org.andromda.translation.ocl.validation.OCLCollections;
17 import org.andromda.translation.ocl.validation.OCLExpressions;
18 import org.andromda.translation.ocl.validation.OCLIntrospector;
19 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
20 import org.apache.log4j.Logger;
21 import org.omg.uml.behavioralelements.activitygraphs.ActionState;
22
23
24
25
26
27
28
29
30 public abstract class FrontEndActionStateLogic
31 extends ActionStateFacadeLogicImpl
32 implements FrontEndActionState
33 {
34
35
36
37
38 protected Object metaObject;
39
40
41
42
43
44 protected FrontEndActionStateLogic(Object metaObjectIn, String context)
45 {
46 super((ActionState)metaObjectIn, getContext(context));
47 this.metaObject = metaObjectIn;
48 }
49
50
51
52
53 private static final Logger logger = Logger.getLogger(FrontEndActionStateLogic.class);
54
55
56
57
58
59
60 private static String getContext(String context)
61 {
62 if (context == null)
63 {
64 context = "org.andromda.metafacades.uml.FrontEndActionState";
65 }
66 return context;
67 }
68
69
70
71
72 @Override
73 public void resetMetafacadeContext(String context)
74 {
75 if (!this.contextRoot)
76 {
77 context = getContext(context);
78 setMetafacadeContext (context);
79 }
80 }
81
82
83
84
85
86 public boolean isFrontEndActionStateMetaType()
87 {
88 return true;
89 }
90
91
92
93
94
95
96
97 protected abstract boolean handleIsServerSide();
98
99 private boolean __serverSide1a;
100 private boolean __serverSide1aSet = false;
101
102
103
104
105
106
107 public final boolean isServerSide()
108 {
109 boolean serverSide1a = this.__serverSide1a;
110 if (!this.__serverSide1aSet)
111 {
112
113 serverSide1a = handleIsServerSide();
114
115 this.__serverSide1a = serverSide1a;
116 if (isMetafacadePropertyCachingEnabled())
117 {
118 this.__serverSide1aSet = true;
119 }
120 }
121 return serverSide1a;
122 }
123
124
125
126
127
128 protected abstract boolean handleIsContainedInFrontEndUseCase();
129
130 private boolean __containedInFrontEndUseCase2a;
131 private boolean __containedInFrontEndUseCase2aSet = false;
132
133
134
135
136
137 public final boolean isContainedInFrontEndUseCase()
138 {
139 boolean containedInFrontEndUseCase2a = this.__containedInFrontEndUseCase2a;
140 if (!this.__containedInFrontEndUseCase2aSet)
141 {
142
143 containedInFrontEndUseCase2a = handleIsContainedInFrontEndUseCase();
144
145 this.__containedInFrontEndUseCase2a = containedInFrontEndUseCase2a;
146 if (isMetafacadePropertyCachingEnabled())
147 {
148 this.__containedInFrontEndUseCase2aSet = true;
149 }
150 }
151 return containedInFrontEndUseCase2a;
152 }
153
154
155
156
157
158 protected abstract String handleGetActionMethodName();
159
160 private String __actionMethodName3a;
161 private boolean __actionMethodName3aSet = false;
162
163
164
165
166
167 public final String getActionMethodName()
168 {
169 String actionMethodName3a = this.__actionMethodName3a;
170 if (!this.__actionMethodName3aSet)
171 {
172
173 actionMethodName3a = handleGetActionMethodName();
174
175 this.__actionMethodName3a = actionMethodName3a;
176 if (isMetafacadePropertyCachingEnabled())
177 {
178 this.__actionMethodName3aSet = true;
179 }
180 }
181 return actionMethodName3a;
182 }
183
184
185
186
187
188 protected abstract List<OperationFacade> handleGetServiceCalls();
189
190 private List<OperationFacade> __serviceCalls4a;
191 private boolean __serviceCalls4aSet = false;
192
193
194
195
196
197 public final List<OperationFacade> getServiceCalls()
198 {
199 List<OperationFacade> serviceCalls4a = this.__serviceCalls4a;
200 if (!this.__serviceCalls4aSet)
201 {
202
203 serviceCalls4a = handleGetServiceCalls();
204
205 this.__serviceCalls4a = serviceCalls4a;
206 if (isMetafacadePropertyCachingEnabled())
207 {
208 this.__serviceCalls4aSet = true;
209 }
210 }
211 return serviceCalls4a;
212 }
213
214
215
216 private List<FrontEndAction> __getContainerActions1r;
217 private boolean __getContainerActions1rSet = false;
218
219
220
221
222
223 public final List<FrontEndAction> getContainerActions()
224 {
225 List<FrontEndAction> getContainerActions1r = this.__getContainerActions1r;
226 if (!this.__getContainerActions1rSet)
227 {
228
229 List result = handleGetContainerActions();
230 List shieldedResult = this.shieldedElements(result);
231 try
232 {
233 getContainerActions1r = (List<FrontEndAction>)shieldedResult;
234 }
235 catch (ClassCastException ex)
236 {
237
238 FrontEndActionStateLogic.logger.warn("incorrect metafacade cast for FrontEndActionStateLogic.getContainerActions List<FrontEndAction> " + result + ": " + shieldedResult);
239 }
240
241 this.__getContainerActions1r = getContainerActions1r;
242 if (isMetafacadePropertyCachingEnabled())
243 {
244 this.__getContainerActions1rSet = true;
245 }
246 }
247 return getContainerActions1r;
248 }
249
250
251
252
253
254 protected abstract List handleGetContainerActions();
255
256 private List<OperationFacade> __getControllerCalls2r;
257 private boolean __getControllerCalls2rSet = false;
258
259
260
261
262
263
264
265 public final List<OperationFacade> getControllerCalls()
266 {
267 List<OperationFacade> getControllerCalls2r = this.__getControllerCalls2r;
268 if (!this.__getControllerCalls2rSet)
269 {
270
271 List result = handleGetControllerCalls();
272 List shieldedResult = this.shieldedElements(result);
273 try
274 {
275 getControllerCalls2r = (List<OperationFacade>)shieldedResult;
276 }
277 catch (ClassCastException ex)
278 {
279
280 FrontEndActionStateLogic.logger.warn("incorrect metafacade cast for FrontEndActionStateLogic.getControllerCalls List<OperationFacade> " + result + ": " + shieldedResult);
281 }
282
283 this.__getControllerCalls2r = getControllerCalls2r;
284 if (isMetafacadePropertyCachingEnabled())
285 {
286 this.__getControllerCalls2rSet = true;
287 }
288 }
289 return getControllerCalls2r;
290 }
291
292
293
294
295
296 protected abstract List handleGetControllerCalls();
297
298 private List<FrontEndExceptionHandler> __getExceptions3r;
299 private boolean __getExceptions3rSet = false;
300
301
302
303
304
305
306
307 public final List<FrontEndExceptionHandler> getExceptions()
308 {
309 List<FrontEndExceptionHandler> getExceptions3r = this.__getExceptions3r;
310 if (!this.__getExceptions3rSet)
311 {
312
313 List result = handleGetExceptions();
314 List shieldedResult = this.shieldedElements(result);
315 try
316 {
317 getExceptions3r = (List<FrontEndExceptionHandler>)shieldedResult;
318 }
319 catch (ClassCastException ex)
320 {
321
322 FrontEndActionStateLogic.logger.warn("incorrect metafacade cast for FrontEndActionStateLogic.getExceptions List<FrontEndExceptionHandler> " + result + ": " + shieldedResult);
323 }
324
325 this.__getExceptions3r = getExceptions3r;
326 if (isMetafacadePropertyCachingEnabled())
327 {
328 this.__getExceptions3rSet = true;
329 }
330 }
331 return getExceptions3r;
332 }
333
334
335
336
337
338 protected abstract List handleGetExceptions();
339
340 private FrontEndForward __getForward4r;
341 private boolean __getForward4rSet = false;
342
343
344
345
346
347
348
349 public final FrontEndForward getForward()
350 {
351 FrontEndForward getForward4r = this.__getForward4r;
352 if (!this.__getForward4rSet)
353 {
354
355 Object result = handleGetForward();
356 MetafacadeBase shieldedResult = this.shieldedElement(result);
357 try
358 {
359 getForward4r = (FrontEndForward)shieldedResult;
360 }
361 catch (ClassCastException ex)
362 {
363
364 FrontEndActionStateLogic.logger.warn("incorrect metafacade cast for FrontEndActionStateLogic.getForward FrontEndForward " + result + ": " + shieldedResult);
365 }
366
367 this.__getForward4r = getForward4r;
368 if (isMetafacadePropertyCachingEnabled())
369 {
370 this.__getForward4rSet = true;
371 }
372 }
373 return getForward4r;
374 }
375
376
377
378
379
380 protected abstract Object handleGetForward();
381
382
383
384
385
386
387
388
389
390
391
392 @Override
393 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
394 {
395 super.validateInvariants(validationMessages);
396 try
397 {
398 final Object contextElement = this.THIS();
399 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"name")));
400 if (!constraintValid)
401 {
402 validationMessages.add(
403 new ModelValidationMessage(
404 (MetafacadeBase)contextElement ,
405 "org::andromda::metafacades::uml::FrontEndActionState::each front-end action state must have a name",
406 "A \"front-end\" action state must have a non-empty name."));
407 }
408 }
409 catch (Throwable th)
410 {
411 Throwable cause = th.getCause();
412 int depth = 0;
413 while (cause != null && depth < 7)
414 {
415 th = cause;
416 depth++;
417 }
418 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndActionState::each front-end action state must have a name' ON "
419 + this.THIS().toString() + ": " + th.getMessage(), th);
420 }
421 try
422 {
423 final Object contextElement = this.THIS();
424 boolean constraintValid = OCLResultEnsurer.ensure((Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"serverSide"))).booleanValue()?(OCLExpressions.equal(OCLCollections.size(OCLIntrospector.invoke(contextElement,"exceptions"))+1,OCLCollections.size(OCLIntrospector.invoke(contextElement,"outgoings")))||OCLExpressions.equal(OCLCollections.size(OCLIntrospector.invoke(contextElement,"exceptions")),OCLCollections.size(OCLIntrospector.invoke(contextElement,"outgoings")))):true));
425 if (!constraintValid)
426 {
427 validationMessages.add(
428 new ModelValidationMessage(
429 (MetafacadeBase)contextElement ,
430 "org::andromda::metafacades::uml::FrontEndActionState::front-end action states can have at most one outgoing transition",
431 "A \"front-end\" action state needs at most one outgoing transition that is not an exception-transition."));
432 }
433 }
434 catch (Throwable th)
435 {
436 Throwable cause = th.getCause();
437 int depth = 0;
438 while (cause != null && depth < 7)
439 {
440 th = cause;
441 depth++;
442 }
443 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndActionState::front-end action states can have at most one outgoing transition' ON "
444 + this.THIS().toString() + ": " + th.getMessage(), th);
445 }
446 }
447 }