adiwg-mdtranslator 2.19.0.pre.beta.25 → 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 (62) 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 +41 -31
  5. data/README.md +21 -0
  6. data/Rakefile +1 -0
  7. data/adiwg-mdtranslator.gemspec +2 -2
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dataQuality.rb +59 -103
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_conformanceResult.rb +0 -5
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coverageResult.rb +0 -4
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataQuality.rb +0 -7
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_descriptiveResult.rb +0 -4
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_quantitativeResult.rb +0 -4
  14. data/lib/adiwg/mdtranslator/version.rb +1 -1
  15. data/lib/adiwg/mdtranslator/writers/dcat_us/dcat_us_writer.rb +98 -0
  16. data/lib/adiwg/mdtranslator/writers/dcat_us/readme.md +10 -0
  17. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_level.rb +55 -0
  18. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_url.rb +17 -0
  19. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_accrualPeriodicity.rb +45 -0
  20. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_bureau_code.rb +33 -0
  21. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_contact_point.rb +29 -0
  22. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_dcat_us.rb +104 -0
  23. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by.rb +29 -0
  24. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by_type.rb +33 -0
  25. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_description.rb +19 -0
  26. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_distribution.rb +59 -0
  27. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_download_url.rb +17 -0
  28. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_identifier.rb +29 -0
  29. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_is_part_of.rb +27 -0
  30. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_issued.rb +19 -0
  31. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_keyword.rb +19 -0
  32. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_landing_page.rb +27 -0
  33. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_language.rb +23 -0
  34. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_license.rb +18 -0
  35. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_media_type.rb +17 -0
  36. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_modified.rb +29 -0
  37. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_primaryITInvestmentUII.rb +19 -0
  38. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_program_code.rb +33 -0
  39. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_publisher.rb +74 -0
  40. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_references.rb +50 -0
  41. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_rights.rb +32 -0
  42. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_spatial.rb +32 -0
  43. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_system_of_records.rb +28 -0
  44. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_temporal.rb +40 -0
  45. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_theme.rb +28 -0
  46. data/lib/adiwg/mdtranslator/writers/dcat_us/version.rb +14 -0
  47. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dataQuality.rb +31 -101
  48. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQuality.rb +1 -17
  49. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQualityReport.rb +0 -28
  50. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataIdentification.rb +0 -29
  51. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataQualityReport.rb +1 -1
  52. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_gcoDateTime.rb +1 -10
  53. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_conformanceResult.rb +5 -6
  54. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageResult.rb +0 -1
  55. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_descriptiveResult.rb +0 -1
  56. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +1 -1
  57. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_quantitativeResult.rb +5 -6
  58. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +1 -1
  59. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +26 -9
  60. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_dataQuality.rb +1 -1
  61. data/lib/adiwg/mdtranslator_cli.rb +1 -1
  62. metadata +39 -6
