adiwg-mdtranslator 2.0.0rc11 → 2.0.0rc13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Rakefile +1 -0
  4. data/adiwg-mdtranslator.gemspec +2 -0
  5. data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +32 -18
  6. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +96 -96
  7. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb +35 -35
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_mdJson.rb +102 -105
  9. data/lib/adiwg/mdtranslator/readers/mdReaders.rb +49 -49
  10. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_additionalDocumentation.rb +0 -0
  11. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_boundingBox.rb +0 -0
  12. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_browseGraphic.rb +0 -0
  13. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_citation.rb +0 -0
  14. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_contacts.rb +0 -0
  15. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_dateTime.rb +0 -0
  16. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_distributionInfo.rb +0 -0
  17. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_extent.rb +0 -0
  18. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_geoCoordSystem.rb +0 -0
  19. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_geoProperties.rb +0 -0
  20. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_geographicElement.rb +0 -0
  21. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_metadata.rb +0 -0
  22. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_metadataInfo.rb +0 -0
  23. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_onlineResource.rb +0 -0
  24. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_resourceIdentifier.rb +0 -0
  25. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_resourceInfo.rb +0 -0
  26. data/lib/adiwg/mdtranslator/readers/sbJson/{modules_v0 → modules/Old}/module_responsibleParty.rb +0 -0
  27. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_body.rb +41 -0
  28. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_citation.rb +32 -0
  29. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_id.rb +35 -0
  30. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_identifier.rb +46 -0
  31. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_provenance.rb +59 -0
  32. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_purpose.rb +32 -0
  33. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_rights.rb +43 -0
  34. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +106 -0
  35. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_titles.rb +42 -0
  36. data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +56 -198
  37. data/lib/adiwg/mdtranslator/readers/sbJson/version.rb +14 -0
  38. data/lib/adiwg/mdtranslator/version.rb +3 -1
  39. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_codelist.rb +38 -38
  40. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_date.rb +1 -1
  41. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +1 -1
  42. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_abstract.rb +27 -0
  43. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +6 -6
  44. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +90 -12
  45. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +12 -4
  46. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_date.rb +4 -4
  47. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb +16 -17
  48. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_materialRequest.rb +6 -2
  49. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_provenance.rb +2 -18
  50. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_rights.rb +13 -0
  51. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +3 -2
  52. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_webLink.rb +23 -2
  53. metadata +59 -22
  54. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_sbJson.rb +0 -52
  55. data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/version.rb +0 -12
@@ -1,204 +1,62 @@
1
- require 'json'
2
-
3
- module ADIWG
4
- module Mdtranslator
5
- module Readers
6
- module SbJson
7
-
8
- def self.readFile(file, responseObj)
9
-
10
- # set reference to responseObj for use throughout this module
11
- @hResponseObj = responseObj
12
-
13
- # receive json file into ruby hash
14
- parseJson(file)
15
- if !@hResponseObj[:readerStructurePass]
16
- return false
17
- end
18
-
19
- # set format of file in $response
20
- @hResponseObj[:readerFormat] = 'json'
21
-
22
- # check sbJson version name
23
- checkVersionName
24
- if !@hResponseObj[:readerStructurePass]
25
- return false
26
- end
27
-
28
- # check sbJson version number
29
- checkVersionNumber
30
- if !@hResponseObj[:readerStructurePass]
31
- return false
32
- end
33
-
34
- #validate file against sbJson schema definition
35
- validate(file, @hResponseObj)
36
- if !@hResponseObj[:readerValidationPass]
37
- return false
38
- end
39
-
40
- # load sbJson file into internal object
41
- require readerModule('module_sbJson')
42
- # instance classes needed in script
43
- intMetadataClass = InternalMetadata.new
44
-
45
- # create new internal metadata container for the reader
46
- @intObj = intMetadataClass.newBase
47
-
48
- #
49
- ADIWG::Mdtranslator::Readers::SbJson.unpack(@intObj, @hSbJson, @hResponseObj)
50
- return @intObj
51
-
52
- end
53
-
54
- def self.parseJson(file)
55
- # validate the input file structure
56
- # test for valid json syntax by attempting to parse the file
57
- begin
58
- @hSbJson = JSON.parse(file)
59
-
60
- # faking the version since sbJSON has no support
61
- @hSbJson['version'] = {
62
- "name" => "sbJson",
63
- "version" => "0.0.0"
64
- }
65
-
66
- @hResponseObj[:readerStructurePass] = true
67
- rescue JSON::JSONError => err
68
- @hResponseObj[:readerStructurePass] = false
69
- @hResponseObj[:readerStructureMessages] << 'JSON Parsing Failed - see following message(s):\n'
70
- @hResponseObj[:readerStructureMessages] << err.to_s.slice(0, 300)
71
- end
72
- end
1
+ # mdJson reader - process and direct mdJson ingest to internal data structure
73
2
 
