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