Class: Seiso::ImportMaster::Importers::ServiceImporter

Inherits:
BaseImporter
  • Object
show all
Defined in:
lib/seiso/import_master/importers/service_importer.rb

Overview

Author

Willie Wheeler ([email protected])

Copyright

Copyright © 2014-2015 Expedia, Inc.

License

Apache 2.0

Instance Method Summary collapse

Methods inherited from BaseImporter

#detach_children

Constructor Details

#initialize(basic_mapper, service_mapper, uri_factory_v1, uri_factory_v2, rest_connector_v1, rest_connector_v2) ⇒ ServiceImporter

Returns a new instance of ServiceImporter.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/seiso/import_master/importers/service_importer.rb', line 16

def initialize(
        basic_mapper,
        service_mapper,
        uri_factory_v1,
        uri_factory_v2,
        rest_connector_v1,
        rest_connector_v2)

	@service_mapper = service_mapper
      @basic_mapper = basic_mapper
      @uri_factory_v1 = uri_factory_v1
      @uri_factory_v2 = uri_factory_v2
      @rest_connector_v1 = rest_connector_v1
      @rest_connector_v2 = rest_connector_v2
end

Instance Method Details

#import(doc) ⇒ Object

Imports the service document



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/seiso/import_master/importers/service_importer.rb', line 33

def import(doc)
					services = doc['items']
					puts "Importing service document"

					sdm_doc_links = detach_children(services, 'service', 'key', 'docLinks')

					seiso_services = services.map { |s| @service_mapper.seiso_service s }
  services_uri = @uri_factory_v1.services_uri true
  @rest_connector_v1.post(services_uri, seiso_services)

  import_doc_links(services, sdm_doc_links)
end