74
- def self.checkVersionName
75
- # find version name on the input json file
76
- if @hSbJson.has_key?('version')
77
- hVersion = @hSbJson['version']
78
- else
79
- @hResponseObj[:readerStructurePass] = false
80
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
81
- @hResponseObj[:readerStructureMessages] << 'The input file is missing the version:{} block.'
82
- return
83
- end
3
+ # History:
4
+ # Stan Smith 2016-06-12 refactor for mdTranslator 2.0
5
+ # Josh Bradley original script
84
6
 
85
- # check the version name
86
- if hVersion.has_key?('name')
87
- s = hVersion['name']
88
- if s.nil?
89
- @hResponseObj[:readerStructurePass] = false
90
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
91
- @hResponseObj[:readerStructureMessages] << 'The input file version: => name: is missing.'
92
- return
93
- end
94
- else
95
- @hResponseObj[:readerStructurePass] = false
96
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
97
- @hResponseObj[:readerStructureMessages] << "The input file version:{} block is missing the 'name:' attribute."
98
- return
99
- end
100
-
101
- # check the version name is 'sbJson'
102
- if s != 'sbJson'
103
- @hResponseObj[:readerStructurePass] = false
104
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
105
- @hResponseObj[:readerStructureMessages] << "The mdTranslator reader expected the input file version: name: to be 'sbJson'."
106
- @hResponseObj[:readerStructureMessages] << "Version name found was: '#{s}'."
107
- end
108
- end
109
-
110
- def self.checkVersionNumber
111
- # find version number on the input json file
112
- hVersion = @hSbJson['version']
113
- if hVersion.has_key?('version')
114
- s = hVersion['version']
115
- if !s.nil?
116
- @hResponseObj[:readerVersionRequested] = s
117
- end
118
- else
119
- @hResponseObj[:readerStructurePass] = false
120
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
121
- @hResponseObj[:readerStructureMessages] << "The input file version:{} block is missing the 'version:' number attribute."
122
- return
123
- end
124
-
125
- # split the version number into its parts
126
- aReqVersion = s.split('.')
127
-
128
- reqMajor = 0
129
- if !aReqVersion[0].nil?
130
- reqMajor = aReqVersion[0]
131
- end
132
-
133
- # test if the requested reader major version is supported
134
- # look for a folder with modules for the major version number
135
- dirName = File.join(File.dirname(__FILE__), 'modules_v' + reqMajor)
136
- if !File.directory?(dirName)
137
- @hResponseObj[:readerStructurePass] = false
138
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
139
- @hResponseObj[:readerStructureMessages] << 'A reader for the requested version is not supported.'
140
- @hResponseObj[:readerStructureMessages] << "sbJson version requested was '#{s}'"
141
- return false
142
- end
143
-
144
- # the requested major version is supported
145
- # get the full version number for this major version of sbJson
146
- require File.join(dirName, 'version')
147
- curVersion = ADIWG::Mdtranslator::Readers::SbJson::VERSION
148
- @hResponseObj[:readerVersionUsed] = curVersion
149
- aCurVersion = curVersion.split('.')
150
- curMinor = aCurVersion[1]
151
-
152
- # test that minor version number is not exceeded
153
- reqMinor = 0
154
- if !aReqVersion[1].nil?
155
- reqMinor = aReqVersion[1]
156
- if curMinor < reqMinor
157
- @hResponseObj[:readerStructurePass] = false
158
- @hResponseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
159
- @hResponseObj[:readerStructureMessages] << 'The requested reader minor version is not supported.'
160
- @hResponseObj[:readerStructureMessages] << "sbJson version requested was '#{s}'"
161
- return false
162
- end
163
- end
164
-
165
- end
166
-
167
- # find the array pointer for a contact
168
- def self.findContact(contactId)
169
- pointer = nil
170
- i = 0
171
- @intObj[:contacts].each do |contact|
172
- if contact[:contactId] == contactId
173
- pointer = i
174
- end
175
- i += 1
176
- end
177
-
178
- return pointer
179
- end
180
-
181
- # require modules for the requested version
182
- def self.readerModule(moduleName)
183
- majVersion = @hResponseObj[:readerVersionUsed].split('.')[0]
184
- dirName = File.join(File.dirname(__FILE__), 'modules_v' + majVersion.to_s)
185
- fileName = File.join(dirName, moduleName)
186
-
187
- # test for the existance of the module in the current sbJson version directory
188
- if !File.exist?(File.join(dirName, moduleName + '.rb'))
189
- # file not found
190
- # ... look for module in previous version directory
191
- # ... note: no previous version directories exist yet
192
-
193
- # no prior version directory found
194
- # ... file not found
195
- return nil
196
- end
7
+ require 'json'
8
+ require_relative 'version'
9
+ require_relative 'modules/module_sbJson'
197
10
 
