genio 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,415 @@
1
+ #
2
+ # Copyright 2013 PayPal Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ #
17
+
18
+ module Genio
19
+ module Helper
20
+ module Java
21
+
22
+ include Base
23
+
24
+ # Key/Reserved Words
25
+ KeyWords = [
26
+ "abstract",
27
+ "continue",
28
+ "for",
29
+ "new",
30
+ "switch",
31
+ "assert",
32
+ "default",
33
+ "goto",
34
+ "package",
35
+ "synchronized",
36
+ "boolean",
37
+ "do",
38
+ "if",
39
+ "private",
40
+ "this",
41
+ "break",
42
+ "double",
43
+ "implements",
44
+ "protected",
45
+ "throw",
46
+ "byte",
47
+ "else",
48
+ "import",
49
+ "public",
50
+ "throws",
51
+ "case",
52
+ "enum",
53
+ "instanceof",
54
+ "return",
55
+ "transient",
56
+ "catch",
57
+ "extends",
58
+ "int",
59
+ "short",
60
+ "try",
61
+ "char",
62
+ "final",
63
+ "interface",
64
+ "static",
65
+ "void",
66
+ "class",
67
+ "finally",
68
+ "long",
69
+ "strictfp**",
70
+ "volatile",
71
+ "const",
72
+ "float",
73
+ "native",
74
+ "super",
75
+ "while"
76
+ ]
77
+
78
+ # Keyword substitute hash
79
+ KeywordsSubstitute = {
80
+
81
+ }
82
+
83
+ # Static resource imports
84
+ # Resource class which have REST operation enabled
85
+ # depend on these core classes
86
+ ServiceImportREST = [
87
+ "com.paypal.core.rest.PayPalRESTException",
88
+ "com.paypal.core.rest.PayPalResource",
89
+ "com.paypal.core.rest.HttpMethod",
90
+ "com.paypal.core.rest.PayPalRESTException",
91
+ "com.paypal.core.rest.RESTUtil",
92
+ "com.paypal.core.rest.JSONFormatter",
93
+ "com.paypal.core.rest.APIContext",
94
+ "com.paypal.core.Constants",
95
+ "com.paypal.core.SDKVersion",
96
+ "com.paypal.sdk.info.SDKVersionImpl",
97
+ "java.io.File",
98
+ "java.io.InputStream",
99
+ "java.util.Properties",
100
+ "java.util.Map",
101
+ "java.util.HashMap"
102
+ ]
103
+
104
+ # Static resource imports for WSDL
105
+ # service class; they depend on these core classes
106
+ ServiceImportWSDL = [
107
+ "java.io.*",
108
+ "java.util.Map",
109
+ "java.util.HashMap",
110
+ "java.util.Properties",
111
+ "com.paypal.core.BaseService",
112
+ "com.paypal.exception.*",
113
+ "com.paypal.sdk.exceptions.*",
114
+ "com.paypal.core.APICallPreHandler",
115
+ "com.paypal.core.DefaultSOAPAPICallHandler",
116
+ "com.paypal.core.DefaultSOAPAPICallHandler.XmlNamespaceProvider",
117
+ "org.w3c.dom.Node",
118
+ "org.xml.sax.SAXException",
119
+ "org.xml.sax.InputSource",
120
+ "javax.xml.parsers.ParserConfigurationException",
121
+ "javax.xml.parsers.DocumentBuilderFactory",
122
+ "javax.xml.xpath.XPathConstants",
123
+ "javax.xml.xpath.XPathExpressionException",
124
+ "javax.xml.xpath.XPathFactory",
125
+ "com.paypal.core.DefaultSOAPAPICallHandler",
126
+ "com.paypal.core.BaseAPIContext"
127
+ ]
128
+
129
+ # Static resource imports for WSDL
130
+ # stub classes; they depend on these core classes
131
+ StubImportWSDL = [
132
+ "javax.xml.xpath.XPath",
133
+ "javax.xml.xpath.XPathConstants",
134
+ "javax.xml.xpath.XPathExpressionException",
135
+ "javax.xml.xpath.XPathFactory",
136
+ "org.w3c.dom.Node",
137
+ "org.w3c.dom.NodeList",
138
+ "com.paypal.core.SDKUtil"
139
+ ]
140
+
141
+ # Spec Types to Java Types conversion map
142
+ BasicTypes = { "int" => "Integer", "integer" => "Integer", "positiveInteger" => "Integer", "nonNegativeInteger" => "Integer", "long" => "Long", "double" => "Double", "decimal" => "Double", "float" => "Float", "boolean" => "Boolean", "string" => "String", "dateTime" => "String", "date" => "String", "number" => "Number", "object" => "Object", "token" => "String", "duration" => "String", "anyURI" => "String", "date_time" => "String", "base64Binary" => "String", "time" => "String" }
143
+
144
+ # Returns the type of a member
145
+ # If the passed in parameter is one of Basic types
146
+ # return the corresponding BasicType, else
147
+ # the parameter is returned unmodified
148
+ def find_basic_type(key)
149
+ only_basic_type(key) || key
150
+ end
151
+
152
+ # Returns the corresponding basic
153
+ # data type in Java
154
+ def only_basic_type(key)
155
+ BasicTypes[key.camelcase(:lower)]
156
+ end
157
+
158
+ # Returns the imports for the Class
159
+ def imports(data_type, schema, package, classname, schema_format, operation_input = false)
160
+ list = []
161
+
162
+ # custom package provided during generation
163
+ pkg = options[:namespace]
164
+ pkg += "." if pkg.present?
165
+
166
+ # mandatory imports
167
+ list += ["com.paypal.core.rest.JSONFormatter"] if (schema_format == "rest")
168
+ data_type.properties.each do |name, property|
169
+ type = schema.data_types[property.type] || schema.enum_types[property.type]
170
+ if (type)
171
+ if (pkg.present?)
172
+ list.push(pkg + property.type)
173
+ else
174
+ # TODO fix this when definition namespace fixes
175
+ defpkg = convert_ns_to_package(type.package || package)
176
+ list.push(defpkg + "." + property.type)
177
+ end
178
+ end
179
+ list.push("java.util.List") if property.array
180
+ list.push("java.util.ArrayList") if property.array
181
+ end
182
+
183
+ # Add references for members of parent datatype
184
+ # flatten classes for wsdl
185
+ if schema.instance_of? Genio::Parser::Format::Wsdl
186
+ x_type = schema.data_types[data_type.extends]
187
+ while x_type
188
+ x_type.properties.each do |name, property|
189
+ type = schema.data_types[property.type] || schema.enum_types[property.type]
190
+ if (type)
191
+ if (pkg.present?)
192
+ list.push(pkg + property.type)
193
+ else
194
+ # TODO fix this when definition namespace fixes
195
+ defpkg = convert_ns_to_package(type.package || package)
196
+ list.push(defpkg + "." + property.type)
197
+ end
198
+ end
199
+ list.push("java.util.List") if property.array
200
+ list.push("java.util.ArrayList") if property.array
201
+ end
202
+ x_type = schema.data_types[x_type.extends]
203
+ end
204
+ end
205
+
206
+ # Add reference for request and response type
207
+ # of operations: Applies to REST services
208
+ service = schema.services[classname]
209
+ if service
210
+ service.operations.each do |name, operation|
211
+ if operation.response
212
+ if (pkg.present?)
213
+ list.push(pkg + validate_class_name(operation.response))
214
+ else
215
+ list.push(convert_ns_to_package(schema.data_types[operation.response].try(:package) || package) + "." + validate_class_name(operation.response))
216
+ end
217
+ end
218
+ if operation.request
219
+ if (pkg.present?)
220
+ list.push(pkg + validate_class_name(operation.request))
221
+ else
222
+ list.push(convert_ns_to_package(schema.data_types[operation.request].try(:package) || package) + "." + validate_class_name(operation.request))
223
+ end
224
+ end
225
+ end
226
+ end
227
+
228
+ list += ServiceImportREST if (schema.services[classname] && (schema_format == "rest"))
229
+ list += StubImportWSDL if (schema_format == "soap")
230
+ list += ["com.paypal.core.message.XMLMessageSerializer"] if (operation_input && (schema_format == "soap"))
231
+ list.uniq.sort
232
+ end
233
+
234
+ # Generate imports for WSDL Service class
235
+ def service_imports(schema, service, package)
236
+ list = []
237
+
238
+ # custom package provided during generation
239
+ pkg = options[:namespace]
240
+ pkg += "." if pkg.present?
241
+
242
+ # import request and response of operations
243
+ service.operations.each do |name, definition|
244
+ if (definition.request_property)
245
+ if (pkg.present?)
246
+ list.push(pkg + validate_class_name(definition.request_property.type))
247
+ else
248
+ list.push(convert_ns_to_package(schema.data_types[validate_class_name(definition.request_property.type)].package || package) + "." + validate_class_name(definition.request_property.type))
249
+ end
250
+ end
251
+ if (definition.response_property)
252
+ if (pkg.present?)
253
+ list.push(pkg + validate_class_name(definition.response_property.type))
254
+ else
255
+ list.push(convert_ns_to_package(schema.data_types[validate_class_name(definition.response_property.type)].package || package) + "." + validate_class_name(definition.response_property.type))
256
+ end
257
+ end
258
+ if (definition.fault_property)
259
+ if (pkg.present?)
260
+ list.push(pkg + validate_class_name(definition.fault_property.type))
261
+ else
262
+ list.push(convert_ns_to_package(schema.data_types[validate_class_name(definition.fault_property.type)].package || package) + "." + validate_class_name(definition.fault_property.type))
263
+ end
264
+ end
265
+ end
266
+
267
+ # mandatory imports
268
+ list += ServiceImportWSDL
269
+ list.uniq.sort
270
+ end
271
+
272
+ # Returns the property type name to be used as the
273
+ # type name in enclosing Class
274
+ def get_property_class(property, classname = nil)
275
+ type = find_basic_type(property.type)
276
+
277
+ # If type is Self (as per Spec) treat is as HostType
278
+ # classname is always in camelcase
279
+ type = classname if type == "self"
280
+ type = "List<#{type}>" if property.array
281
+ type
282
+ end
283
+
284
+ # Replaces any "-" present in the path URI to valid "_"
285
+ # used while replacing placeholders with exact values
286
+ def validate_path(path)
287
+ path.gsub(/\{([^}]*)\}/){|match| "\{#{validate_property_name($1)}\}" }
288
+ end
289
+
290
+ # Replaces '-' with '_' and CamelCase(s) them [Java]
291
+ def validate_class_name(name)
292
+ only_basic_type(name) || name.gsub(/-/, "_").camelcase
293
+ end
294
+
295
+ # Replaces '-' with '_' and camelCase(s) them
296
+ # used for valid property names [Java]
297
+ # replaces keywords with substitutes form KeywordsSubstitute
298
+ def validate_property_name(name)
299
+ valid_name = name.gsub(/-/, "_").camelcase(:lower)
300
+ if KeyWords.include? valid_name
301
+ valid_name = KeywordsSubstitute[valid_name]
302
+ end
303
+ valid_name
304
+ end
305
+
306
+ # Replaces '-' and spaces with '_'
307
+ # used for valid enum names [Java]
308
+ def validate_enum_name(name)
309
+ name.gsub(/[-\s]/, "_").sub(/^\d/, '_\0')
310
+ end
311
+
312
+ # Prepends do to method names that are keywords
313
+ def validate_method_name(name)
314
+ KeyWords.include?(name) ? "do#{name.gsub(/-/, "_").camelcase}" : validate_property_name(name)
315
+ end
316
+
317
+ # Generate method formal parameters for REST API calls
318
+ def form_rest_api_args(classname, property, name)
319
+ arguments = {}
320
+ property.path.scan(/{([^}]*)}/).each do |name, etc|
321
+ if is_static_method(property) or validate_class_name(name) !~ /^#{classname}/i
322
+ arguments[validate_property_name(name)] = "String"
323
+ end
324
+ end
325
+ if property.request and property.request != classname
326
+ arguments[validate_property_name(property.request)] = property.request
327
+ end
328
+ if property.type == 'GET' or property.type == 'HEAD' or property.type == 'DELETE'
329
+ arguments["queryParameters"] = "Map<String, String>"
330
+ end
331
+ arguments
332
+ end
333
+
334
+ # Generate method formal parameters for CXF interface
335
+ # The argument type is appended with annotations
336
+ def form_cxf_args(classname, property, name)
337
+ arguments = {}
338
+ arguments["context"] = "@Context final MessageContext"
339
+ property.parameters.each do |name, parameter|
340
+ arguments[validate_property_name(name)] = "@#{parameter.location.capitalize}Param(\"#{name}\") String"
341
+ end if property.parameters
342
+ if property.request
343
+ arguments[property.request.camelcase(:lower)] = property.request
344
+ end
345
+ arguments
346
+ end
347
+
348
+ # Generates a map of parameters for placeholders used
349
+ # to process path URI
350
+ def generate_format_hash(classname, property, resourcePath)
351
+ map = {}
352
+ resourcePath.scan(/\{([^}]*)\}/) { |name, etc|
353
+ if (name.match(/^#{classname}.*/i) and !is_static_method(property))
354
+ map[name] = 'this.getId()'
355
+ else
356
+ map[name] = validate_property_name(name)
357
+ end
358
+ }
359
+ map
360
+ end
361
+
362
+ # Returns the expression to set for payLoad in the API call
363
+ def get_payload(classname, property)
364
+ payLoad = '""';
365
+ if !is_static_method(property)
366
+ if property.request == classname
367
+ payLoad = "this.toJSON()"
368
+ elsif property.request
369
+ payLoad = validate_property_name(property.request) + ".toJSON()"
370
+ end
371
+ end
372
+ payLoad
373
+ end
374
+
375
+ # Returns true if data_type is in services operations
376
+ # request or header, else returns false
377
+ def is_operation_input(data_type, schema)
378
+ schema.services.each do |service_name, servicedef|
379
+ servicedef.operations.each do |operation_name, oper_definition|
380
+ if (data_type.name == oper_definition.request || data_type.name == oper_definition.header)
381
+ return true
382
+ end
383
+ end
384
+ end
385
+ return false
386
+ end
387
+
388
+ # Returns the name used during serialization for types
389
+ # that extend Serializer interface
390
+ def get_rootname_serialization(data_type, schema)
391
+ schema.services.each do |service_name, servicedef|
392
+ servicedef.operations.each do |operation_name, oper_definition|
393
+ if (data_type.name == oper_definition.request)
394
+ return (oper_definition.request_property.package + ":" + oper_definition.request_property.name)
395
+ elsif (data_type.name == oper_definition.header)
396
+ return (oper_definition.header_property.package + ":" + oper_definition.header_property.name)
397
+ end
398
+ end
399
+ end
400
+ end
401
+
402
+ # Returns a hash of arguments for wsdl operations
403
+ # including the request type and name
404
+ # hash is in the format of [name] = [type]
405
+ def get_wsdl_operation_arguments(operation_definition)
406
+ argument_hash = {}
407
+ argument_hash[validate_property_name(operation_definition.request_property.name)] = operation_definition.request
408
+ argument_hash
409
+ end
410
+
411
+ private
412
+ include Genio::Util::NamespaceHelper
413
+ end
414
+ end
415
+ end
@@ -0,0 +1,342 @@
1
+ #
2
+ # Copyright 2013 PayPal Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ #
17
+ module Genio
18
+ module Helper
19
+ module PHP
20
+
21
+ include Base
22
+ # Key/Reserved Words
23
+ KeyWords = [
24
+ '__halt_compiler',
25
+ 'abstract',
26
+ 'and',
27
+ 'array',
28
+ 'as',
29
+ 'break',
30
+ 'callable',
31
+ 'case',
32
+ 'catch',
33
+ 'class',
34
+ 'clone',
35
+ 'const',
36
+ 'continue',
37
+ 'declare',
38
+ 'default',
39
+ 'die',
40
+ 'do',
41
+ 'echo',
42
+ 'else',
43
+ 'elseif',
44
+ 'empty',
45
+ 'enddeclare',
46
+ 'endfor',
47
+ 'endforeach',
48
+ 'endif',
49
+ 'endswitch',
50
+ 'endwhile',
51
+ 'eval',
52
+ 'exit',
53
+ 'extends',
54
+ 'final',
55
+ 'for',
56
+ 'foreach',
57
+ 'function',
58
+ 'global',
59
+ 'goto',
60
+ 'if',
61
+ 'implements',
62
+ 'include',
63
+ 'include_once',
64
+ 'instanceof',
65
+ 'insteadof',
66
+ 'interface',
67
+ 'isset',
68
+ 'list',
69
+ 'namespace',
70
+ 'new',
71
+ 'or',
72
+ 'print',
73
+ 'private',
74
+ 'protected',
75
+ 'public',
76
+ 'require',
77
+ 'require_once',
78
+ 'return',
79
+ 'static',
80
+ 'switch',
81
+ 'throw',
82
+ 'trait',
83
+ 'try',
84
+ 'unset',
85
+ 'use',
86
+ 'var',
87
+ 'while',
88
+ 'xor'
89
+ ]
90
+
91
+ # Class static imports/references for rest services
92
+ RestServiceImport = [
93
+ "PayPal\\Rest\\IResource",
94
+ "PayPal\\Transport\\PPRestCall"
95
+ ]
96
+
97
+ # Class static imports/references for rest services
98
+ WSDLServiceImport = [
99
+ "PayPal\\Exception\\PPTransformerException",
100
+ "PayPal\\Core\\PPBaseService",
101
+ "PayPal\\Core\\PPUtils"
102
+ ]
103
+
104
+ # Class static imports/references for WSDL
105
+ WSDLStubImport = [
106
+ ]
107
+ # Spec Types to PHP Types conversion map
108
+ BasicTypes = { "int" => "integer", "integer" => "integer", "positiveInteger" => "integer", "nonNegativeInteger" => "integer", "long" => "long", "double" => "double", "decimal" => "double", "float" => "float", "boolean" => "boolean", "string" => "string", "dateTime" => "string", "date" => "string", "date_time" => "string", "number" => "number", "object" => "object", "token" => "string", "duration" => "string", "anyURI" => "string", "base64Binary" => "string", "time" => "string" }
109
+
110
+ # Returns the type of a member
111
+ def find_basic_type(key)
112
+ BasicTypes[key] ? BasicTypes[key] : valid_class_name(key)
113
+ end
114
+
115
+ def get_php_type(property, schema, classname = nil)
116
+ type = find_basic_type(property.type)
117
+
118
+ # for enums, return type as string
119
+ type = "string" if schema.enum_types[property.type]
120
+
121
+ # If type is Self (as per Spec) treat is as HostType
122
+ # classname is always in camelcase
123
+ type = classname if type.downcase == "self"
124
+ type
125
+ end
126
+
127
+ def imports(data_type, schema, package, classname, schema_format)
128
+
129
+ # mandatory references
130
+ list = []
131
+ if (data_type.extends)
132
+ defpkg = get_namespace(schema.data_types[valid_class_name(data_type.extends)].package || package)
133
+ list.push(defpkg + '\\' + valid_class_name(data_type.extends))
134
+ end
135
+
136
+ service = schema.services[classname]
137
+
138
+ # Add use statements for function return types
139
+ if service
140
+ service.operations.each do |name, operation|
141
+ type = schema.data_types[operation.response]
142
+ if(type)
143
+ defpkg = get_namespace(schema.data_types[valid_class_name(operation.response)].package || package)
144
+ list.push(defpkg + '\\' + valid_class_name(operation.response)) if (operation.response && operation.response != classname)
145
+ end
146
+ end
147
+ end
148
+
149
+ if (schema_format == "rest")
150
+ list.push( "PayPal\\Common\\PPModel") if !data_type.extends
151
+ list += RestServiceImport if service
152
+ elsif (schema_format == "soap")
153
+ list += WSDLStubImport
154
+ if data_type.fault
155
+ list.push('PayPal\\Core\\PPXmlFaultMessage')
156
+ else
157
+ list.push('PayPal\\Core\\PPXmlMessage')
158
+ end
159
+ end
160
+ list.uniq.sort
161
+ end
162
+
163
+ # Generate imports for WSDL Service class
164
+ def service_imports(schema, service, package)
165
+ list = []
166
+
167
+ # custom package provided during generation
168
+ pkg = options[:namespace]
169
+ pkg += "." if pkg.present?
170
+
171
+ # import request and response of operations
172
+ service.operations.each do |name, definition|
173
+ if (definition.request_property)
174
+ if (pkg.present?)
175
+ list.push(pkg + valid_class_name(definition.request_property.type))
176
+ else
177
+ list.push(get_slashed_package_name(get_namespace(schema.data_types[valid_class_name(definition.request_property.type)].package || package) + "." + valid_class_name(definition.request_property.type)))
178
+ end
179
+ end
180
+ if (definition.response)
181
+ if (pkg.present?)
182
+ list.push(pkg + valid_class_name(definition.response))
183
+ else
184
+ list.push(get_slashed_package_name(get_namespace(schema.data_types[valid_class_name(definition.response)].package || package) + "." + valid_class_name(definition.response)))
185
+ end
186
+ end
187
+ if (definition.fault)
188
+ if (pkg.present?)
189
+ list.push(pkg + valid_class_name(definition.response))
190
+ else
191
+ list.push(get_slashed_package_name(get_namespace(schema.data_types[valid_class_name(definition.fault)].package || package) + "." + valid_class_name(definition.fault)))
192
+ end
193
+ end
194
+ end
195
+ # mandatory imports
196
+ list += WSDLServiceImport
197
+ list.uniq.sort
198
+ end
199
+
200
+ def process_path_with_placeholders(classname, name, path, hostId_check = false, argument_hash = nil, query_params)
201
+ path = '/' + path if !path.start_with?('/')
202
+ returnPath = ""
203
+ if hostId_check
204
+ returnPath = path.sub(/\{[^}]*\}/, "{$this->getId()}")
205
+ returnPath = '"' + returnPath
206
+ else
207
+ values = argument_hash.keys
208
+ returnPath = path.gsub(/\{[^}]*\}/) do |match|
209
+ "$#{values.shift}"
210
+ end
211
+ returnPath = '"' + returnPath
212
+ end
213
+ if query_params
214
+ returnPath = returnPath +'?" . http_build_query($queryParameters)'
215
+ else
216
+ returnPath = returnPath + '"'
217
+ end
218
+ returnPath
219
+ end
220
+
221
+ def valid_class_name(name)
222
+ name.gsub(/-/, "_").camelcase
223
+ end
224
+
225
+ def valid_property_name(name)
226
+ name.gsub(/-/, "_").camelize(:lower)
227
+ end
228
+
229
+ def deprecated_function_name(name)
230
+ name.gsub(/-/, "_").capitalize
231
+ end
232
+
233
+ def validate_function_name(name)
234
+ returnName = name
235
+ if name == 'list'
236
+ returnName = 'all'
237
+ end
238
+ returnName
239
+ end
240
+
241
+ # Prepends do to method names that are keywords
242
+ def validate_method_name(name)
243
+ KeyWords.include?(name) ? "do#{valid_class_name(name)}" : valid_property_name(name)
244
+ end
245
+
246
+ def validated_package(package)
247
+ get_slashed_package_name(capitalize_package(remove_tld_in_package(convert_ns_to_package(package))))
248
+ end
249
+
250
+ # to underscore
251
+ def to_underscore(name)
252
+ name.gsub(/-/, "_")
253
+ end
254
+
255
+ def form_arguments(classname, property, name)
256
+ arguments = {}
257
+ property.path.scan(/{([^}]*)}/).each do |name, etc|
258
+ if is_static_method(property) or name !~ /^#{classname}/i
259
+ arguments[valid_property_name(name)] = "string"
260
+ end
261
+ end
262
+ if property.request and property.request != classname
263
+ arguments[valid_property_name(property.request)] = property.request
264
+ end
265
+ if property.type == 'GET' or property.type == 'HEAD' or property.type == 'DELETE'
266
+ arguments["queryParameters"] = "array"
267
+ elsif (property.parameters && allowed_params(property.parameters).size > 0)
268
+ arguments["queryParameters"] = "array"
269
+ end
270
+ arguments
271
+ end
272
+
273
+ def get_object_array(classname, name, property, argument_hash)
274
+ arr = []
275
+ if property.path
276
+ arr.push("queryParameters")
277
+ else
278
+ argument_hash.each do |name, type|
279
+ if name.include?("Id") and property.path =~ /\{([^}]*id)\}/
280
+ arr.push(name)
281
+ end
282
+ end
283
+ if !is_static_method(property) and name != "create"
284
+ arr.push("this.id")
285
+ end
286
+ end
287
+ arr
288
+ end
289
+
290
+ def get_payload(classname, property)
291
+ payload = '""';
292
+ if !is_static_method(property)
293
+ if property.request == classname
294
+ payload = "$this->toJSON()"
295
+ elsif property.request
296
+ payload = "$" + valid_property_name(property.request) + "->toJSON()"
297
+ end
298
+ end
299
+ payload
300
+ end
301
+
302
+ def get_namespace(package)
303
+ pkg = options[:namespace]
304
+ return capitalize_package(remove_tld_in_package(convert_ns_to_package(pkg))) if pkg.present?
305
+ return validated_package(package)
306
+ end
307
+
308
+ # Returns a hash of arguments for wsdl operations
309
+ # including the request and header arguments
310
+ # hash is in the format of [name] = [type]
311
+ def get_wsdl_operation_arguments(operation_definition)
312
+ argument_array = []
313
+ argument_array.push('$' + operation_definition.request.camelcase(:lower))
314
+ #argument_array.push('$' + operation_definition.header.camelcase(:lower))
315
+ argument_array
316
+ end
317
+
318
+ def get_rootname_serialization(data_type, schema)
319
+ schema.services.each do |service_name, servicedef|
320
+ servicedef.operations.each do |operation_name, oper_definition|
321
+ if (data_type.name == oper_definition.request)
322
+ temp = oper_definition.request_property.package + ":" + oper_definition.request_property.name
323
+ return temp
324
+ elsif (data_type.name == oper_definition.header)
325
+ temp = oper_definition.header_property.package + ":" + oper_definition.header_property.name
326
+ return temp
327
+ end
328
+ end
329
+ end
330
+ end
331
+
332
+ # Returns set of alllowed query parameters
333
+ # for a operation
334
+ def allowed_params(parameters)
335
+ parameters.select do |name, values|
336
+ values.location != "path"
337
+ end
338
+ end
339
+
340
+ end
341
+ end
342
+ end