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