adiwg-mdtranslator 2.19.0.pre.beta.17 → 2.20.0.pre.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/DCAT-US.md +67 -0
  4. data/Gemfile.lock +37 -27
  5. data/README.md +21 -0
  6. data/Rakefile +1 -0
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dataQuality.rb +1 -1
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_conformanceResult.rb +0 -5
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coverageResult.rb +0 -4
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_descriptiveResult.rb +0 -4
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_quantitativeResult.rb +0 -4
  12. data/lib/adiwg/mdtranslator/version.rb +1 -1
  13. data/lib/adiwg/mdtranslator/writers/dcat_us/dcat_us_writer.rb +98 -0
  14. data/lib/adiwg/mdtranslator/writers/dcat_us/readme.md +10 -0
  15. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_level.rb +55 -0
  16. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_url.rb +17 -0
  17. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_accrualPeriodicity.rb +45 -0
  18. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_bureau_code.rb +33 -0
  19. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_contact_point.rb +29 -0
  20. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_dcat_us.rb +104 -0
  21. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by.rb +29 -0
  22. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by_type.rb +33 -0
  23. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_description.rb +19 -0
  24. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_distribution.rb +59 -0
  25. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_download_url.rb +17 -0
  26. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_identifier.rb +29 -0
  27. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_is_part_of.rb +27 -0
  28. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_issued.rb +19 -0
  29. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_keyword.rb +19 -0
  30. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_landing_page.rb +27 -0
  31. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_language.rb +23 -0
  32. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_license.rb +18 -0
  33. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_media_type.rb +17 -0
  34. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_modified.rb +29 -0
  35. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_primaryITInvestmentUII.rb +19 -0
  36. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_program_code.rb +33 -0
  37. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_publisher.rb +74 -0
  38. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_references.rb +50 -0
  39. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_rights.rb +32 -0
  40. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_spatial.rb +32 -0
  41. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_system_of_records.rb +28 -0
  42. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_temporal.rb +40 -0
  43. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_theme.rb +28 -0
  44. data/lib/adiwg/mdtranslator/writers/dcat_us/version.rb +14 -0
  45. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dataQuality.rb +1 -1
  46. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQualityReport.rb +0 -28
  47. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_conformanceResult.rb +5 -6
  48. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageResult.rb +0 -1
  49. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_descriptiveResult.rb +0 -1
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_quantitativeResult.rb +5 -6
  51. data/lib/adiwg/mdtranslator_cli.rb +1 -1
  52. metadata +34 -1
