# unpack material request instructions # Reader - ScienceBase JSON to internal data structure # History: # Stan Smith 2016-06-21 original script require 'uuidtools' require 'adiwg/mdtranslator/internal/internal_metadata_obj' module ADIWG module Mdtranslator module Readers module SbJson module MaterialRequest 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 end end end end end