-
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.
- Loading branch information
1 parent
ca53ce3
commit 402cb5d
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
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,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 |
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