@@ -0,0 +1,10 @@
1
+
2
+ ## dcat_us
3
+
4
+ ### Supported versions
5
+
6
+ > 0.0.x (dcat_us is not currently versioned)
7
+
8
+ ### Writer for Data Catalog Vocabulary (DCAT) v1.1
9
+
10
+
@@ -0,0 +1,55 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module AccessLevel
8
+
9
+ def self.build(intObj)
10
+
11
+ publicArray = ['unclassified', 'unrestricted', 'licenseUnrestricted', 'licenseEndUser']
12
+ nonPublicArray = ['restricted','confidential','secret','topSecret','forOfficialUseOnly','protected','intellectualPropertyRights','restricted','otherRestrictions','private','statutory','confidential','traditionalKnowledge','personallyIdentifiableInformation']
13
+ restrictedPublicArray = ['sensitiveButUnclassified','limitedDistribution','copyright','patent','patentPending','trademark','license','licenseDistributor','in-confidence','threatenedOrEndangered']
14
+
15
+ resourceInfo = intObj[:metadata][:resourceInfo]
16
+ legalConstraints = resourceInfo[:constraints]&.select { |constraint| constraint[:type] == 'legal' }
17
+ securityConstraints = resourceInfo[:constraints]&.select { |constraint| constraint[:type] == 'security' }
18
+
19
+ accessLevelCodes = []
20
+
21
+ # Gather codes from security constraints and legal constraints
22
+ unless securityConstraints.empty?
23
+ securityConstraints.each do |securityConstraint|
24
+ code = securityConstraint[:securityConstraint][:classCode]
25
+ accessLevelCodes << code
26
+ end
27
+ end
28
+ unless legalConstraints.empty?
29
+ legalConstraints.each do |legalConstraint|
30
+ codes = legalConstraint.dig(:legalConstraint, :accessCodes)
31
+ accessLevelCodes.push(*codes)
32
+ end
33
+ end
34
+
35
+ # return access level that is most restrictive
36
+ accessLevelCodes.uniq.each do |code|
37
+ if nonPublicArray.include? code
38
+ return 'non-public'
39
+ end
40
+ end
41
+ accessLevelCodes.uniq.each do |code|
42
+ if restrictedPublicArray.include? code
43
+ return 'restricted public'
44
+ end
45
+ end
46
+
47
+ return 'public'
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,17 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module AccessURL
8
+
9
+ def self.build(option)
10
+ option[:olResURI] if option[:olResURI].end_with?('.html')
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module AccrualPeriodicity
8
+
9
+ def self.build(intObj)
10
+
11
+ frequency_mapping = {
12
+ 'decennial' => 'R/P10Y',
13
+ 'quadrennial' => 'R/P4Y',
14
+ 'annual' => 'R/P1Y',
15
+ 'bimonthly' => 'R/P2M or R/P0.5M',
16
+ 'semiweekly' => 'R/P3.5D',
17
+ 'daily' => 'R/P1D',
18
+ 'biweekly' => 'R/P2W or R/P0.5W',
19
+ 'semiannual' => 'R/P6M',
20
+ 'biennial' => 'R/P2Y',
21
+ 'triennial' => 'R/P3Y',
22
+ 'three times a week' => 'R/P0.33W',
23
+ 'three times a month' => 'R/P0.33M',
24
+ 'continuously updated' => 'R/PT1S',
25
+ 'monthly' => 'R/P1M',
26
+ 'quarterly' => 'R/P3M',
27
+ 'semimonthly' => 'R/P0.5M',
28
+ 'three times a year' => 'R/P4M',
29
+ 'weekly' => 'R/P1W',
30
+ 'hourly' => 'R/PT1H'
31
+ }
32
+
33
+ frequency = intObj[:metadata][:metadataInfo][:metadataMaintenance][:frequency]
34
+
35
+ unless frequency.nil?
36
+ frequency_code = frequency_mapping[frequency.downcase]
37
+ end
38
+ return frequency_code
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,33 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module BureauCode
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
+ bureauContacts = contacts&.select { |contact| contact[:externalIdentifier].any? { |id| id[:namespace] == 'bureauCode'} }
19
+
20
+ bureauCodes = []
21
+ bureauContacts.each do |contact|
22
+ bureauCode = contact[:externalIdentifier].find { |id| id[:namespace] == 'bureauCode' }
23
+ bureauCodes << bureauCode[:identifier]
24
+ end
25
+
26
+ return bureauCodes
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ require 'jbuilder'
2
+
3
+ module ADIWG
4
+ module Mdtranslator
5
+ module Writers
6
+ module Dcat_us
7
+ module ContactPoint
8
+
9
+ def self.build(intObj)
10
+ resourceInfo = intObj[:metadata][:resourceInfo]
11
+ pointOfContact = resourceInfo[:pointOfContacts][0]
12
+ contactId = pointOfContact[:parties][0][:contactId]
13
+
14
+ contact = Dcat_us.get_contact_by_id(contactId)
15
+ fn = contact[:name]
16
+ hasEmail = contact[:eMailList][0]
17
+
18
+ Jbuilder.new do |json|
19
+ json.set!('@type', 'vcard:Contact')
20
+ json.set!('fn', fn)
21
+ json.set!('hasEmail', hasEmail)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -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