Sha256: 2c9aa3de23ed72195eb15235e8a58677894be180f801e7e414634779620025be

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

# unpack associated resource
# Reader - ADIwg JSON V1 to internal data structure

# History:
# 	Stan Smith 2014-05-02 original script
# 	Stan Smith 2014-05-28 added resource identifier section
# 	Stan Smith 2014-06-02 added resource metadata citation section
#   Stan Smith 2014-07-08 resolve require statements using Mdtranslator.reader_module
#   Stan Smith 2014-08-18 moved resourceIdentifier to citation module schema 0.6.0
#   Stan Smith 2014-11-06 changed resourceType to initiative type for 0.9.0
#   Stan Smith 2014-11-06 added resourceType for 0.9.0

require ADIWG::Mdtranslator.reader_module('module_citation', $response[:readerVersionUsed])

module Md_AssociatedResource

	def self.unpack(hAssocRes)

		# instance classes needed in script
		intMetadataClass = InternalMetadata.new
		intAssocRes = intMetadataClass.newAssociatedResource

		# associated resource - association type
		if hAssocRes.has_key?('associationType')
			s = hAssocRes['associationType']
			if s != ''
				intAssocRes[:associationType] = s
			end
		end

		# associated resource - initiative type
		if hAssocRes.has_key?('initiativeType')
			s = hAssocRes['initiativeType']
			if s != ''
				intAssocRes[:initiativeType] = s
			end
		end

		# associated resource - resource type
		if hAssocRes.has_key?('resourceType')
			s = hAssocRes['resourceType']
			if s != ''
				intAssocRes[:resourceType] = s
			end
		end

		# associated resource - resource citation
		if hAssocRes.has_key?('resourceCitation')
			hCitation = hAssocRes['resourceCitation']
			unless hCitation.empty?
				intAssocRes[:resourceCitation] = Md_Citation.unpack(hCitation)
			end
		end

		# associated resource - metadata citation
		if hAssocRes.has_key?('metadataCitation')
			hCitation = hAssocRes['metadataCitation']
			unless hCitation.empty?
				intAssocRes[:metadataCitation] = Md_Citation.unpack(hCitation)
			end
		end

		return intAssocRes
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adiwg-mdtranslator-0.10.2 lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_associatedResource.rb