module ADIWG::Mdtranslator::Readers::SbJson::MaterialRequest

Public Class Methods

unpack(hSbJson, hResponseObj) click to toggle source
# File lib/adiwg/mdtranslator/readers/sbJson/modules/module_materialRequest.rb, line 17
def self.unpack(hSbJson, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new

   if hSbJson.has_key?('materialRequestInstructions')
      sbRequest = hSbJson['materialRequestInstructions']
      unless sbRequest.nil? || sbRequest == ''

         # make a new request contact
         hContact = intMetadataClass.newContact
         hContact[:contactId] = UUIDTools::UUID.random_create.to_s
         hContact[:name] = 'U.S. Geological Survey ScienceBase'
         hContact[:contactType] = 'materialRequestInstructions'

         # make a new distribution record
         hDistribution = intMetadataClass.newDistribution
         hDistributor = intMetadataClass.newDistributor
         hResponsibility = intMetadataClass.newResponsibility
         hParty = intMetadataClass.newParty
         hProcess = intMetadataClass.newOrderProcess

         # parties [] {party}
         hParty[:contactId] = hContact[:contactId]
         hParty[:contactType] = 'ScienceBase'

         # contact {responsibility}
         hResponsibility[:roleName] = 'distributor'
         hResponsibility[:parties] << hParty

         # orderProcess {orderProcess}
         hProcess[:orderingInstructions] = sbRequest

         # distributor {distributor}
         hDistributor[:contact] = hResponsibility
         hDistributor[:orderProcess] << hProcess

         # distribution {distribution}
         hDistribution[:description] = 'sbJson Material Request distributor generated by ADIwg mdTranslator'
         hDistribution[:distributor] << hDistributor

         return hContact, hDistribution

      end
   end

   return nil

end