@@ -0,0 +1,104 @@
1
+ require 'jbuilder'
2
+ require_relative 'dcat_us_keyword'
3
+ require_relative 'dcat_us_publisher'
4
+ require_relative 'dcat_us_contact_point'
5
+ require_relative 'dcat_us_identifier'
6
+ require_relative 'dcat_us_distribution'
7
+ require_relative 'dcat_us_spatial'
8
+ require_relative 'dcat_us_temporal'
9
+ require_relative 'dcat_us_modified'
10
+ require_relative 'dcat_us_access_level'
11
+ require_relative 'dcat_us_rights'
12
+ require_relative 'dcat_us_license'
13
+ require_relative 'dcat_us_issued'
14
+ require_relative 'dcat_us_described_by'
15
+ require_relative 'dcat_us_is_part_of'
16
+ require_relative 'dcat_us_theme'
17
+ require_relative 'dcat_us_references'
18
+ require_relative 'dcat_us_landing_page'
19
+ require_relative 'dcat_us_system_of_records'
20
+ require_relative 'dcat_us_description'
21
+ require_relative 'dcat_us_described_by_type'
22
+ require_relative 'dcat_us_accrualPeriodicity'
23
+ require_relative 'dcat_us_language'
24
+ require_relative 'dcat_us_primaryITInvestmentUII'
25
+ require_relative 'dcat_us_program_code'
26
+ require_relative 'dcat_us_bureau_code'
27
+
28
+ module ADIWG
29
+ module Mdtranslator
30
+ module Writers
31
+ module Dcat_us
32
+
33
+ def self.build(intObj, responseObj)
34
+ metadataInfo = intObj[:metadata][:metadataInfo]
35
+ resourceInfo = intObj[:metadata][:resourceInfo]
36
+ citation = resourceInfo[:citation]
37
+
38
+ title = citation[:title]
39
+ description = Description.build(intObj)
40
+ keyword = Keyword.build(intObj)
41
+ modified = Modified.build(intObj)
42
+ publisher = Publisher.build(intObj)
43
+ contactPoint = ContactPoint.build(intObj)
44
+ accessLevel = AccessLevel.build(intObj)
45
+ identifier = Identifier.build(intObj)
46
+ distribution = Distribution.build(intObj)
47
+ rights = Rights.build(intObj, accessLevel)
48
+ spatial = Spatial.build(intObj)
49
+ temporal = Temporal.build(intObj)
50
+ license = License.build(intObj)
51
+ issued = Issued.build(intObj)
52
+ language = Language.build(intObj)
53
+ describedBy = DescribedBy.build(intObj)
54
+ isPartOf = IsPartOf.build(intObj)
55
+ theme = Theme.build(intObj)
56
+ references = References.build(intObj)
57
+ landingPage = LandingPage.build(intObj)
58
+ systemOfRecords = SystemOfRecords.build(intObj)
59
+ describedByType = DescribedByType.build(intObj)
60
+ accrualPeriodicity = AccrualPeriodicity.build(intObj)
61
+ primaryITInvestmentUII = PrimaryITInvestmentUII.build(intObj)
62
+ programCode = ProgramCode.build(intObj)
63
+ bureauCode = BureauCode.build(intObj)
64
+
65
+ @Namespace = ADIWG::Mdtranslator::Writers::Dcat_us
66
+
67
+ Jbuilder.new do |json|
68
+ json.set!('@type', 'dcat:Dataset')
69
+ json.set!('title', title)
70
+ json.set!('description', description)
71
+ json.set!('keyword', keyword)
72
+ json.set!('modified', modified)
73
+ json.set!('publisher', publisher)
74
+ json.set!('contactPoint', contactPoint)
75
+ json.set!('identifier', identifier)
76
+ json.set!('accessLevel', accessLevel)
77
+ json.set!('bureauCode', bureauCode)
78
+ json.set!('programCode', programCode)
79
+ json.set!('distribution', distribution)
80
+
81
+ json.set!('license', license)
82
+ json.set!('rights', rights)
83
+ json.set!('spatial', spatial)
84
+ json.set!('temporal', temporal)
85
+
86
+ json.set!('issued', issued)
87
+ json.set!('accrualPeriodicity', accrualPeriodicity)
88
+ json.set!('language', language)
89
+ # json.set!('dataQuality', metadataInfo[:metadataMaintenance][:maintenanceNote])
90
+ json.set!('theme', theme)
91
+ json.set!('references', references)
92
+ json.set!('landingPage', landingPage)
93
+ json.set!('isPartOf', isPartOf)
94
+ json.set!('systemOfRecords', systemOfRecords)
95
+ json.set!('primaryITInvestmentUII', primaryITInvestmentUII)
96
+ json.set!('describedBy', describedBy)
97
+ json.set!('describedByType', describedByType)
98
+ # json.set!('conformsTo', metadataInfo[:metadataStandards][0][:standardName])
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,29 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module DescribedBy
8
+
9
+ def self.build(intObj)
10
+ dataDictionaries = intObj[:dataDictionaries]
11
+ dataDictionaries.each do |dataDictionary|
12
+ unless dataDictionary[:includedWithDataset]
13
+ onlineResources = dataDictionary[:citation][:onlineResources]
14
+ onlineResources.each do |resource|
15
+ if resource[:olResURI]
16
+ return resource[:olResURI]
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ nil
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module DescribedByType
8
+
9
+ def self.build(intObj)
10
+
11
+ # metadataInfo[:metadataOnlineOptions][0][:olResProtocol]
12
+ dataDictionaries = intObj[:dataDictionaries]
13
+ describedByType = ''
14
+ dataDictionaries.each do |dataDictionary|
15
+ unless dataDictionary[:includedWithDataset]
16
+ onlineResources = dataDictionary[:citation][:onlineResources]
17
+ onlineResources.each do |resource|
18
+ if resource[:olResURI] && !resource[:olResURI].end_with?('.html')
19
+ describedByType = resource[:olResProtocol]
20
+ break
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ describedByType
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module Description
6
+
7
+ def self.build(intObj)
8
+ resourceInfo = intObj.dig(:metadata, :resourceInfo)
9
+ description = resourceInfo&.dig(:abstract)
10
+
11
+ return nil unless description
12
+ end
13
+
14
+
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ require 'jbuilder'
2
+ require_relative 'dcat_us_access_url'
3
+ require_relative 'dcat_us_download_url'
4
+ require_relative 'dcat_us_media_type'
5
+
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Dcat_us
11
+ module Distribution
12
+
13
+ def self.build(intObj)
14
+
15
+ resourceDistributions = intObj.dig(:metadata, :distributorInfo)
16
+ distributions = []
17
+
18
+ resourceDistributions&.each do |resource|
19
+ description = resource[:description] || ''
20
+ break_flag = false # Flag to control nested loop breaks
21
+
22
+ resource[:distributor]&.each do |distributor|
23
+ break if break_flag
24
+
25
+ distributor[:transferOptions]&.each do |transfer|
26
+ break if break_flag
27
+
28
+ mediaType = MediaType.build(transfer)
29
+
30
+ transfer[:onlineOptions]&.each do |option|
31
+ next unless option[:olResURI]
32
+ accessURL = AccessURL.build(option)
33
+ downloadURL = DownloadURL.build(option)
34
+ title = option[:olResName] || ''
35
+
36
+ distribution = Jbuilder.new do |json|
37
+ json.set!('@type', 'dcat:Distribution')
38
+ json.set!('description', description)
39
+ json.set!('accessURL', accessURL) if accessURL
40
+ json.set!('downloadURL', downloadURL) if downloadURL
41
+ json.set!('mediaType', mediaType)
42
+ json.set!('title', title)
43
+ end
44
+
45
+ distributions << distribution.attributes!
46
+ break_flag = true
47
+ break
48
+ end
49
+ end
50
+ end
51
+ end
52
+ distributions
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,17 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module DownloadURL
8
+
9
+ def self.build(option)
10
+ option[:olResURI] unless option[:olResURI].end_with?('.html')
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module Identifier
6
+
7
+ def self.build(intObj)
8
+ citation = intObj.dig(:metadata, :resourceInfo, :citation)
9
+ identifiers = citation&.dig(:identifiers)
10
+ onlineResources = citation&.dig(:onlineResources)
11
+ uri = onlineResources.dig(0, :olResURI)
12
+
13
+ namespace_is_doi = identifiers&.any? { |identifier| identifier[:namespace]&.casecmp?("DOI") }
14
+
15
+ if namespace_is_doi
16
+ return uri
17
+ elsif uri && uri.downcase.include?("doi")
18
+ return uri
19
+ end
20
+
21
+ nil
22
+ end
23
+
24
+
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module IsPartOf
8
+
9
+ def self.build(intObj)
10
+ associatedResources = intObj.dig(:metadata, :associatedResources)
11
+
12
+ associatedResources.each do |resource|
13
+ next unless resource[:initiativeType] == "collection" && resource[:associationType] == "collectiveTitle"
14
+
15
+ onlineResources = resource.dig(:resourceCitation, :onlineResources) || []
16
+ uri = onlineResources.find { |onlineResource| onlineResource[:olResURI] }&.dig(:olResURI)
17
+ return uri if uri
18
+ end
19
+
20
+ nil
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module Issued
8
+
9
+ def self.build(intObj)
10
+ dates = intObj[:metadata][:resourceInfo][:citation][:dates].map { |obj| obj[:date] }
11
+ earliest_date = dates.min
12
+ return earliest_date
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module Keyword
6
+
7
+ def self.build(intObj)
8
+ resourceInfo = intObj.dig(:metadata, :resourceInfo)
9
+ keywords = resourceInfo&.dig(:keywords)
10
+
11
+ return keywords&.flat_map { |keyword| keyword[:keywords]&.map { |kw| kw[:keyword] } } || []
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,27 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module LandingPage
8
+
9
+ def self.build(intObj)
10
+ onlineResources = intObj.dig(:metadata, :resourceInfo, :citation, :onlineResources)
11
+
12
+ if onlineResources
13
+ onlineResources.each do |resource|
14
+ if resource.dig(:olResFunction) == 'landingPage'
15
+ return resource.dig(:olResURI)
16
+ end
17
+ end
18
+ end
19
+
20
+ return nil
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module Language
6
+
7
+ def self.build(intObj)
8
+ metadataInfo = intObj.dig(:metadata, :metadataInfo)
9
+ defaultLanguage = metadataInfo&.dig(:defaultMetadataLocale, :languageCode)
10
+ additionalLanguage = metadataInfo&.dig(:otherMetadataLocales)
11
+ languages = []
12
+ languages << defaultLanguage if defaultLanguage
13
+ additionalLanguage.each { |lang| languages << lang[:languageCode] } if additionalLanguage
14
+
15
+ return languages
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,18 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module License
6
+
7
+ def self.build(intObj)
8
+ resourceInfo = intObj.dig(:metadata, :resourceInfo)
9
+ title = resourceInfo.dig(:constraints, 0, :reference, 0, :title)
10
+ license = title || 'https://creativecommons.org/publicdomain/zero/1.0/'
11
+ license
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module MediaType
8
+
9
+ def self.build(transfer)
10
+ transfer.dig(:distributionFormats)&.find { |format| format.dig(:formatSpecification, :title) }&.dig(:formatSpecification, :title) || ''
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module Modified
6
+
7
+ def self.build(intObj)
8
+ resourceInfo = intObj[:metadata][:resourceInfo]
9
+ citation = resourceInfo[:citation]
10
+ dates = citation[:dates]
11
+
12
+ mostRecentDate = nil
13
+
14
+ dates.each do |date|
15
+ if date[:dateType] == "lastUpdated" || date[:dateType] == "lastRevised" || date[:dateType] == "revision"
16
+ if mostRecentDate.nil? || date[:date] > mostRecentDate
17
+ mostRecentDate = date[:date]
18
+ end
19
+ end
20
+ end
21
+
22
+ return mostRecentDate
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module PrimaryITInvestmentUII
8
+
9
+ def self.build(intObj)
10
+ primaryITInvestmentUII = intObj[:metadata][:metadataInfo][:metadataIdentifier][:identifier]
11
+
12
+ primaryITInvestmentUII ? primaryITInvestmentUII : nil
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module ProgramCode
8
+
9
+ def self.build(intObj)
10
+
11
+ responsibleParties = intObj[:metadata][:resourceInfo][:citation][:responsibleParties]
12
+ contacts = []
13
+ responsibleParties.each do |party|
14
+ contactId = party[:parties][0][:contactId]
15
+ contacts << Dcat_us.get_contact_by_id(contactId)
16
+ end
17
+
18
+ programContacts = contacts&.select { |contact| contact[:externalIdentifier].any? { |id| id[:namespace] == 'programCode'} }
19
+
20
+ programsCodes = []
21
+ programContacts.each do |contact|
22
+ programCode = contact[:externalIdentifier].find { |id| id[:namespace] == 'programCode' }
23
+ programsCodes << programCode[:identifier]
24
+ end
25
+
26
+ return programsCodes
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,74 @@
1
+ module ADIWG
2
+ module Mdtranslator
3
+ module Writers
4
+ module Dcat_us
5
+ module Publisher
6
+ def self.build(intObj)
7
+ contacts = intObj.dig(:contacts)
8
+ metadata = intObj.dig(:metadata)
9
+ responsible_parties = metadata&.dig(:resourceInfo, :citation, :responsibleParties)
10
+ resource_distributions = metadata&.dig(:distributorInfo)
11
+
12
+ publisher = find_publisher(responsible_parties) || find_distributions_publisher(intObj)
13
+
14
+ return if publisher.nil?
15
+
16
+ name, org_name = extract_names(publisher, contacts)
17
+
18
+ return if name.nil?
19
+
20
+ build_json(name, org_name)
21
+ end
22
+
23
+ private
24
+
25
+ def self.find_publisher(responsible_parties)
26
+ responsible_parties&.detect do |party|
27
+ party[:roleName] == 'publisher' && party.dig(:parties)&.first&.dig(:contactType) == 'organization'
28
+ end
29
+ end
30
+
31
+ def self.find_distributions_publisher(intObj)
32
+ distributor_info = intObj.dig(:metadata, :distributorInfo) || []
33
+ distributor_info.each do |distribution|
34
+ distributors = distribution[:distributor] || []
35
+ distributors.each do |dist|
36
+ contact_type = dist.dig(:contact, :parties, 0, :contactType)
37
+ return dist[:contact] if contact_type == 'organization'
38
+ end
39
+ end
40
+ nil
41
+ end
42
+
43
+ def self.extract_names(publisher, contacts)
44
+ contact_id = publisher.dig(:parties)&.first&.dig(:contactId) || publisher[:contactId]
45
+ related_contact = contacts&.detect { |contact| contact[:contactId] == contact_id }
46
+ org_name = nil
47
+ if related_contact
48
+ member_of_org_ids = related_contact[:memberOfOrgs]
49
+ member_of_orgs = contacts.select { |contact| member_of_org_ids&.include?(contact[:contactId]) && contact[:isOrganization] }
50
+ org_name = member_of_orgs.first&.dig(:name)
51
+ end
52
+ name = publisher.dig(:parties)&.first&.dig(:contactName) || publisher[:contactName]
53
+ [name, org_name]
54
+ end
55
+
56
+ def self.build_json(name, org_name)
57
+ Jbuilder.new do |json|
58
+ json.set!('@type', 'org:Organization')
59
+ json.set!('name', name)
60
+
61
+ if org_name
62
+ json.subOrganizationOf do |json_sub|
63
+ json_sub.set!('@type', 'org:Organization')
64
+ json_sub.set!('name', org_name)
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,50 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module References
8
+
9
+ def self.build(intObj)
10
+ metadata = intObj.dig(:metadata)
11
+ associated_resources = metadata&.dig(:associatedResources)
12
+ additional_documents = metadata&.dig(:additionalDocuments)
13
+ uris = []
14
+
15
+ if associated_resources
16
+ associated_resources.each do |associated|
17
+ citation = associated.dig(:resourceCitation)
18
+ online_resources = citation&.dig(:onlineResources)
19
+ next unless online_resources
20
+
21
+ online_resources.each do |online|
22
+ uri = online.dig(:olResURI)
23
+ uris << uri if uri
24
+ end
25
+ end
26
+ end
27
+
28
+ if additional_documents
29
+ additional_documents.each do |additional|
30
+ citations = additional&.dig(:citation) || []
31
+ citations.each do |citation|
32
+ online_resources = citation&.dig(:onlineResources)
33
+ next unless online_resources
34
+
35
+ online_resources.each do |online|
36
+ uri = online.dig(:olResURI)
37
+ uris << uri if uri
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ uris.join(',')
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end