1
2
3
4
5 package org.andromda.cartridges.bpm4struts.metafacades;
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.MetafacadeFactory;
12 import org.andromda.core.metafacade.ModelValidationMessage;
13 import org.andromda.metafacades.uml.ConstraintFacade;
14 import org.andromda.metafacades.uml.DependencyFacade;
15 import org.andromda.metafacades.uml.EventFacade;
16 import org.andromda.metafacades.uml.FinalStateFacade;
17 import org.andromda.metafacades.uml.FrontEndFinalState;
18 import org.andromda.metafacades.uml.FrontEndParameter;
19 import org.andromda.metafacades.uml.FrontEndUseCase;
20 import org.andromda.metafacades.uml.ModelElementFacade;
21 import org.andromda.metafacades.uml.ModelFacade;
22 import org.andromda.metafacades.uml.PackageFacade;
23 import org.andromda.metafacades.uml.PartitionFacade;
24 import org.andromda.metafacades.uml.StateFacade;
25 import org.andromda.metafacades.uml.StateMachineFacade;
26 import org.andromda.metafacades.uml.StereotypeFacade;
27 import org.andromda.metafacades.uml.TaggedValueFacade;
28 import org.andromda.metafacades.uml.TemplateParameterFacade;
29 import org.andromda.metafacades.uml.TransitionFacade;
30 import org.andromda.metafacades.uml.TypeMappings;
31 import org.andromda.translation.ocl.validation.OCLCollections;
32 import org.andromda.translation.ocl.validation.OCLIntrospector;
33 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
34 import org.apache.log4j.Logger;
35
36
37
38
39
40
41
42
43 public abstract class StrutsFinalStateLogic
44 extends MetafacadeBase
45 implements StrutsFinalState
46 {
47
48
49
50
51 protected Object metaObject;
52
53
54
55
56
57 protected StrutsFinalStateLogic(Object metaObjectIn, String context)
58 {
59 super(metaObjectIn, getContext(context));
60 this.superFinalStateFacade =
61 (FinalStateFacade)
62 MetafacadeFactory.getInstance().createFacadeImpl(
63 "org.andromda.metafacades.uml.FinalStateFacade",
64 metaObjectIn,
65 getContext(context));
66 this.superFrontEndFinalState =
67 (FrontEndFinalState)
68 MetafacadeFactory.getInstance().createFacadeImpl(
69 "org.andromda.metafacades.uml.FrontEndFinalState",
70 metaObjectIn,
71 getContext(context));
72 this.metaObject = metaObjectIn;
73 }
74
75
76
77
78 private static final Logger logger = Logger.getLogger(StrutsFinalStateLogic.class);
79
80
81
82
83
84
85 private static String getContext(String context)
86 {
87 if (context == null)
88 {
89 context = "org.andromda.cartridges.bpm4struts.metafacades.StrutsFinalState";
90 }
91 return context;
92 }
93
94 private FinalStateFacade superFinalStateFacade;
95 private boolean superFinalStateFacadeInitialized = false;
96
97
98
99
100
101 protected FinalStateFacade getSuperFinalStateFacade()
102 {
103 if (!this.superFinalStateFacadeInitialized)
104 {
105 ((MetafacadeBase)this.superFinalStateFacade).setMetafacadeContext(this.getMetafacadeContext());
106 this.superFinalStateFacadeInitialized = true;
107 }
108 return this.superFinalStateFacade;
109 }
110
111 private FrontEndFinalState superFrontEndFinalState;
112 private boolean superFrontEndFinalStateInitialized = false;
113
114
115
116
117
118 protected FrontEndFinalState getSuperFrontEndFinalState()
119 {
120 if (!this.superFrontEndFinalStateInitialized)
121 {
122 ((MetafacadeBase)this.superFrontEndFinalState).setMetafacadeContext(this.getMetafacadeContext());
123 this.superFrontEndFinalStateInitialized = true;
124 }
125 return this.superFrontEndFinalState;
126 }
127
128
129
130
131
132 @Override
133 public void resetMetafacadeContext(String context)
134 {
135 if (!this.contextRoot)
136 {
137 context = getContext(context);
138 setMetafacadeContext (context);
139 if (this.superFinalStateFacadeInitialized)
140 {
141 ((MetafacadeBase)this.superFinalStateFacade).resetMetafacadeContext(context);
142 }
143 if (this.superFrontEndFinalStateInitialized)
144 {
145 ((MetafacadeBase)this.superFrontEndFinalState).resetMetafacadeContext(context);
146 }
147 }
148 }
149
150
151
152
153
154 public boolean isStrutsFinalStateMetaType()
155 {
156 return true;
157 }
158
159
160
161
162
163
164
165 protected abstract String handleGetFullPath();
166
167 private String __fullPath1a;
168 private boolean __fullPath1aSet = false;
169
170
171
172
173
174
175
176 public final String getFullPath()
177 {
178 String fullPath1a = this.__fullPath1a;
179 if (!this.__fullPath1aSet)
180 {
181
182 fullPath1a = handleGetFullPath();
183
184 this.__fullPath1a = fullPath1a;
185 if (isMetafacadePropertyCachingEnabled())
186 {
187 this.__fullPath1aSet = true;
188 }
189 }
190 return fullPath1a;
191 }
192
193
194
195
196
197
198
199 public boolean isFinalStateFacadeMetaType()
200 {
201 return true;
202 }
203
204
205
206
207
208 public boolean isFrontEndFinalStateMetaType()
209 {
210 return true;
211 }
212
213
214
215
216
217 public boolean isStateFacadeMetaType()
218 {
219 return true;
220 }
221
222
223
224
225
226 public boolean isStateVertexFacadeMetaType()
227 {
228 return true;
229 }
230
231
232
233
234
235 public boolean isModelElementFacadeMetaType()
236 {
237 return true;
238 }
239
240
241
242
243
244
245 public void copyTaggedValues(ModelElementFacade element)
246 {
247 this.getSuperFinalStateFacade().copyTaggedValues(element);
248 }
249
250
251
252
253
254
255 public Object findTaggedValue(String tagName)
256 {
257 return this.getSuperFinalStateFacade().findTaggedValue(tagName);
258 }
259
260
261
262
263
264
265 public Collection<Object> findTaggedValues(String tagName)
266 {
267 return this.getSuperFinalStateFacade().findTaggedValues(tagName);
268 }
269
270
271
272
273
274
275
276 public String getBindedFullyQualifiedName(ModelElementFacade bindedElement)
277 {
278 return this.getSuperFinalStateFacade().getBindedFullyQualifiedName(bindedElement);
279 }
280
281
282
283
284
285 public Collection<ConstraintFacade> getConstraints()
286 {
287 return this.getSuperFinalStateFacade().getConstraints();
288 }
289
290
291
292
293
294
295 public Collection<ConstraintFacade> getConstraints(String kind)
296 {
297 return this.getSuperFinalStateFacade().getConstraints(kind);
298 }
299
300
301
302
303
304
305
306 public String getDocumentation(String indent)
307 {
308 return this.getSuperFinalStateFacade().getDocumentation(indent);
309 }
310
311
312
313
314
315
316
317
318 public String getDocumentation(String indent, int lineLength)
319 {
320 return this.getSuperFinalStateFacade().getDocumentation(indent, lineLength);
321 }
322
323
324
325
326
327
328
329 public String getDocumentation(String indent, int lineLength, boolean htmlStyle)
330 {
331 return this.getSuperFinalStateFacade().getDocumentation(indent, lineLength, htmlStyle);
332 }
333
334
335
336
337
338 public String getFullyQualifiedName()
339 {
340 return this.getSuperFinalStateFacade().getFullyQualifiedName();
341 }
342
343
344
345
346
347
348
349
350 public String getFullyQualifiedName(boolean modelName)
351 {
352 return this.getSuperFinalStateFacade().getFullyQualifiedName(modelName);
353 }
354
355
356
357
358
359
360 public String getFullyQualifiedNamePath()
361 {
362 return this.getSuperFinalStateFacade().getFullyQualifiedNamePath();
363 }
364
365
366
367
368
369 public String getId()
370 {
371 return this.getSuperFinalStateFacade().getId();
372 }
373
374
375
376
377
378
379
380
381
382 public Collection<String> getKeywords()
383 {
384 return this.getSuperFinalStateFacade().getKeywords();
385 }
386
387
388
389
390
391 public String getLabel()
392 {
393 return this.getSuperFinalStateFacade().getLabel();
394 }
395
396
397
398
399
400 public TypeMappings getLanguageMappings()
401 {
402 return this.getSuperFinalStateFacade().getLanguageMappings();
403 }
404
405
406
407
408
409
410 public ModelFacade getModel()
411 {
412 return this.getSuperFinalStateFacade().getModel();
413 }
414
415
416
417
418
419 public String getName()
420 {
421 return this.getSuperFinalStateFacade().getName();
422 }
423
424
425
426
427
428 public ModelElementFacade getPackage()
429 {
430 return this.getSuperFinalStateFacade().getPackage();
431 }
432
433
434
435
436
437 public String getPackageName()
438 {
439 return this.getSuperFinalStateFacade().getPackageName();
440 }
441
442
443
444
445
446
447 public String getPackageName(boolean modelName)
448 {
449 return this.getSuperFinalStateFacade().getPackageName(modelName);
450 }
451
452
453
454
455
456 public String getPackagePath()
457 {
458 return this.getSuperFinalStateFacade().getPackagePath();
459 }
460
461
462
463
464
465
466
467
468 public String getQualifiedName()
469 {
470 return this.getSuperFinalStateFacade().getQualifiedName();
471 }
472
473
474
475
476
477 public PackageFacade getRootPackage()
478 {
479 return this.getSuperFinalStateFacade().getRootPackage();
480 }
481
482
483
484
485
486 public Collection<DependencyFacade> getSourceDependencies()
487 {
488 return this.getSuperFinalStateFacade().getSourceDependencies();
489 }
490
491
492
493
494
495
496 public StateMachineFacade getStateMachineContext()
497 {
498 return this.getSuperFinalStateFacade().getStateMachineContext();
499 }
500
501
502
503
504
505 public Collection<String> getStereotypeNames()
506 {
507 return this.getSuperFinalStateFacade().getStereotypeNames();
508 }
509
510
511
512
513
514 public Collection<StereotypeFacade> getStereotypes()
515 {
516 return this.getSuperFinalStateFacade().getStereotypes();
517 }
518
519
520
521
522
523 public Collection<TaggedValueFacade> getTaggedValues()
524 {
525 return this.getSuperFinalStateFacade().getTaggedValues();
526 }
527
528
529
530
531
532 public Collection<DependencyFacade> getTargetDependencies()
533 {
534 return this.getSuperFinalStateFacade().getTargetDependencies();
535 }
536
537
538
539
540
541 public Object getTemplateParameter(String parameterName)
542 {
543 return this.getSuperFinalStateFacade().getTemplateParameter(parameterName);
544 }
545
546
547
548
549
550 public Collection<TemplateParameterFacade> getTemplateParameters()
551 {
552 return this.getSuperFinalStateFacade().getTemplateParameters();
553 }
554
555
556
557
558
559
560 public String getVisibility()
561 {
562 return this.getSuperFinalStateFacade().getVisibility();
563 }
564
565
566
567
568
569
570 public boolean hasExactStereotype(String stereotypeName)
571 {
572 return this.getSuperFinalStateFacade().hasExactStereotype(stereotypeName);
573 }
574
575
576
577
578
579
580 public boolean hasKeyword(String keywordName)
581 {
582 return this.getSuperFinalStateFacade().hasKeyword(keywordName);
583 }
584
585
586
587
588
589
590
591
592
593
594
595
596
597 public boolean hasStereotype(String stereotypeName)
598 {
599 return this.getSuperFinalStateFacade().hasStereotype(stereotypeName);
600 }
601
602
603
604
605
606
607 public boolean isBindingDependenciesPresent()
608 {
609 return this.getSuperFinalStateFacade().isBindingDependenciesPresent();
610 }
611
612
613
614
615
616 public boolean isConstraintsPresent()
617 {
618 return this.getSuperFinalStateFacade().isConstraintsPresent();
619 }
620
621
622
623
624
625 public boolean isDocumentationPresent()
626 {
627 return this.getSuperFinalStateFacade().isDocumentationPresent();
628 }
629
630
631
632
633
634 public boolean isReservedWord()
635 {
636 return this.getSuperFinalStateFacade().isReservedWord();
637 }
638
639
640
641
642
643
644 public boolean isTemplateParametersPresent()
645 {
646 return this.getSuperFinalStateFacade().isTemplateParametersPresent();
647 }
648
649
650
651
652
653
654
655 public boolean isValidIdentifierName()
656 {
657 return this.getSuperFinalStateFacade().isValidIdentifierName();
658 }
659
660
661
662
663
664
665
666 public String translateConstraint(String name, String translation)
667 {
668 return this.getSuperFinalStateFacade().translateConstraint(name, translation);
669 }
670
671
672
673
674
675 public String[] translateConstraints(String translation)
676 {
677 return this.getSuperFinalStateFacade().translateConstraints(translation);
678 }
679
680
681
682
683
684 public String[] translateConstraints(String kind, String translation)
685 {
686 return this.getSuperFinalStateFacade().translateConstraints(kind, translation);
687 }
688
689
690
691
692
693 public Collection<EventFacade> getDeferrableEvents()
694 {
695 return this.getSuperFinalStateFacade().getDeferrableEvents();
696 }
697
698
699
700
701
702
703
704
705
706
707
708
709 public StateFacade getContainer()
710 {
711 return this.getSuperFinalStateFacade().getContainer();
712 }
713
714
715
716
717
718
719
720
721
722 public Collection<TransitionFacade> getIncomings()
723 {
724 return this.getSuperFinalStateFacade().getIncomings();
725 }
726
727
728
729
730
731
732
733
734
735 public Collection<TransitionFacade> getOutgoings()
736 {
737 return this.getSuperFinalStateFacade().getOutgoings();
738 }
739
740
741
742
743
744 public PartitionFacade getPartition()
745 {
746 return this.getSuperFinalStateFacade().getPartition();
747 }
748
749
750
751
752
753
754
755
756
757
758
759
760 public StateMachineFacade getStateMachine()
761 {
762 return this.getSuperFinalStateFacade().getStateMachine();
763 }
764
765
766
767
768
769
770
771 public List<FrontEndParameter> getInterUseCaseParameters()
772 {
773 return this.getSuperFrontEndFinalState().getInterUseCaseParameters();
774 }
775
776
777
778
779
780 public FrontEndUseCase getTargetUseCase()
781 {
782 return this.getSuperFrontEndFinalState().getTargetUseCase();
783 }
784
785
786
787
788
789 public boolean isContainedInFrontEndUseCase()
790 {
791 return this.getSuperFrontEndFinalState().isContainedInFrontEndUseCase();
792 }
793
794
795
796
797 @Override
798 public void initialize()
799 {
800 this.getSuperFinalStateFacade().initialize();
801 this.getSuperFrontEndFinalState().initialize();
802 }
803
804
805
806
807
808 @Override
809 public Object getValidationOwner()
810 {
811 Object owner = this.getSuperFinalStateFacade().getValidationOwner();
812 if (owner == null)
813 {
814 owner = this.getSuperFrontEndFinalState().getValidationOwner();
815 }
816 return owner;
817 }
818
819
820
821
822
823 @Override
824 public String getValidationName()
825 {
826 String name = this.getSuperFinalStateFacade().getValidationName();
827 if (name == null)
828 {
829 name = this.getSuperFrontEndFinalState().getValidationName();
830 }
831 return name;
832 }
833
834
835
836
837
838
839
840
841 @Override
842 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
843 {
844 this.getSuperFinalStateFacade().validateInvariants(validationMessages);
845 this.getSuperFrontEndFinalState().validateInvariants(validationMessages);
846 try
847 {
848 final Object contextElement = this.THIS();
849 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"fullPath")));
850 if (!constraintValid)
851 {
852 validationMessages.add(
853 new ModelValidationMessage(
854 (MetafacadeBase)contextElement ,
855 "org::andromda::cartridges::bpm4struts::metafacades::StrutsFinalState::name must uniquely match usecase",
856 "The name of this final state must not be null and exactly match the name of a use-case. Alternatively it is possible to reference a use-case using an hyperlink (some UML tools support this). In both cases that use-case MUST carry the FrontEndUseCase stereotype. Finally you may also specify an actual hyperlink to an external resource, either in the final state's name, or as a webpage link as supported by some UML tools."));
857 }
858 }
859 catch (Throwable th)
860 {
861 Throwable cause = th.getCause();
862 int depth = 0;
863 while (cause != null && depth < 7)
864 {
865 th = cause;
866 depth++;
867 }
868 logger.error("Error validating constraint 'org::andromda::cartridges::bpm4struts::metafacades::StrutsFinalState::name must uniquely match usecase' ON "
869 + this.THIS().toString() + ": " + th.getMessage(), th);
870 }
871 }
872
873
874
875
876 private static final String NAME_PROPERTY = "name";
877 private static final String FQNAME_PROPERTY = "fullyQualifiedName";
878
879
880
881
882 @Override
883 public String toString()
884 {
885 final StringBuilder toString = new StringBuilder(this.getClass().getName());
886 toString.append("[");
887 try
888 {
889 toString.append(Introspector.instance().getProperty(this, FQNAME_PROPERTY));
890 }
891 catch (final Throwable tryAgain)
892 {
893 try
894 {
895 toString.append(Introspector.instance().getProperty(this, NAME_PROPERTY));
896 }
897 catch (final Throwable ignore)
898 {
899
900 }
901 }
902 toString.append("]");
903 return toString.toString();
904 }
905 }