adiwg-mdtranslator 2.20.0.pre.beta.5 → 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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/Gemfile.lock +3 -3
  4. data/README.md +0 -21
  5. data/Rakefile +0 -1
  6. data/adiwg-mdtranslator.gemspec +1 -1
  7. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +45 -7
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_acquisition.rb +133 -0
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_environment.rb +47 -0
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_event.rb +88 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_instrument.rb +73 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_instrumentationEvent.rb +77 -0
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_instrumentationEventList.rb +62 -0
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadata.rb +11 -0
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_objective.rb +104 -0
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_operation.rb +119 -0
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_pass.rb +53 -0
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_plan.rb +80 -0
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_platform.rb +87 -0
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_requestedDate.rb +51 -0
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_requirement.rb +98 -0
  22. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_revision.rb +50 -0
  23. data/lib/adiwg/mdtranslator/version.rb +1 -1
  24. data/lib/adiwg/mdtranslator/writers/html/sections/html_acquisition.rb +199 -0
  25. data/lib/adiwg/mdtranslator/writers/html/sections/html_body.rb +19 -0
  26. data/lib/adiwg/mdtranslator/writers/html/sections/html_environment.rb +58 -0
  27. data/lib/adiwg/mdtranslator/writers/html/sections/html_event.rb +121 -0
  28. data/lib/adiwg/mdtranslator/writers/html/sections/html_instrument.rb +98 -0
  29. data/lib/adiwg/mdtranslator/writers/html/sections/html_instrumentationEvent.rb +84 -0
  30. data/lib/adiwg/mdtranslator/writers/html/sections/html_instrumentationEventList.rb +90 -0
  31. data/lib/adiwg/mdtranslator/writers/html/sections/html_objective.rb +155 -0
  32. data/lib/adiwg/mdtranslator/writers/html/sections/html_operation.rb +178 -0
  33. data/lib/adiwg/mdtranslator/writers/html/sections/html_pass.rb +72 -0
  34. data/lib/adiwg/mdtranslator/writers/html/sections/html_plan.rb +93 -0
  35. data/lib/adiwg/mdtranslator/writers/html/sections/html_platform.rb +117 -0
  36. data/lib/adiwg/mdtranslator/writers/html/sections/html_requestedDate.rb +33 -0
  37. data/lib/adiwg/mdtranslator/writers/html/sections/html_requirement.rb +139 -0
  38. data/lib/adiwg/mdtranslator/writers/html/sections/html_revision.rb +55 -0
  39. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_acquisition.rb +42 -0
  40. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_environment.rb +28 -0
  41. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_event.rb +37 -0
  42. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_instrument.rb +35 -0
  43. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_instrumentationEvent.rb +30 -0
  44. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_instrumentationEventList.rb +32 -0
  45. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +2 -0
  46. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_objective.rb +37 -0
  47. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_operation.rb +34 -0
  48. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_pass.rb +30 -0
  49. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_plan.rb +32 -0
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_platform.rb +35 -0
  51. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_requestedDate.rb +26 -0
  52. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_requirement.rb +36 -0
  53. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_revision.rb +28 -0
  54. data/lib/adiwg/mdtranslator_cli.rb +1 -1
  55. metadata +45 -36
  56. data/DCAT-US.md +0 -67
  57. data/lib/adiwg/mdtranslator/writers/dcat_us/dcat_us_writer.rb +0 -98
  58. data/lib/adiwg/mdtranslator/writers/dcat_us/readme.md +0 -10
  59. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_level.rb +0 -55
  60. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_access_url.rb +0 -17
  61. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_accrualPeriodicity.rb +0 -45
  62. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_bureau_code.rb +0 -33
  63. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_contact_point.rb +0 -29
  64. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_dcat_us.rb +0 -104
  65. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by.rb +0 -29
  66. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_described_by_type.rb +0 -33
  67. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_description.rb +0 -19
  68. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_distribution.rb +0 -59
  69. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_download_url.rb +0 -17
  70. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_identifier.rb +0 -29
  71. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_is_part_of.rb +0 -27
  72. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_issued.rb +0 -19
  73. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_keyword.rb +0 -19
  74. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_landing_page.rb +0 -27
  75. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_language.rb +0 -23
  76. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_license.rb +0 -18
  77. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_media_type.rb +0 -17
  78. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_modified.rb +0 -29
  79. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_primaryITInvestmentUII.rb +0 -19
  80. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_program_code.rb +0 -33
  81. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_publisher.rb +0 -74
  82. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_references.rb +0 -50
  83. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_rights.rb +0 -32
  84. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_spatial.rb +0 -32
  85. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_system_of_records.rb +0 -28
  86. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_temporal.rb +0 -40
  87. data/lib/adiwg/mdtranslator/writers/dcat_us/sections/dcat_us_theme.rb +0 -28
  88. data/lib/adiwg/mdtranslator/writers/dcat_us/version.rb +0 -14
