Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/mdjson-reader-platform #371

Merged
merged 9 commits into from
May 6, 2024
64 changes: 36 additions & 28 deletions lib/adiwg/mdtranslator/readers/mdJson/modules/module_platform.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative 'module_citation'
require_relative 'module_identifier'
require_relative 'module_responsibileParty'
require_relative 'module_responsibleParty'
require_relative 'module_acq-instrument'
require_relative 'module_acq-instrumentationEventList'

Expand All @@ -10,62 +10,70 @@ module Readers
module MdJson

module Platform
def self.unpack(hAcqPlatform, responseObj, inContext = nil)
def self.unpack(hPlatform, responseObj, inContext = nil)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

intAcqPlatform = intMetadataClass.newPlatform
intMetadataClass = InternalMetadata.new
intPlatform = intMetadataClass.newPlatform

if hAcqPlatform.has_key('platformId')
intAcqPlatform[:platformId] = hAcqPlatform['platformId']
if hPlatform.has_key?('platformId')
intPlatform[:platformId] = hPlatform['platformId']
else
@MessagePath.issueError(460, responseObj, inContext)
end

if hAcqPlatform.has_key?('citation')
hReturn = Citation.unpack(hAcqPlatform['citation'], responseObj, inContext)
if hPlatform.has_key?('citation')
hReturn = Citation.unpack(hPlatform['citation'], responseObj, inContext)
unless hReturn.nil?
intAcqPlatform[:citation] = hReturn
intPlatform[:citation] = hReturn
end
end

if hAcqPlatform.has_key?('identifier')
hReturn = Identifier.unpack(hAcqPlatform['identifier'], responseObj, inContext)
if hPlatform.has_key?('identifier')
hReturn = Identifier.unpack(hPlatform['identifier'], responseObj, inContext)
unless hReturn.nil?
intAcqPlatform[:identifier] = hReturn
intPlatform[:identifier] = hReturn
else
@MessagePath.issueError(461, responseObj, inContext)
end
end

if hAcqPlatform.has_key('description')
intAcqPlatform[:description] = hAcqPlatform['description']
if hPlatform.has_key?('description')
intPlatform[:description] = hPlatform['description']
else
@MessagePath.issueError(460, responseObj, inContext)
end

if hAcqPlatform.has_key?('sponsor')
hReturn = ResponsibileParty.unpack(hAcqPlatform['sponsor'], responseObj, inContext)
unless hReturn.nil?
intAcqPlatform[:sponsors] = hReturn
if hPlatform.has_key?('sponsor')
hPlatform['sponsor'].each do |sponsor|
hReturn = ResponsibleParty.unpack(sponsor, responseObj, inContext)
unless hReturn.nil?
intPlatform[:sponsors] = hReturn
end
end
end

if hAcqPlatform.has_key('instrument')
hReturn = AcqInstrument.unpack(hAcqPlatform['instrument'], responseObj, inContext)
unless hReturn.nil?
intAcqPlatform[:instruments] = hReturn
else
@MessagePath.issueError(461, responseObj, inContext)
if hPlatform.has_key?('instrument')
hPlatform['instrument'].each do |instrument|
hReturn = AcqInstrument.unpack(instrument, responseObj, inContext)
unless hReturn.nil?
intPlatform[:instruments] = hReturn
else
@MessagePath.issueError(461, responseObj, inContext)
end
end
end

if hAcqPlatform.has_key('history')
hReturn = AcqInstrumentationEventList.unpack(hAcqPlatform['history'], responseObj, inContext)
unless hReturn.nil?
intAcqPlatform[:history] = hReturn
if hPlatform.has_key?('history')
hPlatform['history'].each do |history|
hReturn = AcqInstrumentationEventList.unpack(history, responseObj, inContext)
unless hReturn.nil?
intPlatform[:history] = hReturn
end
end
end

intAcqPlatform
intPlatform

end
end
Expand Down
Loading