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