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,98 +0,0 @@
1
- require 'jbuilder'
2
- require_relative 'version'
3
- require_relative 'sections/dcat_us_dcat_us'
4
-
5
- module ADIWG
6
- module Mdtranslator
7
- module Writers
8
- module Dcat_us
9
-
10
- def self.startWriter(intObj, responseObj)
11
- # set the contact array for use by the writer
12
- @contacts = intObj[:contacts]
13
-
14
- # set output flag for null properties
15
- Jbuilder.ignore_nil(!responseObj[:writerShowTags])
16
-
17
- # set the format of the output file based on the writer specified
18
- responseObj[:writerOutputFormat] = 'json'
19
- responseObj[:writerVersion] = ADIWG::Mdtranslator::Writers::Dcat_us::VERSION
20
-
21
- # write the dcat_us metadata record
22
- metadata = Dcat_us.build(intObj, responseObj)
23
-
24
- # set writer pass to true if no messages
25
- # false or warning state will be set by writer code
26
- responseObj[:writerPass] = true if responseObj[:writerMessages].empty?
27
-
28
- # encode the metadata target as JSON
29
- metadata.target!
30
- end
31
-
32
- # find contact in contact array and return the contact hash
33
- def self.get_contact_by_index(contactIndex)
34
- if @contacts[contactIndex]
35
- return @contacts[contactIndex]
36
- end
37
- {}
38
- end
39
-
40
- # find contact in contact array and return the contact hash
41
- def self.get_contact_by_id(contactId)
42
- @contacts.each do |hContact|
43
- if hContact[:contactId] == contactId
44
- return hContact
45
- end
46
- end
47
- {}
48
- end
49
-
50
- # find contact in contact array and return the contact index
51
- def self.get_contact_index_by_id(contactId)
52
- @contacts.each_with_index do |hContact, index|
53
- if hContact[:contactId] == contactId
54
- return index
55
- end
56
- end
57
- {}
58
- end
59
-
60
- # ignore jBuilder object mapping when array is empty
61
- def self.json_map(collection = [], _class)
62
- if collection.nil? || collection.empty?
63
- return nil
64
- else
65
- collection.map { |item| _class.build(item).attributes! }
66
- end
67
- end
68
-
69
- # find all nested objects in 'obj' that contain the element 'ele'
70
- def self.nested_objs_by_element(obj, ele, excludeList = [])
71
- aCollected = []
72
- obj.each do |key, value|
73
- skipThisOne = false
74
- excludeList.each do |exclude|
75
- if key == exclude.to_sym
76
- skipThisOne = true
77
- end
78
- end
79
- next if skipThisOne
80
- if key == ele.to_sym
81
- aCollected << obj
82
- elsif obj.is_a?(Array)
83
- if key.respond_to?(:each)
84
- aReturn = nested_objs_by_element(key, ele, excludeList)
85
- aCollected = aCollected.concat(aReturn) unless aReturn.empty?
86
- end
87
- elsif obj[key].respond_to?(:each)
88
- aReturn = nested_objs_by_element(value, ele, excludeList)
89
- aCollected = aCollected.concat(aReturn) unless aReturn.empty?
90
- end
91
- end
92
- aCollected
93
- end
94
-
95
- end
96
- end
97
- end
98
- end
@@ -1,10 +0,0 @@
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
-
@@ -1,55 +0,0 @@
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
-
@@ -1,17 +0,0 @@
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
@@ -1,45 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -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
-