lib/adiwg/mdtranslator/readers/mdJson/modules/module_releasability.rb in adiwg-mdtranslator-2.9.2 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_releasability.rb in adiwg-mdtranslator-2.10.0

- old
+ new

@@ -1,71 +1,77 @@ # unpack releasability # Reader - ADIwg JSON to internal data structure # History: +# Stan Smith 2018-02-19 refactored error and warning messaging # Stan Smith 2016-10-15 original script require_relative 'module_responsibleParty' module ADIWG - module Mdtranslator - module Readers - module MdJson + module Mdtranslator + module Readers + module MdJson - module Releasability + module Releasability - def self.unpack(hRelease, responseObj) + def self.unpack(hRelease, responseObj) - # return nil object if input is empty - if hRelease.empty? - responseObj[:readerExecutionMessages] << 'Releasability object is empty' - responseObj[:readerExecutionPass] = false - return nil - end + # return nil object if input is empty + if hRelease.empty? + responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: releasability object is empty' + return nil + end - # instance classes needed in script - intMetadataClass = InternalMetadata.new - intRelease = intMetadataClass.newRelease + # instance classes needed in script + intMetadataClass = InternalMetadata.new + intRelease = intMetadataClass.newRelease - # releasability - addressee [responsibleParty] - if hRelease.has_key?('addressee') - aRParty = hRelease['addressee'] - aRParty.each do |item| - hParty = ResponsibleParty.unpack(item, responseObj) - unless hParty.nil? - intRelease[:addressee] << hParty - end - end - end + haveRelease = false - # releasability - statement - if hRelease.has_key?('statement') - if hRelease['statement'] != '' - intRelease[:statement] = hRelease['statement'] - end + # releasability - addressee [responsibleParty] + if hRelease.has_key?('addressee') + aRParty = hRelease['addressee'] + aRParty.each do |item| + hParty = ResponsibleParty.unpack(item, responseObj) + unless hParty.nil? + intRelease[:addressee] << hParty + haveRelease = true end + end + end - # releasability - dissemination constraint [] - if hRelease.has_key?('disseminationConstraint') - hRelease['disseminationConstraint'].each do |item| - if item != '' - intRelease[:disseminationConstraint] << item - end - end - end + # releasability - statement + if hRelease.has_key?('statement') + unless hRelease['statement'] == '' + intRelease[:statement] = hRelease['statement'] + haveRelease = true + end + end - if intRelease[:addressee].empty? && intRelease[:statement].nil? - responseObj[:readerExecutionMessages] << 'Releasability must have at least one addressee or statement' - responseObj[:readerExecutionPass] = false - return nil + # releasability - dissemination constraint [] + if hRelease.has_key?('disseminationConstraint') + hRelease['disseminationConstraint'].each do |item| + if item != '' + intRelease[:disseminationConstraint] << item end + end + end - return intRelease + # error messages + unless haveRelease + responseObj[:readerExecutionMessages] << + 'ERROR: mdJson reader: releasability must have at least one addressee or statement' + responseObj[:readerExecutionPass] = false + return nil + end - end + return intRelease - end + end end - end - end + + end + end + end end \ No newline at end of file