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