adiwg-mdtranslator 2.20.0.pre.beta.3 → 2.21.0.pre.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/Gemfile.lock +12 -10
  4. data/README.md +0 -21
  5. data/Rakefile +0 -1
  6. data/adiwg-mdtranslator.gemspec +2 -2
  7. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +45 -7
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dataQuality.rb +103 -59
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_acquisition.rb +133 -0
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_conformanceResult.rb +5 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coverageResult.rb +4 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataQuality.rb +7 -0
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_descriptiveResult.rb +4 -0
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_environment.rb +47 -0
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_event.rb +88 -0
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_instrument.rb +73 -0
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_instrumentationEvent.rb +77 -0
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_instrumentationEventList.rb +62 -0
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadata.rb +11 -0
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_objective.rb +104 -0
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_operation.rb +119 -0
  22. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_pass.rb +53 -0
  23. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_plan.rb +80 -0
  24. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_platform.rb +87 -0
  25. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_quantitativeResult.rb +4 -0
  26. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_requestedDate.rb +51 -0
  27. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_requirement.rb +98 -0
  28. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_revision.rb +50 -0
  29. data/lib/adiwg/mdtranslator/version.rb +1 -1
  30. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dataQuality.rb +101 -31
  31. data/lib/adiwg/mdtranslator/writers/html/sections/html_acquisition.rb +199 -0
  32. data/lib/adiwg/mdtranslator/writers/html/sections/html_body.rb +19 -0
  33. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQuality.rb +17 -1
  34. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataQualityReport.rb +28 -0
  35. data/lib/adiwg/mdtranslator/writers/html/sections/html_environment.rb +58 -0
  36. data/lib/adiwg/mdtranslator/writers/html/sections/html_event.rb +121 -0
  37. data/lib/adiwg/mdtranslator/writers/html/sections/html_instrument.rb +98 -0
  38. data/lib/adiwg/mdtranslator/writers/html/sections/html_instrumentationEvent.rb +84 -0
  39. data/lib/adiwg/mdtranslator/writers/html/sections/html_instrumentationEventList.rb +90 -0
  40. data/lib/adiwg/mdtranslator/writers/html/sections/html_objective.rb +155 -0
  41. data/lib/adiwg/mdtranslator/writers/html/sections/html_operation.rb +178 -0
  42. data/lib/adiwg/mdtranslator/writers/html/sections/html_pass.rb +72 -0
  43. data/lib/adiwg/mdtranslator/writers/html/sections/html_plan.rb +93 -0
  44. data/lib/adiwg/mdtranslator/writers/html/sections/html_platform.rb +117 -0
  45. data/lib/adiwg/mdtranslator/writers/html/sections/html_requestedDate.rb +33 -0
  46. data/lib/adiwg/mdtranslator/writers/html/sections/html_requirement.rb +139 -0
  47. data/lib/adiwg/mdtranslator/writers/html/sections/html_revision.rb +55 -0
  48. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataIdentification.rb +29 -0
  49. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataQualityReport.rb +1 -1
  50. data/lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_gcoDateTime.rb +10 -1
  51. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_acquisition.rb +42 -0
  52. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_conformanceResult.rb +6 -5
  53. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageResult.rb +1 -0
  54. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_descriptiveResult.rb +1 -0
  55. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_environment.rb +28 -0
  56. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_event.rb +37 -0
  57. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_instrument.rb +35 -0
  58. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_instrumentationEvent.rb +30 -0
  59. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_instrumentationEventList.rb +32 -0
  60. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +2 -0
  61. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_objective.rb +37 -0
  62. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +1 -1
  63. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_operation.rb +34 -0
  64. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_pass.rb +30 -0
  65. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_plan.rb +32 -0
  66. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_platform.rb +35 -0
  67. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_quantitativeResult.rb +6 -5
  68. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_requestedDate.rb +26 -0
  69. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_requirement.rb +36 -0
  70. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +1 -1
  71. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_revision.rb +28 -0
  72. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +9 -26
  73. data/lib/adiwg/mdtranslator/writers/simple_html/sections/html_dataQuality.rb +1 -1
  74. data/lib/adiwg/mdtranslator_cli.rb +1 -1
  75. metadata +48 -39
  76. data/DCAT-US.md +0 -67
  77. data/lib/adiwg/mdtranslator/writers/dcat_us/dcat_us_writer.rb +0 -98
  78. data/lib/adiwg/mdtranslator/writers/dcat_us/readme.md +0 -10
  79. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_level.rb +0 -55
  80. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_url.rb +0 -17
  81. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_accrualPeriodicity.rb +0 -45
  82. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_bureau_code.rb +0 -33
  83. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_contact_point.rb +0 -29
  84. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_dcat_us.rb +0 -104
  85. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by.rb +0 -29
  86. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by_type.rb +0 -33
  87. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_description.rb +0 -19
  88. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_distribution.rb +0 -59
  89. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_download_url.rb +0 -17
  90. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_identifier.rb +0 -29
  91. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_is_part_of.rb +0 -27
  92. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_issued.rb +0 -19
  93. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_keyword.rb +0 -19
  94. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_landing_page.rb +0 -27
  95. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_language.rb +0 -23
  96. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_license.rb +0 -18
  97. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_media_type.rb +0 -17
  98. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_modified.rb +0 -29
  99. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_primaryITInvestmentUII.rb +0 -19
  100. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_program_code.rb +0 -33
  101. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_publisher.rb +0 -74
  102. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_references.rb +0 -50
  103. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_rights.rb +0 -32
  104. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_spatial.rb +0 -32
  105. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_system_of_records.rb +0 -28
  106. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_temporal.rb +0 -40
  107. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_theme.rb +0 -28
  108. data/lib/adiwg/mdtranslator/writers/dcat_us/version.rb +0 -14
@@ -1,104 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,19 +0,0 @@
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
@@ -1,59 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,27 +0,0 @@
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
@@ -1,19 +0,0 @@
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
@@ -1,19 +0,0 @@
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
-
@@ -1,27 +0,0 @@
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
@@ -1,23 +0,0 @@
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
-
@@ -1,18 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,19 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,74 +0,0 @@
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
@@ -1,50 +0,0 @@
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