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.FrontEndActivityGraph;
13 import org.andromda.metafacades.uml.FrontEndController;
14 import org.andromda.metafacades.uml.FrontEndFinalState;
15 import org.andromda.metafacades.uml.FrontEndParameter;
16 import org.andromda.metafacades.uml.FrontEndUseCase;
17 import org.andromda.metafacades.uml.FrontEndView;
18 import org.andromda.metafacades.uml.Role;
19 import org.andromda.translation.ocl.validation.OCLCollections;
20 import org.andromda.translation.ocl.validation.OCLExpressions;
21 import org.andromda.translation.ocl.validation.OCLIntrospector;
22 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
23 import org.apache.commons.collections.Predicate;
24 import org.apache.commons.collections.Transformer;
25 import org.apache.log4j.Logger;
26 import org.omg.uml.behavioralelements.usecases.UseCase;
27
28
29
30
31
32
33
34 public abstract class FrontEndUseCaseLogic
35 extends UseCaseFacadeLogicImpl
36 implements FrontEndUseCase
37 {
38
39
40
41
42 protected Object metaObject;
43
44
45
46
47
48 protected FrontEndUseCaseLogic(Object metaObjectIn, String context)
49 {
50 super((UseCase)metaObjectIn, getContext(context));
51 this.metaObject = metaObjectIn;
52 }
53
54
55
56
57 private static final Logger logger = Logger.getLogger(FrontEndUseCaseLogic.class);
58
59
60
61
62
63
64 private static String getContext(String context)
65 {
66 if (context == null)
67 {
68 context = "org.andromda.metafacades.uml.FrontEndUseCase";
69 }
70 return context;
71 }
72
73
74
75
76 @Override
77 public void resetMetafacadeContext(String context)
78 {
79 if (!this.contextRoot)
80 {
81 context = getContext(context);
82 setMetafacadeContext (context);
83 }
84 }
85
86
87
88
89
90 public boolean isFrontEndUseCaseMetaType()
91 {
92 return true;
93 }
94
95
96
97
98
99
100
101 protected abstract boolean handleIsEntryUseCase();
102
103 private boolean __entryUseCase1a;
104 private boolean __entryUseCase1aSet = false;
105
106
107
108
109
110 public final boolean isEntryUseCase()
111 {
112 boolean entryUseCase1a = this.__entryUseCase1a;
113 if (!this.__entryUseCase1aSet)
114 {
115
116 entryUseCase1a = handleIsEntryUseCase();
117
118 this.__entryUseCase1a = entryUseCase1a;
119 if (isMetafacadePropertyCachingEnabled())
120 {
121 this.__entryUseCase1aSet = true;
122 }
123 }
124 return entryUseCase1a;
125 }
126
127
128
129
130
131 protected abstract boolean handleIsSecured();
132
133 private boolean __secured2a;
134 private boolean __secured2aSet = false;
135
136
137
138
139
140
141 public final boolean isSecured()
142 {
143 boolean secured2a = this.__secured2a;
144 if (!this.__secured2aSet)
145 {
146
147 secured2a = handleIsSecured();
148
149 this.__secured2a = secured2a;
150 if (isMetafacadePropertyCachingEnabled())
151 {
152 this.__secured2aSet = true;
153 }
154 }
155 return secured2a;
156 }
157
158
159
160 private List<FrontEndFinalState> __getReferencingFinalStates1r;
161 private boolean __getReferencingFinalStates1rSet = false;
162
163
164
165
166
167 public final List<FrontEndFinalState> getReferencingFinalStates()
168 {
169 List<FrontEndFinalState> getReferencingFinalStates1r = this.__getReferencingFinalStates1r;
170 if (!this.__getReferencingFinalStates1rSet)
171 {
172
173 List result = handleGetReferencingFinalStates();
174 List shieldedResult = this.shieldedElements(result);
175 try
176 {
177 getReferencingFinalStates1r = (List<FrontEndFinalState>)shieldedResult;
178 }
179 catch (ClassCastException ex)
180 {
181
182 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getReferencingFinalStates List<FrontEndFinalState> " + result + ": " + shieldedResult);
183 }
184
185 this.__getReferencingFinalStates1r = getReferencingFinalStates1r;
186 if (isMetafacadePropertyCachingEnabled())
187 {
188 this.__getReferencingFinalStates1rSet = true;
189 }
190 }
191 return getReferencingFinalStates1r;
192 }
193
194
195
196
197
198 protected abstract List handleGetReferencingFinalStates();
199
200 private List<Role> __getAllRoles2r;
201 private boolean __getAllRoles2rSet = false;
202
203
204
205
206
207 public final List<Role> getAllRoles()
208 {
209 List<Role> getAllRoles2r = this.__getAllRoles2r;
210 if (!this.__getAllRoles2rSet)
211 {
212
213 List result = handleGetAllRoles();
214 List shieldedResult = this.shieldedElements(result);
215 try
216 {
217 getAllRoles2r = (List<Role>)shieldedResult;
218 }
219 catch (ClassCastException ex)
220 {
221
222 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getAllRoles List<Role> " + result + ": " + shieldedResult);
223 }
224
225 this.__getAllRoles2r = getAllRoles2r;
226 if (isMetafacadePropertyCachingEnabled())
227 {
228 this.__getAllRoles2rSet = true;
229 }
230 }
231 return getAllRoles2r;
232 }
233
234
235
236
237
238 protected abstract List handleGetAllRoles();
239
240 private List<Role> __getRoles3r;
241 private boolean __getRoles3rSet = false;
242
243
244
245
246
247 public final List<Role> getRoles()
248 {
249 List<Role> getRoles3r = this.__getRoles3r;
250 if (!this.__getRoles3rSet)
251 {
252
253 List result = handleGetRoles();
254 List shieldedResult = this.shieldedElements(result);
255 try
256 {
257 getRoles3r = (List<Role>)shieldedResult;
258 }
259 catch (ClassCastException ex)
260 {
261
262 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getRoles List<Role> " + result + ": " + shieldedResult);
263 }
264
265 this.__getRoles3r = getRoles3r;
266 if (isMetafacadePropertyCachingEnabled())
267 {
268 this.__getRoles3rSet = true;
269 }
270 }
271 return getRoles3r;
272 }
273
274
275
276
277
278 protected abstract List handleGetRoles();
279
280 private FrontEndController __getController4r;
281 private boolean __getController4rSet = false;
282
283
284
285
286
287 public final FrontEndController getController()
288 {
289 FrontEndController getController4r = this.__getController4r;
290 if (!this.__getController4rSet)
291 {
292
293 Object result = handleGetController();
294 MetafacadeBase shieldedResult = this.shieldedElement(result);
295 try
296 {
297 getController4r = (FrontEndController)shieldedResult;
298 }
299 catch (ClassCastException ex)
300 {
301
302 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getController FrontEndController " + result + ": " + shieldedResult);
303 }
304
305 this.__getController4r = getController4r;
306 if (isMetafacadePropertyCachingEnabled())
307 {
308 this.__getController4rSet = true;
309 }
310 }
311 return getController4r;
312 }
313
314
315
316
317
318 protected abstract Object handleGetController();
319
320 private List<FrontEndView> __getViews5r;
321 private boolean __getViews5rSet = false;
322
323
324
325
326
327 public final List<FrontEndView> getViews()
328 {
329 List<FrontEndView> getViews5r = this.__getViews5r;
330 if (!this.__getViews5rSet)
331 {
332
333 List result = handleGetViews();
334 List shieldedResult = this.shieldedElements(result);
335 try
336 {
337 getViews5r = (List<FrontEndView>)shieldedResult;
338 }
339 catch (ClassCastException ex)
340 {
341
342 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getViews List<FrontEndView> " + result + ": " + shieldedResult);
343 }
344
345 this.__getViews5r = getViews5r;
346 if (isMetafacadePropertyCachingEnabled())
347 {
348 this.__getViews5rSet = true;
349 }
350 }
351 return getViews5r;
352 }
353
354
355
356
357
358 protected abstract List handleGetViews();
359
360 private List<FrontEndAction> __getActions6r;
361 private boolean __getActions6rSet = false;
362
363
364
365
366
367 public final List<FrontEndAction> getActions()
368 {
369 List<FrontEndAction> getActions6r = this.__getActions6r;
370 if (!this.__getActions6rSet)
371 {
372
373 List result = handleGetActions();
374 List shieldedResult = this.shieldedElements(result);
375 try
376 {
377 getActions6r = (List<FrontEndAction>)shieldedResult;
378 }
379 catch (ClassCastException ex)
380 {
381
382 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getActions List<FrontEndAction> " + result + ": " + shieldedResult);
383 }
384
385 this.__getActions6r = getActions6r;
386 if (isMetafacadePropertyCachingEnabled())
387 {
388 this.__getActions6rSet = true;
389 }
390 }
391 return getActions6r;
392 }
393
394
395
396
397
398 protected abstract List handleGetActions();
399
400 private List<FrontEndUseCase> __getAllUseCases7r;
401 private boolean __getAllUseCases7rSet = false;
402
403
404
405
406
407 public final List<FrontEndUseCase> getAllUseCases()
408 {
409 List<FrontEndUseCase> getAllUseCases7r = this.__getAllUseCases7r;
410 if (!this.__getAllUseCases7rSet)
411 {
412
413 List result = handleGetAllUseCases();
414 List shieldedResult = this.shieldedElements(result);
415 try
416 {
417 getAllUseCases7r = (List<FrontEndUseCase>)shieldedResult;
418 }
419 catch (ClassCastException ex)
420 {
421
422 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getAllUseCases List<FrontEndUseCase> " + result + ": " + shieldedResult);
423 }
424
425 this.__getAllUseCases7r = getAllUseCases7r;
426 if (isMetafacadePropertyCachingEnabled())
427 {
428 this.__getAllUseCases7rSet = true;
429 }
430 }
431 return getAllUseCases7r;
432 }
433
434
435
436
437
438 protected abstract List handleGetAllUseCases();
439
440 private FrontEndView __getInitialView8r;
441 private boolean __getInitialView8rSet = false;
442
443
444
445
446
447 public final FrontEndView getInitialView()
448 {
449 FrontEndView getInitialView8r = this.__getInitialView8r;
450 if (!this.__getInitialView8rSet)
451 {
452
453 Object result = handleGetInitialView();
454 MetafacadeBase shieldedResult = this.shieldedElement(result);
455 try
456 {
457 getInitialView8r = (FrontEndView)shieldedResult;
458 }
459 catch (ClassCastException ex)
460 {
461
462 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getInitialView FrontEndView " + result + ": " + shieldedResult);
463 }
464
465 this.__getInitialView8r = getInitialView8r;
466 if (isMetafacadePropertyCachingEnabled())
467 {
468 this.__getInitialView8rSet = true;
469 }
470 }
471 return getInitialView8r;
472 }
473
474
475
476
477
478 protected abstract Object handleGetInitialView();
479
480 private FrontEndActivityGraph __getActivityGraph9r;
481 private boolean __getActivityGraph9rSet = false;
482
483
484
485
486
487 public final FrontEndActivityGraph getActivityGraph()
488 {
489 FrontEndActivityGraph getActivityGraph9r = this.__getActivityGraph9r;
490 if (!this.__getActivityGraph9rSet)
491 {
492
493 Object result = handleGetActivityGraph();
494 MetafacadeBase shieldedResult = this.shieldedElement(result);
495 try
496 {
497 getActivityGraph9r = (FrontEndActivityGraph)shieldedResult;
498 }
499 catch (ClassCastException ex)
500 {
501
502 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getActivityGraph FrontEndActivityGraph " + result + ": " + shieldedResult);
503 }
504
505 this.__getActivityGraph9r = getActivityGraph9r;
506 if (isMetafacadePropertyCachingEnabled())
507 {
508 this.__getActivityGraph9rSet = true;
509 }
510 }
511 return getActivityGraph9r;
512 }
513
514
515
516
517
518 protected abstract Object handleGetActivityGraph();
519
520 private List<FrontEndParameter> __getViewVariables10r;
521 private boolean __getViewVariables10rSet = false;
522
523
524
525
526
527 public final List<FrontEndParameter> getViewVariables()
528 {
529 List<FrontEndParameter> getViewVariables10r = this.__getViewVariables10r;
530 if (!this.__getViewVariables10rSet)
531 {
532
533 List result = handleGetViewVariables();
534 List shieldedResult = this.shieldedElements(result);
535 try
536 {
537 getViewVariables10r = (List<FrontEndParameter>)shieldedResult;
538 }
539 catch (ClassCastException ex)
540 {
541
542 FrontEndUseCaseLogic.logger.warn("incorrect metafacade cast for FrontEndUseCaseLogic.getViewVariables List<FrontEndParameter> " + result + ": " + shieldedResult);
543 }
544
545 this.__getViewVariables10r = getViewVariables10r;
546 if (isMetafacadePropertyCachingEnabled())
547 {
548 this.__getViewVariables10rSet = true;
549 }
550 }
551 return getViewVariables10r;
552 }
553
554
555
556
557
558 protected abstract List handleGetViewVariables();
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576 @Override
577 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
578 {
579 super.validateInvariants(validationMessages);
580 try
581 {
582 final Object contextElement = this.THIS();
583 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"activityGraph")));
584 if (!constraintValid)
585 {
586 validationMessages.add(
587 new ModelValidationMessage(
588 (MetafacadeBase)contextElement ,
589 "org::andromda::metafacades::uml::FrontEndUseCase::each usecase needs one and only one graph",
590 "Each use-case needs one and only one activity graph."));
591 }
592 }
593 catch (Throwable th)
594 {
595 Throwable cause = th.getCause();
596 int depth = 0;
597 while (cause != null && depth < 7)
598 {
599 th = cause;
600 depth++;
601 }
602 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndUseCase::each usecase needs one and only one graph' ON "
603 + this.THIS().toString() + ": " + th.getMessage(), th);
604 }
605 try
606 {
607 final Object contextElement = this.THIS();
608 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.one(OCLIntrospector.invoke(contextElement,"allUseCases"),new Predicate(){public boolean evaluate(Object object){return Boolean.valueOf(String.valueOf(OCLExpressions.equal(OCLIntrospector.invoke(object,"entryUseCase"),true))).booleanValue();}}));
609 if (!constraintValid)
610 {
611 validationMessages.add(
612 new ModelValidationMessage(
613 (MetafacadeBase)contextElement ,
614 "org::andromda::metafacades::uml::FrontEndUseCase::one and only one usecase must be a FrontEndApplication",
615 "One and only one use-case must be marked as the application entry use-case. Currently this is done by adding the FrontEndApplication stereotype to it."));
616 }
617 }
618 catch (Throwable th)
619 {
620 Throwable cause = th.getCause();
621 int depth = 0;
622 while (cause != null && depth < 7)
623 {
624 th = cause;
625 depth++;
626 }
627 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndUseCase::one and only one usecase must be a FrontEndApplication' ON "
628 + this.THIS().toString() + ": " + th.getMessage(), th);
629 }
630 try
631 {
632 final Object contextElement = this.THIS();
633 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"name"))&&OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"model.allUseCases"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}}));
634 if (!constraintValid)
635 {
636 validationMessages.add(
637 new ModelValidationMessage(
638 (MetafacadeBase)contextElement ,
639 "org::andromda::metafacades::uml::FrontEndUseCase::non-empty unique usecase name",
640 "Each use-case must have a non-empty name that is unique among all use-cases."));
641 }
642 }
643 catch (Throwable th)
644 {
645 Throwable cause = th.getCause();
646 int depth = 0;
647 while (cause != null && depth < 7)
648 {
649 th = cause;
650 depth++;
651 }
652 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndUseCase::non-empty unique usecase name' ON "
653 + this.THIS().toString() + ": " + th.getMessage(), th);
654 }
655 try
656 {
657 final Object contextElement = this.THIS();
658 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"packageName")));
659 if (!constraintValid)
660 {
661 validationMessages.add(
662 new ModelValidationMessage(
663 (MetafacadeBase)contextElement ,
664 "org::andromda::metafacades::uml::FrontEndUseCase::each front-end use-case needs to be in a package",
665 "Each front-end use-case is required to be modeled in a package, doing otherwise will result in uncompileable code due to filename collisions."));
666 }
667 }
668 catch (Throwable th)
669 {
670 Throwable cause = th.getCause();
671 int depth = 0;
672 while (cause != null && depth < 7)
673 {
674 th = cause;
675 depth++;
676 }
677 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndUseCase::each front-end use-case needs to be in a package' ON "
678 + this.THIS().toString() + ": " + th.getMessage(), th);
679 }
680 }
681 }