1 package org.andromda.cartridges.webservice.metafacades;
2
3 import org.andromda.cartridges.webservice.WebServiceGlobals;
4 import org.andromda.cartridges.webservice.WebServiceUtils;
5 import org.andromda.metafacades.uml.TypeMappings;
6 import org.apache.commons.lang.StringUtils;
7
8
9
10
11
12
13 public class WSDLEnumerationTypeLogicImpl
14 extends WSDLEnumerationTypeLogic
15 {
16
17
18 public WSDLEnumerationTypeLogicImpl(Object metaObject, String context)
19 {
20 super(metaObject, context);
21 }
22
23
24
25
26 protected java.lang.String handleGetSchemaType()
27 {
28 return this.getSchemaType(true, true);
29 }
30
31
32
33
34 protected String handleGetQName()
35 {
36 return this.getQualfiedNameLocalPartPattern().replaceAll("\\{0\\}", StringUtils.trimToEmpty(this.getName()));
37 }
38
39
40
41
42 protected String handleGetNamespacePrefix()
43 {
44 return (String)this.getConfiguredProperty(WebServiceLogicImpl.NAMESPACE_PREFIX);
45 }
46
47
48
49
50 protected String getQualfiedNameLocalPartPattern()
51 {
52 return (String)this.getConfiguredProperty(WebServiceLogicImpl.QNAME_LOCAL_PART_PATTERN);
53 }
54
55
56
57
58 protected String handleGetNamespace()
59 {
60 String packageName = this.getPackageName();
61 if (this.isReverseNamespace())
62 {
63 packageName = WebServiceUtils.reversePackage(packageName);
64 }
65 return this.getNamespacePattern().replaceAll("\\{0\\}", StringUtils.trimToEmpty(packageName));
66 }
67
68
69
70
71 protected String getNamespacePattern()
72 {
73 return (String)this.getConfiguredProperty(WebServiceLogicImpl.NAMESPACE_PATTERN);
74 }
75
76
77
78
79
80
81 private boolean isReverseNamespace()
82 {
83 return Boolean.valueOf(String.valueOf(this.getConfiguredProperty(WebServiceLogicImpl.REVERSE_NAMESPACE)))
84 .booleanValue();
85 }
86
87
88
89
90 public java.lang.String handleGetSchemaType(boolean withPrefix, boolean preserveArray)
91 {
92 return WebServiceUtils.getSchemaType(this, this.getSchemaTypeMappings(), this.getNamespacePrefix(),
93 this.getQName(), this.getWsdlArrayNamePrefix(), withPrefix, preserveArray);
94 }
95
96
97
98
99 protected String handleGetWsdlArrayNamePrefix()
100 {
101 return String.valueOf(this.getConfiguredProperty(WebServiceGlobals.ARRAY_NAME_PREFIX));
102 }
103
104
105
106
107 protected String handleGetWsdlArrayName()
108 {
109 StringBuffer name = new StringBuffer(StringUtils.trimToEmpty(this.getQName()).replaceAll("\\[\\]", ""));
110 name.insert(0, this.getWsdlArrayNamePrefix());
111 return name.toString();
112 }
113
114
115
116
117
118
119 private TypeMappings getSchemaTypeMappings()
120 {
121 final String propertyName = WebServiceGlobals.SCHEMA_TYPE_MAPPINGS_URI;
122 Object property = this.getConfiguredProperty(propertyName);
123 TypeMappings mappings = null;
124 String uri = null;
125 if (String.class.isAssignableFrom(property.getClass()))
126 {
127 uri = (String)property;
128 try
129 {
130 mappings = TypeMappings.getInstance((String)property);
131 this.setProperty(propertyName, mappings);
132 }
133 catch (Throwable th)
134 {
135 String errMsg = "Error getting '" + propertyName + "' --> '" + uri + "'";
136 logger.error(errMsg, th);
137
138 }
139 }
140 else
141 {
142 mappings = (TypeMappings)property;
143 }
144 return mappings;
145 }
146 }