198
- return fileName
199
- end
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Readers
14
+ module SbJson
15
+
16
+ def self.readFile(file, hResponseObj)
17
+
18
+ # receive json file into ruby hash
19
+ begin
20
+ hSbJson = JSON.parse(file)
21
+ rescue JSON::JSONError => err
22
+ hResponseObj[:readerStructurePass] = false
23
+ hResponseObj[:readerStructureMessages] << 'Parsing sbJson Failed - see following message(s):\n'
24
+ hResponseObj[:readerStructureMessages] << err.to_s.slice(0, 300)
25
+ return {}
26
+ end
27
+
28
+ # file must contain an mdJson object
29
+ if hSbJson.empty?
30
+ hResponseObj[:readerStructureMessages] << 'sbJson object is empty'
31
+ hResponseObj[:readerStructurePass] = false
32
+ return {}
33
+ end
34
+
35
+ # faking the version since sbJSON has no version support
36
+ hSbJson['schema'] = {
37
+ 'name' => 'sbJson',
38
+ 'version' => '0.0.0'
39
+ }
40
+
41
+ # schema - current version
42
+ currentVersion = ADIWG::Mdtranslator::Readers::SbJson::VERSION
43
+ hResponseObj[:readerVersionRequested] = hSbJson['schema']['version']
44
+ hResponseObj[:readerVersionUsed] = currentVersion
45
+ unless currentVersion == hSbJson['schema']['version']
46
+ hResponseObj[:readerStructureMessages] << "sbJson schema version '#{hSbJson['version']}' is not supported"
47
+ hResponseObj[:readerStructurePass] = false
48
+ return {}
49
+ end
50
+
51
+ # faking the validation since there is no schema definition
52
+ # @hResponseObj[:readerValidationPass] default is true
53
+
54
+ # load sbJson file into internal object
55
+ return SbJson.unpack(hSbJson, hResponseObj)
200
56
 
201
57
  end
202
- end
203
- end
58
+
59
+ end
60
+ end
61
+ end
204
62
  end
