class ResoTransport::MetadataParser
Attributes
entity_sets[R]
enumerations[R]
schemas[R]
Public Class Methods
new()
click to toggle source
# File lib/reso_transport/metadata_parser.rb, line 7 def initialize @schemas = [] @entity_sets = [] @entity_types = [] @enumerations = [] @current_entity_type = nil @current_complex_type = nil @current_enum_type = nil @current_member = nil @datasystem = nil end
Public Instance Methods
datasystem?()
click to toggle source
# File lib/reso_transport/metadata_parser.rb, line 111 def datasystem? return @datasystem unless @datasystem.nil? @datasystem = @schemas.any? { |s| s.entity_types.any? { |t| t.name == 'DataSystem' } } end
finalize()
click to toggle source
# File lib/reso_transport/metadata_parser.rb, line 27 def finalize schemas.each do |s| s.entity_types.each do |et| et.properties.each do |p| p.finalize_type(self) end et.navigation_properties.each do |p| p.finalize_type(self) end end s.complex_types.each do |et| et.properties.each do |p| p.finalize_type(self) end end end end
parse(doc)
click to toggle source
# File lib/reso_transport/metadata_parser.rb, line 21 def parse(doc) REXML::Document.parse_stream(doc, self) finalize self end
tag_end(name)
click to toggle source
# File lib/reso_transport/metadata_parser.rb, line 94 def tag_end(name) case name when 'EntityType' @current_entity_type.schema = @schemas.last.namespace @schemas.last.entity_types << @current_entity_type when 'ComplexType' @current_complex_type.schema = @schemas.last.namespace @schemas.last.complex_types << @current_complex_type when 'EnumType' @enumerations << @current_enum_type @current_enum_type = nil when 'Member' @current_enum_type.members << @current_member @current_member = nil end end
tag_start(name, args)
click to toggle source
Schema ->
EnumType -> Members -> Annotation EntityType -> Key Properties -> enumerations
# File lib/reso_transport/metadata_parser.rb, line 57 def tag_start(name, args) case name when 'Schema' @schemas << ResoTransport::Schema.from_stream(args) when 'EntitySet' @entity_sets << ResoTransport::EntitySet.from_stream(args) when 'EntityType' @current_entity_type = ResoTransport::EntityType.from_stream(args) when 'ComplexType' @current_complex_type = ResoTransport::EntityType.from_stream(args) when 'PropertyRef' @current_entity_type.primary_key = args['Name'] when 'Property' if @current_entity_type @current_entity_type.properties << ResoTransport::Property.from_stream(args.merge(schema: @schemas.last)) end if @current_complex_type @current_complex_type.properties << ResoTransport::Property.from_stream(args.merge(schema: @schemas.last)) end when 'NavigationProperty' @current_entity_type.navigation_properties << ResoTransport::Property.from_stream(args) when 'EnumType' @current_enum_type = ResoTransport::Enum.from_stream(args.merge(schema: @schemas.last)) when 'Member' @current_member = ResoTransport::Member.from_stream(args) when 'Annotation' if @current_enum_type && @current_member @current_member.annotation = args['String'] elsif @current_entity_type || @current_complex_type # raise args.inspect end end rescue StandardError => e puts e.inspect puts "Error processing Tag: #{[name, args].inspect}" end