1
2
3
4
5 package org.andromda.cartridges.jsf2.metafacades;
6
7 import java.util.Collection;
8 import java.util.List;
9 import java.util.Map;
10 import org.andromda.core.common.Introspector;
11 import org.andromda.core.metafacade.MetafacadeBase;
12 import org.andromda.core.metafacade.MetafacadeFactory;
13 import org.andromda.core.metafacade.ModelValidationMessage;
14 import org.andromda.metafacades.uml.ActionFacade;
15 import org.andromda.metafacades.uml.ConstraintFacade;
16 import org.andromda.metafacades.uml.DependencyFacade;
17 import org.andromda.metafacades.uml.EventFacade;
18 import org.andromda.metafacades.uml.FrontEndAction;
19 import org.andromda.metafacades.uml.FrontEndActivityGraph;
20 import org.andromda.metafacades.uml.FrontEndControllerOperation;
21 import org.andromda.metafacades.uml.FrontEndEvent;
22 import org.andromda.metafacades.uml.FrontEndForward;
23 import org.andromda.metafacades.uml.FrontEndParameter;
24 import org.andromda.metafacades.uml.FrontEndUseCase;
25 import org.andromda.metafacades.uml.GuardFacade;
26 import org.andromda.metafacades.uml.ModelElementFacade;
27 import org.andromda.metafacades.uml.ModelFacade;
28 import org.andromda.metafacades.uml.PackageFacade;
29 import org.andromda.metafacades.uml.StateMachineFacade;
30 import org.andromda.metafacades.uml.StateVertexFacade;
31 import org.andromda.metafacades.uml.StereotypeFacade;
32 import org.andromda.metafacades.uml.TaggedValueFacade;
33 import org.andromda.metafacades.uml.TemplateParameterFacade;
34 import org.andromda.metafacades.uml.TypeMappings;
35 import org.andromda.translation.ocl.validation.OCLCollections;
36 import org.andromda.translation.ocl.validation.OCLIntrospector;
37 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
38 import org.apache.log4j.Logger;
39
40
41
42
43
44
45
46 public abstract class JSFForwardLogic
47 extends MetafacadeBase
48 implements JSFForward
49 {
50
51
52
53
54 protected Object metaObject;
55
56
57
58
59
60 protected JSFForwardLogic(Object metaObjectIn, String context)
61 {
62 super(metaObjectIn, getContext(context));
63 this.superFrontEndForward =
64 (FrontEndForward)
65 MetafacadeFactory.getInstance().createFacadeImpl(
66 "org.andromda.metafacades.uml.FrontEndForward",
67 metaObjectIn,
68 getContext(context));
69 this.metaObject = metaObjectIn;
70 }
71
72
73
74
75 private static final Logger logger = Logger.getLogger(JSFForwardLogic.class);
76
77
78
79
80
81
82 private static String getContext(String context)
83 {
84 if (context == null)
85 {
86 context = "org.andromda.cartridges.jsf2.metafacades.JSFForward";
87 }
88 return context;
89 }
90
91 private FrontEndForward superFrontEndForward;
92 private boolean superFrontEndForwardInitialized = false;
93
94
95
96
97
98 private FrontEndForward getSuperFrontEndForward()
99 {
100 if (!this.superFrontEndForwardInitialized)
101 {
102 ((MetafacadeBase)this.superFrontEndForward).setMetafacadeContext(this.getMetafacadeContext());
103 this.superFrontEndForwardInitialized = true;
104 }
105 return this.superFrontEndForward;
106 }
107
108
109
110
111
112 @Override
113 public void resetMetafacadeContext(String context)
114 {
115 if (!this.contextRoot)
116 {
117 context = getContext(context);
118 setMetafacadeContext (context);
119 if (this.superFrontEndForwardInitialized)
120 {
121 ((MetafacadeBase)this.superFrontEndForward).resetMetafacadeContext(context);
122 }
123 }
124 }
125
126
127
128
129
130 public boolean isJSFForwardMetaType()
131 {
132 return true;
133 }
134
135
136
137
138
139
140
141 protected abstract String handleGetPath();
142
143 private String __path1a;
144 private boolean __path1aSet = false;
145
146
147
148
149
150 public final String getPath()
151 {
152 String path1a = this.__path1a;
153 if (!this.__path1aSet)
154 {
155
156 path1a = handleGetPath();
157
158 this.__path1a = path1a;
159 if (isMetafacadePropertyCachingEnabled())
160 {
161 this.__path1aSet = true;
162 }
163 }
164 return path1a;
165 }
166
167
168
169
170
171 protected abstract boolean handleIsFinalStateTarget();
172
173 private boolean __finalStateTarget2a;
174 private boolean __finalStateTarget2aSet = false;
175
176
177
178
179
180 public final boolean isFinalStateTarget()
181 {
182 boolean finalStateTarget2a = this.__finalStateTarget2a;
183 if (!this.__finalStateTarget2aSet)
184 {
185
186 finalStateTarget2a = handleIsFinalStateTarget();
187
188 this.__finalStateTarget2a = finalStateTarget2a;
189 if (isMetafacadePropertyCachingEnabled())
190 {
191 this.__finalStateTarget2aSet = true;
192 }
193 }
194 return finalStateTarget2a;
195 }
196
197
198
199
200
201 protected abstract String handleGetFromOutcome();
202
203 private String __fromOutcome3a;
204 private boolean __fromOutcome3aSet = false;
205
206
207
208
209
210 public final String getFromOutcome()
211 {
212 String fromOutcome3a = this.__fromOutcome3a;
213 if (!this.__fromOutcome3aSet)
214 {
215
216 fromOutcome3a = handleGetFromOutcome();
217
218 this.__fromOutcome3a = fromOutcome3a;
219 if (isMetafacadePropertyCachingEnabled())
220 {
221 this.__fromOutcome3aSet = true;
222 }
223 }
224 return fromOutcome3a;
225 }
226
227
228
229
230
231 protected abstract Map handleGetSuccessMessages();
232
233 private Map __successMessages4a;
234 private boolean __successMessages4aSet = false;
235
236
237
238
239
240 public final Map getSuccessMessages()
241 {
242 Map successMessages4a = this.__successMessages4a;
243 if (!this.__successMessages4aSet)
244 {
245
246 successMessages4a = handleGetSuccessMessages();
247
248 this.__successMessages4a = successMessages4a;
249 if (isMetafacadePropertyCachingEnabled())
250 {
251 this.__successMessages4aSet = true;
252 }
253 }
254 return successMessages4a;
255 }
256
257
258
259
260
261 protected abstract boolean handleIsSuccessMessagesPresent();
262
263 private boolean __successMessagesPresent5a;
264 private boolean __successMessagesPresent5aSet = false;
265
266
267
268
269
270 public final boolean isSuccessMessagesPresent()
271 {
272 boolean successMessagesPresent5a = this.__successMessagesPresent5a;
273 if (!this.__successMessagesPresent5aSet)
274 {
275
276 successMessagesPresent5a = handleIsSuccessMessagesPresent();
277
278 this.__successMessagesPresent5a = successMessagesPresent5a;
279 if (isMetafacadePropertyCachingEnabled())
280 {
281 this.__successMessagesPresent5aSet = true;
282 }
283 }
284 return successMessagesPresent5a;
285 }
286
287
288
289
290
291 protected abstract Map handleGetWarningMessages();
292
293 private Map __warningMessages6a;
294 private boolean __warningMessages6aSet = false;
295
296
297
298
299
300 public final Map getWarningMessages()
301 {
302 Map warningMessages6a = this.__warningMessages6a;
303 if (!this.__warningMessages6aSet)
304 {
305
306 warningMessages6a = handleGetWarningMessages();
307
308 this.__warningMessages6a = warningMessages6a;
309 if (isMetafacadePropertyCachingEnabled())
310 {
311 this.__warningMessages6aSet = true;
312 }
313 }
314 return warningMessages6a;
315 }
316
317
318
319
320
321 protected abstract boolean handleIsWarningMessagesPresent();
322
323 private boolean __warningMessagesPresent7a;
324 private boolean __warningMessagesPresent7aSet = false;
325
326
327
328
329
330 public final boolean isWarningMessagesPresent()
331 {
332 boolean warningMessagesPresent7a = this.__warningMessagesPresent7a;
333 if (!this.__warningMessagesPresent7aSet)
334 {
335
336 warningMessagesPresent7a = handleIsWarningMessagesPresent();
337
338 this.__warningMessagesPresent7a = warningMessagesPresent7a;
339 if (isMetafacadePropertyCachingEnabled())
340 {
341 this.__warningMessagesPresent7aSet = true;
342 }
343 }
344 return warningMessagesPresent7a;
345 }
346
347
348
349
350
351
352
353 public boolean isFrontEndForwardMetaType()
354 {
355 return true;
356 }
357
358
359
360
361
362 public boolean isTransitionFacadeMetaType()
363 {
364 return true;
365 }
366
367
368
369
370
371 public boolean isModelElementFacadeMetaType()
372 {
373 return true;
374 }
375
376
377
378
379
380
381 public String getActionMethodName()
382 {
383 return this.getSuperFrontEndForward().getActionMethodName();
384 }
385
386
387
388
389
390 public List<FrontEndAction> getActions()
391 {
392 return this.getSuperFrontEndForward().getActions();
393 }
394
395
396
397
398
399 public FrontEndEvent getDecisionTrigger()
400 {
401 return this.getSuperFrontEndForward().getDecisionTrigger();
402 }
403
404
405
406
407
408 public List<FrontEndParameter> getForwardParameters()
409 {
410 return this.getSuperFrontEndForward().getForwardParameters();
411 }
412
413
414
415
416
417 public FrontEndActivityGraph getFrontEndActivityGraph()
418 {
419 return this.getSuperFrontEndForward().getFrontEndActivityGraph();
420 }
421
422
423
424
425
426 public FrontEndControllerOperation getOperationCall()
427 {
428 return this.getSuperFrontEndForward().getOperationCall();
429 }
430
431
432
433
434
435 public FrontEndUseCase getUseCase()
436 {
437 return this.getSuperFrontEndForward().getUseCase();
438 }
439
440
441
442
443
444 public boolean isContainedInFrontEndUseCase()
445 {
446 return this.getSuperFrontEndForward().isContainedInFrontEndUseCase();
447 }
448
449
450
451
452
453 public boolean isEnteringView()
454 {
455 return this.getSuperFrontEndForward().isEnteringView();
456 }
457
458
459
460
461
462 public boolean isExitingView()
463 {
464 return this.getSuperFrontEndForward().isExitingView();
465 }
466
467
468
469
470
471 public void copyTaggedValues(ModelElementFacade element)
472 {
473 this.getSuperFrontEndForward().copyTaggedValues(element);
474 }
475
476
477
478
479
480
481 public Object findTaggedValue(String tagName)
482 {
483 return this.getSuperFrontEndForward().findTaggedValue(tagName);
484 }
485
486
487
488
489
490
491 public Collection<Object> findTaggedValues(String tagName)
492 {
493 return this.getSuperFrontEndForward().findTaggedValues(tagName);
494 }
495
496
497
498
499
500
501
502 public String getBindedFullyQualifiedName(ModelElementFacade bindedElement)
503 {
504 return this.getSuperFrontEndForward().getBindedFullyQualifiedName(bindedElement);
505 }
506
507
508
509
510
511 public Collection<ConstraintFacade> getConstraints()
512 {
513 return this.getSuperFrontEndForward().getConstraints();
514 }
515
516
517
518
519
520
521 public Collection<ConstraintFacade> getConstraints(String kind)
522 {
523 return this.getSuperFrontEndForward().getConstraints(kind);
524 }
525
526
527
528
529
530
531
532 public String getDocumentation(String indent)
533 {
534 return this.getSuperFrontEndForward().getDocumentation(indent);
535 }
536
537
538
539
540
541
542
543
544 public String getDocumentation(String indent, int lineLength)
545 {
546 return this.getSuperFrontEndForward().getDocumentation(indent, lineLength);
547 }
548
549
550
551
552
553
554
555 public String getDocumentation(String indent, int lineLength, boolean htmlStyle)
556 {
557 return this.getSuperFrontEndForward().getDocumentation(indent, lineLength, htmlStyle);
558 }
559
560
561
562
563
564 public String getFullyQualifiedName()
565 {
566 return this.getSuperFrontEndForward().getFullyQualifiedName();
567 }
568
569
570
571
572
573
574
575
576 public String getFullyQualifiedName(boolean modelName)
577 {
578 return this.getSuperFrontEndForward().getFullyQualifiedName(modelName);
579 }
580
581
582
583
584
585
586 public String getFullyQualifiedNamePath()
587 {
588 return this.getSuperFrontEndForward().getFullyQualifiedNamePath();
589 }
590
591
592
593
594
595 public String getId()
596 {
597 return this.getSuperFrontEndForward().getId();
598 }
599
600
601
602
603
604
605
606
607
608 public Collection<String> getKeywords()
609 {
610 return this.getSuperFrontEndForward().getKeywords();
611 }
612
613
614
615
616
617 public String getLabel()
618 {
619 return this.getSuperFrontEndForward().getLabel();
620 }
621
622
623
624
625
626 public TypeMappings getLanguageMappings()
627 {
628 return this.getSuperFrontEndForward().getLanguageMappings();
629 }
630
631
632
633
634
635
636 public ModelFacade getModel()
637 {
638 return this.getSuperFrontEndForward().getModel();
639 }
640
641
642
643
644
645 public String getName()
646 {
647 return this.getSuperFrontEndForward().getName();
648 }
649
650
651
652
653
654 public ModelElementFacade getPackage()
655 {
656 return this.getSuperFrontEndForward().getPackage();
657 }
658
659
660
661
662
663 public String getPackageName()
664 {
665 return this.getSuperFrontEndForward().getPackageName();
666 }
667
668
669
670
671
672
673 public String getPackageName(boolean modelName)
674 {
675 return this.getSuperFrontEndForward().getPackageName(modelName);
676 }
677
678
679
680
681
682 public String getPackagePath()
683 {
684 return this.getSuperFrontEndForward().getPackagePath();
685 }
686
687
688
689
690
691
692
693
694 public String getQualifiedName()
695 {
696 return this.getSuperFrontEndForward().getQualifiedName();
697 }
698
699
700
701
702
703 public PackageFacade getRootPackage()
704 {
705 return this.getSuperFrontEndForward().getRootPackage();
706 }
707
708
709
710
711
712 public Collection<DependencyFacade> getSourceDependencies()
713 {
714 return this.getSuperFrontEndForward().getSourceDependencies();
715 }
716
717
718
719
720
721
722 public StateMachineFacade getStateMachineContext()
723 {
724 return this.getSuperFrontEndForward().getStateMachineContext();
725 }
726
727
728
729
730
731 public Collection<String> getStereotypeNames()
732 {
733 return this.getSuperFrontEndForward().getStereotypeNames();
734 }
735
736
737
738
739
740 public Collection<StereotypeFacade> getStereotypes()
741 {
742 return this.getSuperFrontEndForward().getStereotypes();
743 }
744
745
746
747
748
749 public Collection<TaggedValueFacade> getTaggedValues()
750 {
751 return this.getSuperFrontEndForward().getTaggedValues();
752 }
753
754
755
756
757
758 public Collection<DependencyFacade> getTargetDependencies()
759 {
760 return this.getSuperFrontEndForward().getTargetDependencies();
761 }
762
763
764
765
766
767 public Object getTemplateParameter(String parameterName)
768 {
769 return this.getSuperFrontEndForward().getTemplateParameter(parameterName);
770 }
771
772
773
774
775
776 public Collection<TemplateParameterFacade> getTemplateParameters()
777 {
778 return this.getSuperFrontEndForward().getTemplateParameters();
779 }
780
781
782
783
784
785
786 public String getVisibility()
787 {
788 return this.getSuperFrontEndForward().getVisibility();
789 }
790
791
792
793
794
795
796 public boolean hasExactStereotype(String stereotypeName)
797 {
798 return this.getSuperFrontEndForward().hasExactStereotype(stereotypeName);
799 }
800
801
802
803
804
805
806 public boolean hasKeyword(String keywordName)
807 {
808 return this.getSuperFrontEndForward().hasKeyword(keywordName);
809 }
810
811
812
813
814
815
816
817
818
819
820
821
822
823 public boolean hasStereotype(String stereotypeName)
824 {
825 return this.getSuperFrontEndForward().hasStereotype(stereotypeName);
826 }
827
828
829
830
831
832
833 public boolean isBindingDependenciesPresent()
834 {
835 return this.getSuperFrontEndForward().isBindingDependenciesPresent();
836 }
837
838
839
840
841
842 public boolean isConstraintsPresent()
843 {
844 return this.getSuperFrontEndForward().isConstraintsPresent();
845 }
846
847
848
849
850
851 public boolean isDocumentationPresent()
852 {
853 return this.getSuperFrontEndForward().isDocumentationPresent();
854 }
855
856
857
858
859
860 public boolean isReservedWord()
861 {
862 return this.getSuperFrontEndForward().isReservedWord();
863 }
864
865
866
867
868
869
870 public boolean isTemplateParametersPresent()
871 {
872 return this.getSuperFrontEndForward().isTemplateParametersPresent();
873 }
874
875
876
877
878
879
880
881 public boolean isValidIdentifierName()
882 {
883 return this.getSuperFrontEndForward().isValidIdentifierName();
884 }
885
886
887
888
889
890
891
892 public String translateConstraint(String name, String translation)
893 {
894 return this.getSuperFrontEndForward().translateConstraint(name, translation);
895 }
896
897
898
899
900
901 public String[] translateConstraints(String translation)
902 {
903 return this.getSuperFrontEndForward().translateConstraints(translation);
904 }
905
906
907
908
909
910 public String[] translateConstraints(String kind, String translation)
911 {
912 return this.getSuperFrontEndForward().translateConstraints(kind, translation);
913 }
914
915
916
917
918
919
920
921
922
923
924
925 public ActionFacade getEffect()
926 {
927 return this.getSuperFrontEndForward().getEffect();
928 }
929
930
931
932
933
934
935
936
937
938 public GuardFacade getGuard()
939 {
940 return this.getSuperFrontEndForward().getGuard();
941 }
942
943
944
945
946
947
948
949 public StateVertexFacade getSource()
950 {
951 return this.getSuperFrontEndForward().getSource();
952 }
953
954
955
956
957
958
959
960 public StateVertexFacade getTarget()
961 {
962 return this.getSuperFrontEndForward().getTarget();
963 }
964
965
966
967
968
969 public EventFacade getTrigger()
970 {
971 return this.getSuperFrontEndForward().getTrigger();
972 }
973
974
975
976
977
978
979 public boolean isEnteringActionState()
980 {
981 return this.getSuperFrontEndForward().isEnteringActionState();
982 }
983
984
985
986
987
988
989 public boolean isEnteringDecisionPoint()
990 {
991 return this.getSuperFrontEndForward().isEnteringDecisionPoint();
992 }
993
994
995
996
997
998
999 public boolean isEnteringFinalState()
1000 {
1001 return this.getSuperFrontEndForward().isEnteringFinalState();
1002 }
1003
1004
1005
1006
1007
1008
1009 public boolean isExitingActionState()
1010 {
1011 return this.getSuperFrontEndForward().isExitingActionState();
1012 }
1013
1014
1015
1016
1017
1018
1019 public boolean isExitingDecisionPoint()
1020 {
1021 return this.getSuperFrontEndForward().isExitingDecisionPoint();
1022 }
1023
1024
1025
1026
1027
1028
1029 public boolean isExitingInitialState()
1030 {
1031 return this.getSuperFrontEndForward().isExitingInitialState();
1032 }
1033
1034
1035
1036
1037
1038 public boolean isTriggerPresent()
1039 {
1040 return this.getSuperFrontEndForward().isTriggerPresent();
1041 }
1042
1043
1044
1045
1046 @Override
1047 public void initialize()
1048 {
1049 this.getSuperFrontEndForward().initialize();
1050 }
1051
1052
1053
1054
1055
1056 @Override
1057 public Object getValidationOwner()
1058 {
1059 Object owner = this.getSuperFrontEndForward().getValidationOwner();
1060 return owner;
1061 }
1062
1063
1064
1065
1066
1067 @Override
1068 public String getValidationName()
1069 {
1070 String name = this.getSuperFrontEndForward().getValidationName();
1071 return name;
1072 }
1073
1074
1075
1076
1077
1078
1079
1080
1081 @Override
1082 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
1083 {
1084 this.getSuperFrontEndForward().validateInvariants(validationMessages);
1085 try
1086 {
1087 final Object contextElement = this.THIS();
1088 boolean constraintValid = OCLResultEnsurer.ensure((Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"enteringDecisionPoint"))).booleanValue()?(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"decisionTrigger"))&&OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"operationCall"))&&Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"operationCall.returnTypePresent"))).booleanValue()):true));
1089 if (!constraintValid)
1090 {
1091 validationMessages.add(
1092 new ModelValidationMessage(
1093 (MetafacadeBase)contextElement ,
1094 "org::andromda::cartridges::jsf2::metafacades::JSFForward::decision forwards need a controller operation with a non-void return type",
1095 "If a transition is going into a decision point you will need to defer to an operation with a non-void return type. You will need to model this on the transition's trigger."));
1096 }
1097 }
1098 catch (Throwable th)
1099 {
1100 Throwable cause = th.getCause();
1101 int depth = 0;
1102 while (cause != null && depth < 7)
1103 {
1104 th = cause;
1105 depth++;
1106 }
1107 logger.error("Error validating constraint 'org::andromda::cartridges::jsf2::metafacades::JSFForward::decision forwards need a controller operation with a non-void return type' ON "
1108 + this.THIS().toString() + ": " + th.getMessage(), th);
1109 }
1110 }
1111
1112
1113
1114
1115 private static final String NAME_PROPERTY = "name";
1116 private static final String FQNAME_PROPERTY = "fullyQualifiedName";
1117
1118
1119
1120
1121 @Override
1122 public String toString()
1123 {
1124 final StringBuilder toString = new StringBuilder(this.getClass().getName());
1125 toString.append("[");
1126 try
1127 {
1128 toString.append(Introspector.instance().getProperty(this, FQNAME_PROPERTY));
1129 }
1130 catch (final Throwable tryAgain)
1131 {
1132 try
1133 {
1134 toString.append(Introspector.instance().getProperty(this, NAME_PROPERTY));
1135 }
1136 catch (final Throwable ignore)
1137 {
1138
1139 }
1140 }
1141 toString.append("]");
1142 return toString.toString();
1143 }
1144 }