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