@@ -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
@@ -1,32 +0,0 @@
1
- module ADIWG
2
- module Mdtranslator
3
- module Writers
4
- module Dcat_us
5
- module Rights
6
-
7
- def self.build(intObj, accessLevel)
8
- resourceInfo = intObj.dig(:metadata, :resourceInfo)
9
- constraints = resourceInfo&.dig(:constraints)
10
-
11
- if accessLevel && ["restricted public", "non-public"].include?(accessLevel)
12
- constraints&.each do |constraint|
13
- if constraint[:type] == "use"
14
- statement = constraint.dig(:releasability, :statement)
15
- disseminationConstraints = constraint.dig(:releasability, :disseminationConstraint)
16
-
17
- if statement && disseminationConstraints
18
- combinedConstraints = disseminationConstraints.join(" ")
19
- return "#{statement} #{combinedConstraints}".strip
20
- end
21
- end
22
- end
23
- end
24
-
25
- nil
26
- end
27
-
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,32 +0,0 @@
1
- module ADIWG
2
- module Mdtranslator
3
- module Writers
4
- module Dcat_us
5
- module Spatial
6
-
7
- def self.build(intObj)
8
- resourceInfo = intObj.dig(:metadata, :resourceInfo)
9
- extent = resourceInfo&.dig(:extents, 0)
10
- geographicExtent = extent&.dig(:geographicExtents, 0)
11
- boundingBox = geographicExtent&.dig(:boundingBox)
12
-
13
- if boundingBox
14
- return [
15
- boundingBox[:eastLongitude],
16
- boundingBox[:southLatitude],
17
- boundingBox[:westLongitude],
18
- boundingBox[:northLatitude]
19
- ].join(',')
20
- elsif geographicExtent&.dig(:geographicElement, 0, :type) == 'point'
21
- point = geographicExtent.dig(:geographicElement, 0, :coordinate)
22
- return "#{point[1]},#{point[0]}" if point&.length == 2
23
- end
24
-
25
- nil
26
- end
27
-
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,28 +0,0 @@
1
- require 'jbuilder'
2
-
3
- module ADIWG
4
- module Mdtranslator
5
- module Writers
6
- module Dcat_us
7
- module SystemOfRecords
8
-
9
- def self.build(intObj)
10
- associatedResources = intObj.dig(:metadata, :associatedResources)
11
-
12
- return nil if associatedResources.nil?
13
-
14
- associatedResources.each do |resource|
15
- if resource[:initiativeType] == 'sorn'
16
- onlineResources = resource.dig(:resourceCitation, :onlineResources)
17
- return onlineResources.first[:olResURI] if onlineResources&.first&.has_key?(:olResURI)
18
- end
19
- end
20
-
21
- return nil
22
- end
23
-
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,40 +0,0 @@
1
- module ADIWG
2
- module Mdtranslator
3
- module Writers
4
- module Dcat_us
5
- module Temporal
6
-
7
- def self.build(intObj)
8
- resourceInfo = intObj.dig(:metadata, :resourceInfo)
9
- extent = resourceInfo&.dig(:extents, 0)
10
- temporalExtents = extent&.dig(:temporalExtents)
11
-
12
- if temporalExtents
13
- temporalExtents.each do |temporalExtent|
14
- timePeriod = temporalExtent&.dig(:timePeriod)
15
- next unless timePeriod
16
-
17
- startDateHash = timePeriod[:startDateTime]
18
- endDateHash = timePeriod[:endDateTime]
19
-
20
- startDate = startDateHash&.dig(:dateTime)
21
- endDate = endDateHash&.dig(:dateTime)
22
-
23
- if startDate && endDate
24
- return "#{startDate}/#{endDate}"
25
- elsif startDate
26
- return startDate
27
- elsif endDate
28
- return endDate
29
- end
30
- end
31
- end
32
-
33
- nil
34
- end
35
-
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,28 +0,0 @@
1
- require 'jbuilder'
2
-
3
- module ADIWG
4
- module Mdtranslator
5
- module Writers
6
- module Dcat_us
7
- module Theme
8
-
9
- def self.build(intObj)
10
- resourceInfo = intObj[:metadata][:resourceInfo]
11
- keywords_str = []
12
-
13
- resourceInfo[:keywords].each do |keyword_group|
14
- if keyword_group[:thesaurus][:title] == "ISO Topic Categories"
15
- keyword_group[:keywords].each do |keyword_obj|
16
- keywords_str << keyword_obj[:keyword]
17
- end
18
- end
19
- end
20
-
21
- return keywords_str.join(" ")
22
- end
23
-
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,14 +0,0 @@
1
- # dcat_us version history
2
- # Johnathan Aspinwall 2023-06-22 created for mdJson/mdTranslator 2.0
3
-
4
- module ADIWG
5
- module Mdtranslator
6
- module Writers
7
- module Dcat_us
8
-
9
- VERSION = '1.0.0'
10
-
11
- end
12
- end
13
- end
14
- end