Sha256: dfd748c15a6469bc4183de08be5c7b908cadd1e41dd463f342b3937ecd7bd7f6

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

# coding: utf-8

require 'libis/services/oracle_client'
require 'libis/tools/xml_document'

module Libis
  module Services
    module Scope

      class Search
        include ::Libis::Services::GenericSearch

        def initialize
          @doc = nil
        end

        def find(term, options = {})
          super
          OracleClient.new('SCOPE01', 'APLKN_ARCHV_LIAS', 'archvsc').
              call('kul_packages.scope_xml_meta_file_ed', [term.upcase])
          err_file = "/nas/vol03/oracle/scope01/#{term}_err.XML"
          if File.exist? err_file
            doc = XmlDocument.open(err_file)
            msg = doc.xpath('/error/error_msg').first.content
            msg_detail = doc.xpath('/error/error_').first.content
            File.delete(err_file)
            @doc = nil
            raise RuntimeError, "Scope search failed: '#{msg}'. Details: '#{msg_detail}'"
          else
            @doc = XmlDocument.open("/nas/vol03/oracle/scope01/#{term}_md.XML").to_hash
          end
        end

        def each(_ = {})
          yield @doc
        end

        def next_record(_ = {})
          yield @doc
        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
libis-services-0.1.5 lib/libis/services/scope/search.rb
libis-services-0.1.3 lib/libis/services/scope/search.rb
libis-services-0.1.2 lib/libis/services/scope/search.rb
libis-services-0.1.1 lib/libis/services/scope/search.rb
libis-services-0.1.0-java lib/libis/services/scope/search.rb
libis-services-0.0.3 lib/libis/services/scope/search.rb
libis-services-0.0.2 lib/libis/services/scope/search.rb