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.FrontEndController;
14 import org.andromda.metafacades.uml.FrontEndControllerOperation;
15 import org.andromda.metafacades.uml.FrontEndForward;
16 import org.andromda.metafacades.uml.FrontEndParameter;
17 import org.andromda.metafacades.uml.FrontEndView;
18 import org.andromda.metafacades.uml.ParameterFacade;
19 import org.andromda.metafacades.uml.StateVertexFacade;
20 import org.andromda.translation.ocl.validation.OCLCollections;
21 import org.andromda.translation.ocl.validation.OCLIntrospector;
22 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
23 import org.apache.commons.collections.Transformer;
24 import org.apache.log4j.Logger;
25
26
27
28
29
30
31
32
33 public abstract class FrontEndActionLogic
34 extends FrontEndForwardLogicImpl
35 implements FrontEndAction
36 {
37
38
39
40
41 protected Object metaObject;
42
43
44
45
46
47 protected FrontEndActionLogic(Object metaObjectIn, String context)
48 {
49 super(metaObjectIn, getContext(context));
50 this.metaObject = metaObjectIn;
51 }
52
53
54
55
56 private static final Logger logger = Logger.getLogger(FrontEndActionLogic.class);
57
58
59
60
61
62
63 private static String getContext(String context)
64 {
65 if (context == null)
66 {
67 context = "org.andromda.metafacades.uml.FrontEndAction";
68 }
69 return context;
70 }
71
72
73
74
75 @Override
76 public void resetMetafacadeContext(String context)
77 {
78 if (!this.contextRoot)
79 {
80 context = getContext(context);
81 setMetafacadeContext (context);
82 }
83 }
84
85
86
87
88
89 public boolean isFrontEndActionMetaType()
90 {
91 return true;
92 }
93
94
95
96
97
98
99
100 protected abstract boolean handleIsUseCaseStart();
101
102 private boolean __useCaseStart1a;
103 private boolean __useCaseStart1aSet = false;
104
105
106
107
108
109 public final boolean isUseCaseStart()
110 {
111 boolean useCaseStart1a = this.__useCaseStart1a;
112 if (!this.__useCaseStart1aSet)
113 {
114
115 useCaseStart1a = handleIsUseCaseStart();
116
117 this.__useCaseStart1a = useCaseStart1a;
118 if (isMetafacadePropertyCachingEnabled())
119 {
120 this.__useCaseStart1aSet = true;
121 }
122 }
123 return useCaseStart1a;
124 }
125
126
127
128
129
130
131
132
133
134
135 protected abstract ParameterFacade handleFindParameter(String name);
136
137
138
139
140
141
142
143
144 public ParameterFacade findParameter(String name)
145 {
146
147 ParameterFacade returnValue = handleFindParameter(name);
148
149 return returnValue;
150 }
151
152
153
154 private List<FrontEndForward> __getDecisionTransitions1r;
155 private boolean __getDecisionTransitions1rSet = false;
156
157
158
159
160
161
162 public final List<FrontEndForward> getDecisionTransitions()
163 {
164 List<FrontEndForward> getDecisionTransitions1r = this.__getDecisionTransitions1r;
165 if (!this.__getDecisionTransitions1rSet)
166 {
167
168 List result = handleGetDecisionTransitions();
169 List shieldedResult = this.shieldedElements(result);
170 try
171 {
172 getDecisionTransitions1r = (List<FrontEndForward>)shieldedResult;
173 }
174 catch (ClassCastException ex)
175 {
176
177 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getDecisionTransitions List<FrontEndForward> " + result + ": " + shieldedResult);
178 }
179
180 this.__getDecisionTransitions1r = getDecisionTransitions1r;
181 if (isMetafacadePropertyCachingEnabled())
182 {
183 this.__getDecisionTransitions1rSet = true;
184 }
185 }
186 return getDecisionTransitions1r;
187 }
188
189
190
191
192
193 protected abstract List handleGetDecisionTransitions();
194
195 private List<FrontEndForward> __getActionForwards2r;
196 private boolean __getActionForwards2rSet = false;
197
198
199
200
201
202
203 public final List<FrontEndForward> getActionForwards()
204 {
205 List<FrontEndForward> getActionForwards2r = this.__getActionForwards2r;
206 if (!this.__getActionForwards2rSet)
207 {
208
209 List result = handleGetActionForwards();
210 List shieldedResult = this.shieldedElements(result);
211 try
212 {
213 getActionForwards2r = (List<FrontEndForward>)shieldedResult;
214 }
215 catch (ClassCastException ex)
216 {
217
218 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getActionForwards List<FrontEndForward> " + result + ": " + shieldedResult);
219 }
220
221 this.__getActionForwards2r = getActionForwards2r;
222 if (isMetafacadePropertyCachingEnabled())
223 {
224 this.__getActionForwards2rSet = true;
225 }
226 }
227 return getActionForwards2r;
228 }
229
230
231
232
233
234 protected abstract List handleGetActionForwards();
235
236 private List<FrontEndForward> __getTransitions3r;
237 private boolean __getTransitions3rSet = false;
238
239
240
241
242
243 public final List<FrontEndForward> getTransitions()
244 {
245 List<FrontEndForward> getTransitions3r = this.__getTransitions3r;
246 if (!this.__getTransitions3rSet)
247 {
248
249 List result = handleGetTransitions();
250 List shieldedResult = this.shieldedElements(result);
251 try
252 {
253 getTransitions3r = (List<FrontEndForward>)shieldedResult;
254 }
255 catch (ClassCastException ex)
256 {
257
258 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getTransitions List<FrontEndForward> " + result + ": " + shieldedResult);
259 }
260
261 this.__getTransitions3r = getTransitions3r;
262 if (isMetafacadePropertyCachingEnabled())
263 {
264 this.__getTransitions3rSet = true;
265 }
266 }
267 return getTransitions3r;
268 }
269
270
271
272
273
274 protected abstract List handleGetTransitions();
275
276 private FrontEndController __getController4r;
277 private boolean __getController4rSet = false;
278
279
280
281
282
283 public final FrontEndController getController()
284 {
285 FrontEndController getController4r = this.__getController4r;
286 if (!this.__getController4rSet)
287 {
288
289 Object result = handleGetController();
290 MetafacadeBase shieldedResult = this.shieldedElement(result);
291 try
292 {
293 getController4r = (FrontEndController)shieldedResult;
294 }
295 catch (ClassCastException ex)
296 {
297
298 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getController FrontEndController " + result + ": " + shieldedResult);
299 }
300
301 this.__getController4r = getController4r;
302 if (isMetafacadePropertyCachingEnabled())
303 {
304 this.__getController4rSet = true;
305 }
306 }
307 return getController4r;
308 }
309
310
311
312
313
314 protected abstract Object handleGetController();
315
316 private List<FrontEndParameter> __getParameters5r;
317 private boolean __getParameters5rSet = false;
318
319
320
321
322
323
324 public final List<FrontEndParameter> getParameters()
325 {
326 List<FrontEndParameter> getParameters5r = this.__getParameters5r;
327 if (!this.__getParameters5rSet)
328 {
329
330 List result = handleGetParameters();
331 List shieldedResult = this.shieldedElements(result);
332 try
333 {
334 getParameters5r = (List<FrontEndParameter>)shieldedResult;
335 }
336 catch (ClassCastException ex)
337 {
338
339 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getParameters List<FrontEndParameter> " + result + ": " + shieldedResult);
340 }
341
342 this.__getParameters5r = getParameters5r;
343 if (isMetafacadePropertyCachingEnabled())
344 {
345 this.__getParameters5rSet = true;
346 }
347 }
348 return getParameters5r;
349 }
350
351
352
353
354
355 protected abstract List handleGetParameters();
356
357 private List<FrontEndActionState> __getActionStates6r;
358 private boolean __getActionStates6rSet = false;
359
360
361
362
363
364 public final List<FrontEndActionState> getActionStates()
365 {
366 List<FrontEndActionState> getActionStates6r = this.__getActionStates6r;
367 if (!this.__getActionStates6rSet)
368 {
369
370 List result = handleGetActionStates();
371 List shieldedResult = this.shieldedElements(result);
372 try
373 {
374 getActionStates6r = (List<FrontEndActionState>)shieldedResult;
375 }
376 catch (ClassCastException ex)
377 {
378
379 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getActionStates List<FrontEndActionState> " + result + ": " + shieldedResult);
380 }
381
382 this.__getActionStates6r = getActionStates6r;
383 if (isMetafacadePropertyCachingEnabled())
384 {
385 this.__getActionStates6rSet = true;
386 }
387 }
388 return getActionStates6r;
389 }
390
391
392
393
394
395 protected abstract List handleGetActionStates();
396
397 private List<FrontEndParameter> __getFormFields7r;
398 private boolean __getFormFields7rSet = false;
399
400
401
402
403
404
405 public final List<FrontEndParameter> getFormFields()
406 {
407 List<FrontEndParameter> getFormFields7r = this.__getFormFields7r;
408 if (!this.__getFormFields7rSet)
409 {
410
411 List result = handleGetFormFields();
412 List shieldedResult = this.shieldedElements(result);
413 try
414 {
415 getFormFields7r = (List<FrontEndParameter>)shieldedResult;
416 }
417 catch (ClassCastException ex)
418 {
419
420 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getFormFields List<FrontEndParameter> " + result + ": " + shieldedResult);
421 }
422
423 this.__getFormFields7r = getFormFields7r;
424 if (isMetafacadePropertyCachingEnabled())
425 {
426 this.__getFormFields7rSet = true;
427 }
428 }
429 return getFormFields7r;
430 }
431
432
433
434
435
436 protected abstract List handleGetFormFields();
437
438 private List<FrontEndView> __getTargetViews8r;
439 private boolean __getTargetViews8rSet = false;
440
441
442
443
444
445
446 public final List<FrontEndView> getTargetViews()
447 {
448 List<FrontEndView> getTargetViews8r = this.__getTargetViews8r;
449 if (!this.__getTargetViews8rSet)
450 {
451
452 List result = handleGetTargetViews();
453 List shieldedResult = this.shieldedElements(result);
454 try
455 {
456 getTargetViews8r = (List<FrontEndView>)shieldedResult;
457 }
458 catch (ClassCastException ex)
459 {
460
461 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getTargetViews List<FrontEndView> " + result + ": " + shieldedResult);
462 }
463
464 this.__getTargetViews8r = getTargetViews8r;
465 if (isMetafacadePropertyCachingEnabled())
466 {
467 this.__getTargetViews8rSet = true;
468 }
469 }
470 return getTargetViews8r;
471 }
472
473
474
475
476
477 protected abstract List handleGetTargetViews();
478
479 private List<FrontEndControllerOperation> __getDeferredOperations9r;
480 private boolean __getDeferredOperations9rSet = false;
481
482
483
484
485
486
487 public final List<FrontEndControllerOperation> getDeferredOperations()
488 {
489 List<FrontEndControllerOperation> getDeferredOperations9r = this.__getDeferredOperations9r;
490 if (!this.__getDeferredOperations9rSet)
491 {
492
493 List result = handleGetDeferredOperations();
494 List shieldedResult = this.shieldedElements(result);
495 try
496 {
497 getDeferredOperations9r = (List<FrontEndControllerOperation>)shieldedResult;
498 }
499 catch (ClassCastException ex)
500 {
501
502 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getDeferredOperations List<FrontEndControllerOperation> " + result + ": " + shieldedResult);
503 }
504
505 this.__getDeferredOperations9r = getDeferredOperations9r;
506 if (isMetafacadePropertyCachingEnabled())
507 {
508 this.__getDeferredOperations9rSet = true;
509 }
510 }
511 return getDeferredOperations9r;
512 }
513
514
515
516
517
518 protected abstract List handleGetDeferredOperations();
519
520
521
522
523
524
525 public final StateVertexFacade getInput()
526 {
527 StateVertexFacade getInput10r = null;
528
529 Object result = handleGetInput();
530 MetafacadeBase shieldedResult = this.shieldedElement(result);
531 try
532 {
533 getInput10r = (StateVertexFacade)shieldedResult;
534 }
535 catch (ClassCastException ex)
536 {
537
538 FrontEndActionLogic.logger.warn("incorrect metafacade cast for FrontEndActionLogic.getInput StateVertexFacade " + result + ": " + shieldedResult);
539 }
540
541 return getInput10r;
542 }
543
544
545
546
547
548 protected abstract Object handleGetInput();
549
550
551
552
553
554
555
556
557
558
559
560
561 @Override
562 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
563 {
564 super.validateInvariants(validationMessages);
565 try
566 {
567 final Object contextElement = this.THIS();
568 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"parameters"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}}));
569 if (!constraintValid)
570 {
571 validationMessages.add(
572 new ModelValidationMessage(
573 (MetafacadeBase)contextElement ,
574 "org::andromda::metafacades::uml::FrontEndAction::parameters must be unique",
575 "Each front-end action parameter must have a unique name."));
576 }
577 }
578 catch (Throwable th)
579 {
580 Throwable cause = th.getCause();
581 int depth = 0;
582 while (cause != null && depth < 7)
583 {
584 th = cause;
585 depth++;
586 }
587 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndAction::parameters must be unique' ON "
588 + this.THIS().toString() + ": " + th.getMessage(), th);
589 }
590 try
591 {
592 final Object contextElement = this.THIS();
593 boolean constraintValid = OCLResultEnsurer.ensure((Boolean.valueOf(String.valueOf(Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"exitingView"))).booleanValue())).booleanValue()?Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"triggerPresent"))).booleanValue():true));
594 if (!constraintValid)
595 {
596 validationMessages.add(
597 new ModelValidationMessage(
598 (MetafacadeBase)contextElement ,
599 "org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger",
600 "Each action transition coming out of a view must have a trigger (the name is sufficient), it is recommended to add a trigger of type 'signal'."));
601 }
602 }
603 catch (Throwable th)
604 {
605 Throwable cause = th.getCause();
606 int depth = 0;
607 while (cause != null && depth < 7)
608 {
609 th = cause;
610 depth++;
611 }
612 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndAction::each action must carry a trigger' ON "
613 + this.THIS().toString() + ": " + th.getMessage(), th);
614 }
615 }
616 }