@@ -0,0 +1,14 @@
1
+ # adiwg mdTranslator / readers / sbJson
2
+
3
+ # version 0 history
4
+ # 0.0.0 2016-10-01 start of version 0
5
+
6
+ module ADIWG
7
+ module Mdtranslator
8
+ module Readers
9
+ module SbJson
10
+ VERSION = '0.0.0'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,6 +1,8 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.0.0rc13 2017-06-16 apply changes to sbJson writer after fourth review session
5
+ # 2.0.0rc12 2017-06-14 apply changes to sbJson writer after third review session
4
6
  # 2.0.0rc11 2017-06-08 apply changes to sbJson writer after second review session
5
7
  # 2.0.0rc10 2017-06-05 apply changes to sbJson writer after review
6
8
  # 2.0.0rc9 2017-05-26 allow choice of which dictionary to translate
@@ -18,7 +20,7 @@
18
20
  module ADIWG
19
21
  module Mdtranslator
20
22
  # current mdtranslator version
21
- VERSION = "2.0.0rc11"
23
+ VERSION = "2.0.0rc13"
22
24
  end
23
25
  end
24
26
 
@@ -2,56 +2,56 @@
2
2
 
3
3
  # from http://mdtranslator.adiwg.org/api/codelists?format=xml
4
4
  # History:
5
- # Stan Smith 2016-11-19 refactored for mdTranslator/mdJson 2.0
6
- # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
- # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
9
- # Stan Smith 2015-06-11 refactored to use mdCodes gem for codelist contents
10
- # Stan Smith 2014-12-15 replaced NOAA CT_CodelistCatalogue with mdTranslator CT_CodelistCatalogue
11
- # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
- # Stan Smith 2014-10-15 allow non-ISO codesNames to be rendered
5
+ # Stan Smith 2016-11-19 refactored for mdTranslator/mdJson 2.0
6
+ # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
+ # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
9
+ # Stan Smith 2015-06-11 refactored to use mdCodes gem for codelist contents
10
+ # Stan Smith 2014-12-15 replaced NOAA CT_CodelistCatalogue with mdTranslator CT_CodelistCatalogue
11
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-10-15 allow non-ISO codesNames to be rendered
13
13
  # Stan Smith 2013-08-09 original script
14
14
 
15
15
  require 'adiwg-mdcodes'
16
16
 
17
17
  module ADIWG
18
- module Mdtranslator
19
- module Writers
20
- module Iso19115_2
18
+ module Mdtranslator
19
+ module Writers
20
+ module Iso19115_2
21
21
 
22
- class MD_Codelist
22
+ class MD_Codelist
23
23
 
24
- def initialize(xml, hResponseObj)
25
- @xml = xml
26
- @hResponseObj = hResponseObj
27
- end
24
+ def initialize(xml, hResponseObj)
25
+ @xml = xml
26
+ @hResponseObj = hResponseObj
27
+ end
28
28
 
29
- def writeXML(codeSpace, codeList, codeName)
29
+ def writeXML(codeSpace, codeList, codeName)
30
30
 
31
- # get requested codelist from the adiwg-mdcodes gem
32
- mdCodelist = ADIWG::Mdcodes.getCodelistDetail(codeList, @hResponseObj)
31
+ # get requested codelist from the adiwg-mdcodes gem
32
+ mdCodelist = ADIWG::Mdcodes.getCodelistDetail(codeList, 'hash')
33
33
 
34
- sourceName = mdCodelist['sourceName']
35
- codelist = mdCodelist['codelist']
36
- codeId = 'userCode'
34
+ sourceName = mdCodelist['sourceName']
35
+ codelist = mdCodelist['codelist']
36
+ codeId = 'userCode'
37
37
 
38
- # search the codelist for a matching codeName
39
- codelist.each do |code|
40
- if code['codeName'] == codeName
41
- codeId = code['code']
42
- break
43
- end
44
- end
38
+ # search the codelist for a matching codeName
39
+ codelist.each do |code|
40
+ if code['codeName'] == codeName
41
+ codeId = code['code']
42
+ break
43
+ end
44
+ end
45
45
 
