Skip to content

Commit

Permalink
Add bureauCode class to DCAT writer
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Oliveros committed May 9, 2024
1 parent ca53ce3 commit 402cb5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'jbuilder'

module ADIWG
module Mdtranslator
module Writers
module Dcat_us
module BureauCode

def self.build(intObj)

roles = intObj[:metadata][:resourceInfo][:citation][:responsibleParties]&.select { |party| party[:roleName] == 'bureau' }
bureaus = intObj[:contacts]&.select { |contact| contact[:externalIdentifier].any? { |id| id[:namespace] == 'bureauCode'} }

bureauCodes = []
unless roles.empty? || bureaus.empty?
roles.each do |bureau|
roleId = bureau[:parties][0][:contactId]
bureauId = bureau[:parties].any? { |party| party[:contactId] == roleId } ? roleId : nil
unless bureauId.nil?
bureauCodes << bureauId
end
end
end

return bureauCodes
end

end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
require_relative 'dcat_us_accrualPeriodicity'
require_relative 'dcat_us_language'
require_relative 'dcat_us_primaryITInvestmentUII'
# require_relative 'dcat_us_program_code'
require_relative 'dcat_us_bureau_code'

module ADIWG
module Mdtranslator
Expand Down Expand Up @@ -57,6 +59,8 @@ def self.build(intObj, responseObj)
describedByType = DescribedByType.build(intObj)
accrualPeriodicity = AccrualPeriodicity.build(intObj)
primaryITInvestmentUII = PrimaryITInvestmentUII.build(intObj)
# programCode = ProgramCode.build(intObj)
bureauCode = BureauCode.build(intObj)

@Namespace = ADIWG::Mdtranslator::Writers::Dcat_us

Expand All @@ -70,8 +74,8 @@ def self.build(intObj, responseObj)
json.set!('contactPoint', contactPoint)
json.set!('identifier', identifier)
json.set!('accessLevel', accessLevel)
# json.set!('bureauCode', 'ToDo')
# json.set!('programCode', 'ToDo')
json.set!('bureauCode', bureauCode)
# json.set!('programCode', programCode)
json.set!('distribution', distribution)

json.set!('license', license)
Expand Down

0 comments on commit 402cb5d

Please sign in to comment.