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