46
- # generate the iso code block
47
- @xml.tag!(codeSpace + ':' + "#{sourceName}", {:codeList => 'http://mdtranslator.adiwg.org/api/codelists?format=xml#' + "#{sourceName}",
48
- :codeListValue => "#{codeName}",
49
- :codeSpace => "#{codeId}"})
50
- end
51
-
52
- end
46
+ # generate the iso code block
47
+ @xml.tag!(codeSpace + ':' + "#{sourceName}", {:codeList => 'http://mdtranslator.adiwg.org/api/codelists?format=xml#' + "#{sourceName}",
48
+ :codeListValue => "#{codeName}",
49
+ :codeSpace => "#{codeId}"})
50
+ end
53
51
 
54
52
  end
55
- end
56
- end
53
+
54
+ end
55
+ end
56
+ end
57
57
  end
@@ -16,7 +16,7 @@ module ADIWG
16
16
  def self.build(hDate)
17
17
 
18
18
  Jbuilder.new do |json|
19
- json.date(AdiwgDateTimeFun.stringFromDateObject(hDate))
19
+ json.date(AdiwgDateTimeFun.stringDateTimeFromDateObject(hDate))
20
20
  json.dateType hDate[:dateType]
21
21
  end
22
22
 
@@ -14,7 +14,7 @@ module ADIWG
14
14
 
15
15
  def self.build(hDateTime)
16
16
 
17
- return AdiwgDateTimeFun.stringFromDateObject(hDateTime)
17
+ return AdiwgDateTimeFun.stringDateTimeFromDateObject(hDateTime)
18
18
 
19
19
  end # build
20
20
  end # DateTime
@@ -0,0 +1,27 @@
1
+ # sbJson 1.0 writer
2
+
3
+ # History:
4
+ # Stan Smith 2017-06-16 original script
5
+
6
+ require 'kramdown'
7
+
8
+ module ADIWG
9
+ module Mdtranslator
10
+ module Writers
11
+ module SbJson
12
+
13
+ module Abstract
14
+
15
+ def self.build(abstract)
16
+
17
+ abstract = Kramdown::Document.new(abstract).to_html
18
+ abstract.gsub!(/\n/, '')
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,6 +3,7 @@
3
3
  # History:
4
4
  # Stan Smith 2017-05-16 original script
5
5
 
6
+ require 'adiwg/mdtranslator/internal/module_dateTimeFun'
6
7
  require_relative 'sbJson_codelists'
7
8
 
8
9
  module ADIWG
@@ -20,7 +21,6 @@ module ADIWG
20
21
  def self.build(hCitation)
21
22
 
22
23
  citation = ''
23
- role = ''
24
24
 
25
25
  # names
26
26
  aIndexes = []
@@ -44,18 +44,18 @@ module ADIWG
44
44
  hContact = ADIWG::Mdtranslator::Writers::SbJson.get_contact_by_index(hIndex[:index])
45
45
  unless hContact.empty?
46
46
  unless hContact[:name].nil?
47
- citation += hContact[:name] + '(' + hIndex[:role] + '), '
47
+ sbRole = Codelists.codelist_iso_to_sb('iso_sb_role', :isoCode => hIndex[:role])
48
+ sbRole = sbRole.nil? ? hIndex[:role] : sbRole
49
+ citation += hContact[:name] + '(' + sbRole + '), '
48
50
  end
49
51
  end
50
52
  end
51
53
 
52
54
  # dates
53
55
  hCitation[:dates].each do |hDate|
54
- dateStr = AdiwgDateTimeFun.stringFromDateObject(hDate)
56
+ dateStr = AdiwgDateTimeFun.stringDateFromDateObject(hDate)
55
57
  dateType = Codelists.codelist_iso_to_sb('iso_sb_date', :isoCode => hDate[:dateType])
56
- if dateType.nil?
57
- citation += dateStr + ', '
58
- else
58
+ unless dateType.nil?
59
59
  citation += dateStr + '(' + dateType + '), '
60
60
  end
61
61
  end
@@ -3,6 +3,8 @@
3
3
  # History:
4
4
  # Stan Smith 2017-05-26 original script
5
5
 
