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.common.Introspector;
10 import org.andromda.core.metafacade.MetafacadeBase;
11 import org.andromda.core.metafacade.ModelValidationMessage;
12 import org.andromda.metafacades.uml.ActionStateFacade;
13 import org.andromda.metafacades.uml.ActivityGraphFacade;
14 import org.andromda.metafacades.uml.ActorFacade;
15 import org.andromda.metafacades.uml.ClassifierFacade;
16 import org.andromda.metafacades.uml.FinalStateFacade;
17 import org.andromda.metafacades.uml.ModelFacade;
18 import org.andromda.metafacades.uml.ObjectFlowStateFacade;
19 import org.andromda.metafacades.uml.PackageFacade;
20 import org.andromda.metafacades.uml.TransitionFacade;
21 import org.andromda.metafacades.uml.UseCaseFacade;
22 import org.apache.log4j.Logger;
23 import org.omg.uml.UmlPackage;
24
25
26
27
28
29
30
31
32
33
34 public abstract class ModelFacadeLogic
35 extends MetafacadeBase
36 implements ModelFacade
37 {
38
39
40
41
42 protected UmlPackage metaObject;
43
44
45
46
47
48 protected ModelFacadeLogic(UmlPackage metaObjectIn, String context)
49 {
50 super(metaObjectIn, getContext(context));
51 this.metaObject = metaObjectIn;
52 }
53
54
55
56
57 private static final Logger logger = Logger.getLogger(ModelFacadeLogic.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.ModelFacade";
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 isModelFacadeMetaType()
91 {
92 return true;
93 }
94
95
96
97
98
99
100
101
102
103
104 protected abstract UseCaseFacade handleFindUseCaseWithTaggedValueOrHyperlink(String tag, String value);
105
106
107
108
109
110
111
112
113
114
115
116 public UseCaseFacade findUseCaseWithTaggedValueOrHyperlink(String tag, String value)
117 {
118
119 UseCaseFacade returnValue = handleFindUseCaseWithTaggedValueOrHyperlink(tag, value);
120
121 return returnValue;
122 }
123
124
125
126
127
128
129
130
131 protected abstract ClassifierFacade handleFindClassWithTaggedValueOrHyperlink(String tag, String value);
132
133
134
135
136
137
138
139
140
141
142
143 public ClassifierFacade findClassWithTaggedValueOrHyperlink(String tag, String value)
144 {
145
146 ClassifierFacade returnValue = handleFindClassWithTaggedValueOrHyperlink(tag, value);
147
148 return returnValue;
149 }
150
151
152
153
154
155
156
157 protected abstract ActivityGraphFacade handleFindActivityGraphByName(String name);
158
159
160
161
162
163
164
165
166 public ActivityGraphFacade findActivityGraphByName(String name)
167 {
168
169 ActivityGraphFacade returnValue = handleFindActivityGraphByName(name);
170
171 return returnValue;
172 }
173
174
175
176
177
178
179
180
181 protected abstract ActivityGraphFacade handleFindActivityGraphByNameAndStereotype(String name, String stereotypeName);
182
183
184
185
186
187
188
189
190
191
192
193 public ActivityGraphFacade findActivityGraphByNameAndStereotype(String name, String stereotypeName)
194 {
195
196 ActivityGraphFacade returnValue = handleFindActivityGraphByNameAndStereotype(name, stereotypeName);
197
198 return returnValue;
199 }
200
201
202
203
204
205
206
207 protected abstract UseCaseFacade handleFindUseCaseByName(String name);
208
209
210
211
212
213
214
215
216 public UseCaseFacade findUseCaseByName(String name)
217 {
218
219 UseCaseFacade returnValue = handleFindUseCaseByName(name);
220
221 return returnValue;
222 }
223
224
225
226
227
228
229
230
231 protected abstract UseCaseFacade handleFindUseCaseWithNameAndStereotype(String name, String stereotypeName);
232
233
234
235
236
237
238
239
240
241
242
243 public UseCaseFacade findUseCaseWithNameAndStereotype(String name, String stereotypeName)
244 {
245
246 UseCaseFacade returnValue = handleFindUseCaseWithNameAndStereotype(name, stereotypeName);
247
248 return returnValue;
249 }
250
251
252
253
254
255
256
257 protected abstract Collection<FinalStateFacade> handleFindFinalStatesWithNameOrHyperlink(UseCaseFacade useCase);
258
259
260
261
262
263
264
265
266 public Collection<FinalStateFacade> findFinalStatesWithNameOrHyperlink(UseCaseFacade useCase)
267 {
268
269 Collection<FinalStateFacade> returnValue = handleFindFinalStatesWithNameOrHyperlink(useCase);
270
271 return returnValue;
272 }
273
274
275
276
277
278
279
280
281 protected abstract Collection<ActionStateFacade> handleGetAllActionStatesWithStereotype(ActivityGraphFacade activityGraph, String stereotypeName);
282
283
284
285
286
287
288
289
290
291
292
293 public Collection<ActionStateFacade> getAllActionStatesWithStereotype(ActivityGraphFacade activityGraph, String stereotypeName)
294 {
295
296 Collection<ActionStateFacade> returnValue = handleGetAllActionStatesWithStereotype(activityGraph, stereotypeName);
297
298 return returnValue;
299 }
300
301
302
303 private Collection<ClassifierFacade> __getAllClasses1r;
304 private boolean __getAllClasses1rSet = false;
305
306
307
308
309
310
311
312
313
314
315
316 public final Collection<ClassifierFacade> getAllClasses()
317 {
318 Collection<ClassifierFacade> getAllClasses1r = this.__getAllClasses1r;
319 if (!this.__getAllClasses1rSet)
320 {
321
322 Collection result = handleGetAllClasses();
323 List shieldedResult = this.shieldedElements(result);
324 try
325 {
326 getAllClasses1r = (Collection<ClassifierFacade>)shieldedResult;
327 }
328 catch (ClassCastException ex)
329 {
330
331 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllClasses Collection<ClassifierFacade> " + result + ": " + shieldedResult);
332 }
333
334 this.__getAllClasses1r = getAllClasses1r;
335 if (isMetafacadePropertyCachingEnabled())
336 {
337 this.__getAllClasses1rSet = true;
338 }
339 }
340 return getAllClasses1r;
341 }
342
343
344
345
346
347 protected abstract Collection handleGetAllClasses();
348
349
350
351
352
353
354
355
356
357
358
359 public final PackageFacade getRootPackage()
360 {
361 PackageFacade getRootPackage2r = null;
362
363 Object result = handleGetRootPackage();
364 MetafacadeBase shieldedResult = this.shieldedElement(result);
365 try
366 {
367 getRootPackage2r = (PackageFacade)shieldedResult;
368 }
369 catch (ClassCastException ex)
370 {
371
372 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getRootPackage PackageFacade " + result + ": " + shieldedResult);
373 }
374
375 return getRootPackage2r;
376 }
377
378
379
380
381
382 protected abstract Object handleGetRootPackage();
383
384 private Collection<TransitionFacade> __getAllTransitions3r;
385 private boolean __getAllTransitions3rSet = false;
386
387
388
389
390
391
392
393
394
395
396
397 public final Collection<TransitionFacade> getAllTransitions()
398 {
399 Collection<TransitionFacade> getAllTransitions3r = this.__getAllTransitions3r;
400 if (!this.__getAllTransitions3rSet)
401 {
402
403 Collection result = handleGetAllTransitions();
404 List shieldedResult = this.shieldedElements(result);
405 try
406 {
407 getAllTransitions3r = (Collection<TransitionFacade>)shieldedResult;
408 }
409 catch (ClassCastException ex)
410 {
411
412 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllTransitions Collection<TransitionFacade> " + result + ": " + shieldedResult);
413 }
414
415 this.__getAllTransitions3r = getAllTransitions3r;
416 if (isMetafacadePropertyCachingEnabled())
417 {
418 this.__getAllTransitions3rSet = true;
419 }
420 }
421 return getAllTransitions3r;
422 }
423
424
425
426
427
428 protected abstract Collection handleGetAllTransitions();
429
430
431
432
433
434
435
436
437
438
439
440 public final Collection<ActorFacade> getAllActors()
441 {
442 Collection<ActorFacade> getAllActors4r = null;
443
444 Collection result = handleGetAllActors();
445 List shieldedResult = this.shieldedElements(result);
446 try
447 {
448 getAllActors4r = (Collection<ActorFacade>)shieldedResult;
449 }
450 catch (ClassCastException ex)
451 {
452
453 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllActors Collection<ActorFacade> " + result + ": " + shieldedResult);
454 }
455
456 return getAllActors4r;
457 }
458
459
460
461
462
463 protected abstract Collection handleGetAllActors();
464
465
466
467
468
469
470
471
472
473
474
475 public final Collection<UseCaseFacade> getAllUseCases()
476 {
477 Collection<UseCaseFacade> getAllUseCases5r = null;
478
479 Collection result = handleGetAllUseCases();
480 List shieldedResult = this.shieldedElements(result);
481 try
482 {
483 getAllUseCases5r = (Collection<UseCaseFacade>)shieldedResult;
484 }
485 catch (ClassCastException ex)
486 {
487
488 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllUseCases Collection<UseCaseFacade> " + result + ": " + shieldedResult);
489 }
490
491 return getAllUseCases5r;
492 }
493
494
495
496
497
498 protected abstract Collection handleGetAllUseCases();
499
500
501
502
503
504
505
506
507
508
509
510 public final Collection<ActionStateFacade> getAllActionStates()
511 {
512 Collection<ActionStateFacade> getAllActionStates6r = null;
513
514 Collection result = handleGetAllActionStates();
515 List shieldedResult = this.shieldedElements(result);
516 try
517 {
518 getAllActionStates6r = (Collection<ActionStateFacade>)shieldedResult;
519 }
520 catch (ClassCastException ex)
521 {
522
523 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllActionStates Collection<ActionStateFacade> " + result + ": " + shieldedResult);
524 }
525
526 return getAllActionStates6r;
527 }
528
529
530
531
532
533 protected abstract Collection handleGetAllActionStates();
534
535 private Collection<ObjectFlowStateFacade> __getAllObjectFlowStates7r;
536 private boolean __getAllObjectFlowStates7rSet = false;
537
538
539
540
541
542
543
544
545
546
547
548 public final Collection<ObjectFlowStateFacade> getAllObjectFlowStates()
549 {
550 Collection<ObjectFlowStateFacade> getAllObjectFlowStates7r = this.__getAllObjectFlowStates7r;
551 if (!this.__getAllObjectFlowStates7rSet)
552 {
553
554 Collection result = handleGetAllObjectFlowStates();
555 List shieldedResult = this.shieldedElements(result);
556 try
557 {
558 getAllObjectFlowStates7r = (Collection<ObjectFlowStateFacade>)shieldedResult;
559 }
560 catch (ClassCastException ex)
561 {
562
563 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllObjectFlowStates Collection<ObjectFlowStateFacade> " + result + ": " + shieldedResult);
564 }
565
566 this.__getAllObjectFlowStates7r = getAllObjectFlowStates7r;
567 if (isMetafacadePropertyCachingEnabled())
568 {
569 this.__getAllObjectFlowStates7rSet = true;
570 }
571 }
572 return getAllObjectFlowStates7r;
573 }
574
575
576
577
578
579 protected abstract Collection handleGetAllObjectFlowStates();
580
581
582
583
584
585 @Override
586 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
587 {
588 }
589
590
591
592
593 private static final String NAME_PROPERTY = "name";
594 private static final String FQNAME_PROPERTY = "fullyQualifiedName";
595
596
597
598
599 @Override
600 public String toString()
601 {
602 final StringBuilder toString = new StringBuilder(this.getClass().getName());
603 toString.append("[");
604 try
605 {
606 toString.append(Introspector.instance().getProperty(this, FQNAME_PROPERTY));
607 }
608 catch (final Throwable tryAgain)
609 {
610 try
611 {
612 toString.append(Introspector.instance().getProperty(this, NAME_PROPERTY));
613 }
614 catch (final Throwable ignore)
615 {
616
617 }
618 }
619 toString.append("]");
620 return toString.toString();
621 }
622 }