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