Skip to content

Commit

Permalink
Add bureauCode class to DCAT writer (#379)
Browse files Browse the repository at this point in the history
* Add bureauCode class to DCAT writer

* Update logic in BureauCode. Add ProgramCode class and update references in dcat_us class
  • Loading branch information
J-Oliveros committed May 9, 2024
1 parent ca53ce3 commit 098c4be
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'jbuilder'

module ADIWG
module Mdtranslator
module Writers
module Dcat_us
module BureauCode

def self.build(intObj)

responsibleParties = intObj[:metadata][:resourceInfo][:citation][:responsibleParties]
contacts = []
responsibleParties.each do |party|
contactId = party[:parties][0][:contactId]
contacts << Dcat_us.get_contact_by_id(contactId)
end

bureauContacts = contacts&.select { |contact| contact[:externalIdentifier].any? { |id| id[:namespace] == 'bureauCode'} }

bureauCodes = []
bureauContacts.each do |contact|
bureauCode = contact[:externalIdentifier].find { |id| id[:namespace] == 'bureauCode' }
bureauCodes << bureauCode[:identifier]
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'jbuilder'

module ADIWG
module Mdtranslator
module Writers
module Dcat_us
module ProgramCode

def self.build(intObj)

responsibleParties = intObj[:metadata][:resourceInfo][:citation][:responsibleParties]
contacts = []
responsibleParties.each do |party|
contactId = party[:parties][0][:contactId]
contacts << Dcat_us.get_contact_by_id(contactId)
end

programContacts = contacts&.select { |contact| contact[:externalIdentifier].any? { |id| id[:namespace] == 'programCode'} }

programsCodes = []
programContacts.each do |contact|
programCode = contact[:externalIdentifier].find { |id| id[:namespace] == 'programCode' }
programsCodes << programCode[:identifier]
end

return programsCodes
end

end
end
end
end
end

0 comments on commit 098c4be

Please sign in to comment.