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