source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/wsdl/soap/mappingRegistryCreator.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 2.0 KB
Line 
1# WSDL4R - Creating MappingRegistry code from WSDL.
2# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <[email protected]>.
3
4# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
5# redistribute it and/or modify it under the same terms of Ruby's license;
6# either the dual license version in 2003, or any later version.
7
8
9require 'wsdl/info'
10require 'wsdl/soap/classDefCreatorSupport'
11
12
13module WSDL
14module SOAP
15
16
17class MappingRegistryCreator
18 include ClassDefCreatorSupport
19
20 attr_reader :definitions
21
22 def initialize(definitions)
23 @definitions = definitions
24 @complextypes = @definitions.collect_complextypes
25 @types = nil
26 end
27
28 def dump(types)
29 @types = types
30 map_cache = []
31 map = ""
32 @types.each do |type|
33 if map_cache.index(type).nil?
34 map_cache << type
35 if type.namespace != XSD::Namespace
36 if typemap = dump_typemap(type)
37 map << typemap
38 end
39 end
40 end
41 end
42 return map
43 end
44
45private
46
47 def dump_typemap(type)
48 if definedtype = @complextypes[type]
49 case definedtype.compoundtype
50 when :TYPE_STRUCT
51 dump_struct_typemap(definedtype)
52 when :TYPE_ARRAY
53 dump_array_typemap(definedtype)
54 when :TYPE_MAP, :TYPE_EMPTY
55 nil
56 else
57 raise NotImplementedError.new("must not reach here")
58 end
59 end
60 end
61
62 def dump_struct_typemap(definedtype)
63 ele = definedtype.name
64 return <<__EOD__
65MappingRegistry.set(
66 #{create_class_name(ele)},
67 ::SOAP::SOAPStruct,
68 ::SOAP::Mapping::Registry::TypedStructFactory,
69 { :type => #{dqname(ele)} }
70)
71__EOD__
72 end
73
74 def dump_array_typemap(definedtype)
75 ele = definedtype.name
76 arytype = definedtype.find_arytype || XSD::AnyTypeName
77 type = XSD::QName.new(arytype.namespace, arytype.name.sub(/\[(?:,)*\]$/, ''))
78 @types << type
79 return <<__EOD__
80MappingRegistry.set(
81 #{create_class_name(ele)},
82 ::SOAP::SOAPArray,
83 ::SOAP::Mapping::Registry::TypedArrayFactory,
84 { :type => #{dqname(type)} }
85)
86__EOD__
87 end
88end
89
90
91end
92end
Note: See TracBrowser for help on using the repository browser.