Sha256: 9dce4b926127eed3f8a7c0901e52acb55931f0e4f769803728f9f815b8cc772e

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

# unpack dates
# Reader - ScienceBase JSON to internal data structure

# History:
#   Stan Smith 2016-06-25 original script

require 'adiwg/mdtranslator/internal/internal_metadata_obj'
require 'adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists'

module ADIWG
   module Mdtranslator
      module Readers
         module SbJson

            module Date

               @Namespace = ADIWG::Mdtranslator::Writers::SbJson

               def self.unpack(hSbJson, hCitation, hResponseObj)

                  # instance classes needed in script
                  intMetadataClass = InternalMetadata.new

                  if hSbJson.has_key?('dates')
                     hSbJson['dates'].each do |hSbDate|
                        hDate = intMetadataClass.newDate
                        aReturn = AdiwgDateTimeFun.dateTimeFromString(hSbDate['dateString'])
                        unless aReturn.nil?
                           hDate[:date] = aReturn[0]
                           hDate[:dateResolution] = aReturn[1]
                           hDate[:description] = hSbDate['label']
                           type = @Namespace::Codelists.codelist_iso_to_sb('iso_sb_date', :sbCode => hSbDate['type'])
                           type = type.nil? ? hSbDate['type'] : type
                           hDate[:dateType] = type
                           hCitation[:dates] << hDate
                        end
                     end
                  end

                  return hCitation

               end

            end

         end
      end
   end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.0.0 lib/adiwg/mdtranslator/readers/sbJson/modules/module_date.rb