6
+ require 'adiwg-mdcodes'
7
+
6
8
  module ADIWG
7
9
  module Mdtranslator
8
10
  module Writers
@@ -13,41 +15,92 @@ module ADIWG
13
15
  @iso_sb_role = [
14
16
  {iso: 'resourceProvider', sb: 'Resource Provider'},
15
17
  {iso: 'custodian', sb: 'Custodian'},
16
- {iso: 'rightsHolder', sb: 'Data Owner'},
18
+ {iso: 'owner', sb: 'Data Owner'},
17
19
  {iso: 'use', sb: 'User'},
18
20
  {iso: 'distributor', sb: 'Distributor'},
19
21
  {iso: 'originator', sb: 'Originator'},
20
22
  {iso: 'pointOfContact', sb: 'Point of Contact'},
21
23
  {iso: 'principalInvestigator', sb: 'Principal Investigator'},
22
24
  {iso: 'processor', sb: 'Processor'},
25
+ {iso: 'publisher', sb: 'publisher'},
23
26
  {iso: 'author', sb: 'Author'},
27
+ {iso: 'sponsor', sb: 'sponsor'},
24
28
  {iso: 'coAuthor', sb: 'Author'},
25
29
  {iso: 'collaborator', sb: 'Cooperator/Partner'},
26
- {iso: 'contributor', sb: 'Cooperator/Partner'},
27
30
  {iso: 'editor', sb: 'Editor'},
28
- {iso: 'coPrincipalInvestigator', sb: 'Co-Investigator'},
29
- {iso: 'publisher', sb: 'publisher'},
30
- {iso: 'sponsor', sb: 'sponsor'},
31
+ {iso: 'mediator', sb: 'mediator'},
32
+ {iso: 'rightsHolder', sb: 'Data Owner'},
33
+ {iso: 'contributor', sb: 'Cooperator/Partner'},
34
+ {iso: 'contributor', sb: 'Cooperator/Partner'},
35
+ {iso: 'funder', sb: 'funder'},
31
36
  {iso: 'stakeholder', sb: 'stakeholder'},
32
37
  {iso: 'administrator', sb: 'administrator'},
33
38
  {iso: 'client', sb: 'client'},
34
39
  {iso: 'logistics', sb: 'logistics'},
35
- {iso: 'mediator', sb: 'mediator'}
40
+ {iso: 'coPrincipalInvestigator', sb: 'Co-Investigator'},
41
+ {iso: nil, sb: 'Associate Project Chief'},
42
+ {iso: nil, sb: 'Contact'},
43
+ {iso: nil, sb: 'Data Provider'},
44
+ {iso: nil, sb: 'Funding Agency'},
45
+ {iso: nil, sb: 'Lead Organization'},
46
+ {iso: nil, sb: 'Material Request Contact'},
47
+ {iso: nil, sb: 'Metadata Contact'},
48
+ {iso: nil, sb: 'Participant'},
49
+ {iso: nil, sb: 'Photographer'},
50
+ {iso: nil, sb: 'Process Contact'},
51
+ {iso: nil, sb: 'Project Chief'},
52
+ {iso: nil, sb: 'Project Team'},
53
+ {iso: nil, sb: 'Referred By'},
54
+ {iso: nil, sb: 'Report Prepared By'},
55
+ {iso: nil, sb: 'SoftwareEngineer'},
56
+ {iso: nil, sb: 'Subtask Leader'},
57
+ {iso: nil, sb: 'Supporter'},
58
+ {iso: nil, sb: 'Task Leader'},
59
+ {iso: nil, sb: 'Transmitted'},
60
+ {iso: nil, sb: 'User'},
61
+ {iso: nil, sb: 'USGS Mission Area'},
62
+ {iso: nil, sb: 'USGS Program'}
36
63
  ]
37
64
 
38
65
  @iso_sb_onlineFunction = [
39
- {iso: 'information', sb: 'webLink'},
40
- {iso: 'completeMetadata', sb: 'originalMetadata'},
41
- {iso: 'browseGraphic', sb: 'browseImage'},
42
- {iso: 'webApplication', sb: 'webapp'},
43
66
  {iso: 'download', sb: 'download'},
67
+ {iso: 'information', sb: 'webLink'},
44
68
  {iso: 'offlineAccess', sb: 'offlineAccess'},
45
69
  {iso: 'order', sb: 'order'},
46
70
  {iso: 'search', sb: 'search'},
71
+ {iso: 'completeMetadata', sb: 'originalMetadata'},
72
+ {iso: 'browseGraphic', sb: 'browseImage'},
47
73
  {iso: 'upload', sb: 'upload'},
48
74
  {iso: 'emailService', sb: 'emailService'},
49
75
  {iso: 'browsing', sb: 'browsing'},
50
- {iso: 'fileAccess', sb: 'fileAccess'}
76
+ {iso: 'fileAccess', sb: 'fileAccess'},
77
+ {iso: 'webApplication', sb: 'webapp'},
78
+ {iso: 'doi', sb: nil},
79
+ {iso: 'orcid', sb: nil},
80
+ {iso: 'dataUri', sb: nil},
81
+ {iso: nil, sb: 'arcgis'},
82
+ {iso: nil, sb: 'citation'},
83
+ {iso: nil, sb: 'configFile'},
84
+ {iso: nil, sb: 'kml'},
85
+ {iso: nil, sb: 'mapapp'},
86
+ {iso: nil, sb: 'method'},
87
+ {iso: nil, sb: 'oia-pmh'},
88
+ {iso: nil, sb: 'dpf'},
89
+ {iso: nil, sb: 'publicationReferenceSouce'},
90
+ {iso: nil, sb: 'repo'},
91
+ {iso: nil, sb: 'serviceCapabilitiesUri'},
92
+ {iso: nil, sb: 'serviceFeatureInfoUri'},
93
+ {iso: nil, sb: 'serviceLegendUri'},
94
+ {iso: nil, sb: 'serviceLink'},
95
+ {iso: nil, sb: 'serviceMapUri'},
96
+ {iso: nil, sb: 'serviceWfsBackingUri'},
97
+ {iso: nil, sb: 'siteMap'},
98
+ {iso: nil, sb: 'sourceCode'},
99
+ {iso: nil, sb: 'txt'},
100
+ {iso: nil, sb: 'WAF'},
101
+ {iso: nil, sb: 'xls'},
102
+ {iso: nil, sb: 'zip'}
103
+
51
104
  ]
52
105
 
53
106
  @iso_sb_scope = [
@@ -153,7 +206,8 @@ module ADIWG
153
206
  {iso: 'suspended', sb: nil}
154
207
  ]
155
208
 
156
- def self.codelist_iso_to_sb(codelist, isoCode: nil, sbCode: nil)
209
+ # translate iso/adiwg code to sb
210
+ def self.codelist_iso_to_sb(codelist, isoCode: nil, sbCode: nil)
157
211
 
158
212
  codeList = instance_variable_get("@#{codelist}")
159
213
 
@@ -178,6 +232,30 @@ module ADIWG
178
232
 
179
233
  end
180
234
 
235
+ # test if provided code is a valid sb code
236
+ def self.is_sb_code(codelist, sbCode)
237
+ codeList = instance_variable_get("@#{codelist}")
238
+ unless sbCode.nil?
239
+ codeList.each do |obj|
240
+ if obj[:sb] == sbCode
241
+ return true
242
+ end
243
+ end
244
+ end
245
+ return false
246
+ end
247
+
248
+ # get requested codelist from the adiwg-mdcodes gem
249
+ def self.get_code_definition(codeList, code)
250
+ hCodelist = ADIWG::Mdcodes.getCodelistDetail(codeList, @hResponseObj)
251
+ hCodelist['codelist'].each do |item|
252
+ if item['codeName'] == code
253
+ return item['description']
254
+ end
255
+ end
256
+ return nil
257
+ end
258
+
181
259
  end
182
260
 
183
261
  end