-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bureauCode class to DCAT writer (#379)
* Add bureauCode class to DCAT writer * Update logic in BureauCode. Add ProgramCode class and update references in dcat_us class
- Loading branch information
1 parent
ca53ce3
commit 098c4be
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_bureau_code.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_program_code.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |