adiwg-mdtranslator 2.0.0rc13 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_browseCategory.rb +47 -0
  3. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_budget.rb +79 -0
  4. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_contact.rb +248 -0
  5. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_date.rb +49 -0
  6. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_extent.rb +62 -0
  7. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_id.rb +10 -3
  8. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_identifier.rb +17 -15
  9. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_materialRequest.rb +72 -0
  10. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_parentId.rb +44 -0
  11. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_project.rb +48 -0
  12. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_publication.rb +77 -0
  13. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +90 -7
  14. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_spatial.rb +56 -0
  15. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_tag.rb +125 -0
  16. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkDocument.rb +99 -0
  17. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkGraphic.rb +92 -0
  18. data/lib/adiwg/mdtranslator/version.rb +2 -1
  19. data/lib/adiwg/mdtranslator/writers/html/sections/html_bodyScript.js +6 -1
  20. data/lib/adiwg/mdtranslator/writers/html/sections/html_citation.rb +6 -2
  21. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +1 -2
  22. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_budget.rb +29 -2
  23. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +0 -1
  24. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +7 -1
  25. metadata +18 -22
  26. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_additionalDocumentation.rb +0 -52
  27. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_boundingBox.rb +0 -54
  28. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_browseGraphic.rb +0 -66
  29. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_citation.rb +0 -125
  30. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_contacts.rb +0 -143
  31. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_dateTime.rb +0 -31
  32. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_distributionInfo.rb +0 -64
  33. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_extent.rb +0 -61
  34. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_geoCoordSystem.rb +0 -50
  35. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_geoProperties.rb +0 -91
  36. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_geographicElement.rb +0 -161
  37. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_metadata.rb +0 -75
  38. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_metadataInfo.rb +0 -130
  39. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_onlineResource.rb +0 -71
  40. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_resourceIdentifier.rb +0 -73
  41. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_resourceInfo.rb +0 -437
  42. data/lib/adiwg/mdtranslator/readers/sbJson/modules/Old/module_responsibleParty.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6dae2d4d0b4f056465097adf48a786332a8e1ac
4
- data.tar.gz: 4d120c45abcf7459c45271c4e4a626e4bc2aa426
3
+ metadata.gz: eaa279b686cbbf45cc0066e9aef52a6c72604444
4
+ data.tar.gz: a88be00a70a91aae1cfb0d77ac333b758731c5e7
5
5
  SHA512:
6
- metadata.gz: 59a2afd957514a20c5d2497d6627a08516dcfb40df807fb9fcbd6039263bb83ec512717b141abfe43153b91fe4430877e360964bdcdb51c82e195826c9017941
7
- data.tar.gz: 1e080a421fad0efb0139437922a021d5b7402c252ed2dda1ca3fbd0695eed882309c2f345a4170e015606142689a17364914b1784df99c7ccce3610568412c4f
6
+ metadata.gz: e755033a24e274d7af87523e5209a65d8b9b046a9e4967be02d407657475c8983c45fa1fb97260f9422ea39530f8e10e7f5456ff4afc4183800006ba813af0ff
7
+ data.tar.gz: a23c434be20d0309294c36133f2bcb2099883198c46c3fde5701361dfba854798ba156dbc2a5cb9916b7ae3aa213d58fb84126fbb88a70634698043c2132cdfc
@@ -0,0 +1,47 @@
1
+ # unpack browse category
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-22 original script
6
+
7
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
8
+ require 'adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module SbJson
14
+
15
+ module BrowseCategory
16
+
17
+ @Namespace = ADIWG::Mdtranslator::Writers::SbJson
18
+
19
+ def self.unpack(hSbJson, hResourceInfo, hResponseObj)
20
+
21
+ # instance classes needed in script
22
+ intMetadataClass = InternalMetadata.new
23
+
24
+ if hSbJson.has_key?('browseCategories')
25
+ hSbJson['browseCategories'].each do |category|
26
+ hResType = intMetadataClass.newResourceType
27
+ scope = @Namespace::Codelists.codelist_iso_to_sb('iso_sb_scope', :sbCode => category)
28
+ if scope.nil?
29
+ hResType[:type] = 'dataset'
30
+ hResType[:name] = category
31
+ else
32
+ hResType[:type] = scope
33
+ end
34
+ hResourceInfo[:resourceTypes] << hResType
35
+ end
36
+ end
37
+
38
+ return hResourceInfo
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,79 @@
1
+ # unpack budget facet
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-25 original script
6
+
7
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module SbJson
13
+
14
+ module Budget
15
+
16
+ def self.unpack(hFacet, hMetadata, hResponseObj)
17
+
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
20
+
21
+ if hFacet.has_key?('annualBudgets')
22
+ hFacet['annualBudgets'].each do |hBudget|
23
+
24
+ hFunding = intMetadataClass.newFunding
25
+
26
+ # funding source
27
+ # ignore source and recipient
28
+ if hBudget.has_key?('fundingSources')
29
+ hBudget['fundingSources'].each do |hSource|
30
+ hAllocation = intMetadataClass.newAllocation
31
+ if hSource.has_key?('amount')
32
+ unless hSource['amount'].nil? || hSource == ''
33
+ hAllocation[:amount] = hSource['amount']
34
+ end
35
+ end
36
+ if hSource.has_key?('matching')
37
+ if !!hSource['matching'] == hSource['matching']
38
+ hAllocation[:matching] = hSource['matching']
39
+ else
40
+ hAllocation[:matching] = false
41
+ end
42
+ end
43
+
44
+ hFunding[:allocations] << hAllocation
45
+ end
46
+ end
47
+
48
+ # year
49
+ if hBudget.has_key?('year')
50
+ unless hBudget['year'].nil? || hBudget['year'] == ''
51
+ hPeriod = intMetadataClass.newTimePeriod
52
+ hDateTime = intMetadataClass.newDateTime
53
+ aReturn = AdiwgDateTimeFun.dateTimeFromString(hBudget['year'])
54
+ unless aReturn.nil?
55
+ hDateTime[:dateTime] = aReturn[0]
56
+ hDateTime[:dateResolution] = aReturn[1]
57
+ hPeriod[:endDateTime] = hDateTime
58
+ hFunding[:timePeriod] = hPeriod
59
+ end
60
+ end
61
+ end
62
+
63
+ unless hFunding.empty?
64
+ hMetadata[:funding] << hFunding
65
+ end
66
+
67
+ end
68
+ end
69
+
70
+ return hMetadata
71
+
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,248 @@
1
+ # unpack contacts
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-21 original script
6
+
7
+ require 'uuidtools'
8
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module SbJson
14
+
15
+ module Contact
16
+
17
+ def self.unpackAddress(hSbPrimary, hAddress)
18
+
19
+ if hSbPrimary.has_key?('line1')
20
+ unless hSbPrimary['line1'].nil? || hSbPrimary['line1'] == ''
21
+ hAddress[:deliveryPoints] << hSbPrimary['line1']
22
+ end
23
+ end
24
+ if hSbPrimary.has_key?('line2')
25
+ unless hSbPrimary['line2'].nil? || hSbPrimary['line2'] == ''
26
+ hAddress[:deliveryPoints] << hSbPrimary['line2']
27
+ end
28
+ end
29
+
30
+ if hSbPrimary.has_key?('city')
31
+ unless hSbPrimary['city'].nil? || hSbPrimary['city'] == ''
32
+ hAddress[:city] = hSbPrimary['city']
33
+ end
34
+ end
35
+ if hSbPrimary.has_key?('state')
36
+ unless hSbPrimary['state'].nil? || hSbPrimary['state'] == ''
37
+ hAddress[:adminArea] = hSbPrimary['state']
38
+ end
39
+ end
40
+ if hSbPrimary.has_key?('zip')
41
+ unless hSbPrimary['zip'].nil? || hSbPrimary['zip'] == ''
42
+ hAddress[:postalCode] = hSbPrimary['zip']
43
+ end
44
+ end
45
+ if hSbPrimary.has_key?('country')
46
+ unless hSbPrimary['country'].nil? || hSbPrimary['country'] == ''
47
+ hAddress[:country] = hSbPrimary['country']
48
+ end
49
+ end
50
+
51
+ return hAddress
52
+
53
+ end
54
+
55
+ def self.unpack(hSbJson, aContacts, hResponseObj)
56
+
57
+ # instance classes needed in script
58
+ intMetadataClass = InternalMetadata.new
59
+
60
+ if hSbJson.has_key?('contacts')
61
+
62
+ hSbJson['contacts'].each do |hSbContact|
63
+
64
+ hContact = intMetadataClass.newContact
65
+
66
+ hContact[:contactId] = UUIDTools::UUID.random_create.to_s
67
+
68
+ # contact - contactType (required) [ person | organization ]
69
+ if hSbContact.has_key?('contactType')
70
+ if %w(person organization).include?(hSbContact['contactType'])
71
+ hContact[:isOrganization] = true if hSbContact['contactType'] == 'organization'
72
+ else
73
+ hResponseObj[:readerExecutionMessages] << 'Contact contactType must be person or organization'
74
+ hResponseObj[:readerExecutionPass] = false
75
+ return nil
76
+ end
77
+ end
78
+ if hSbContact['contactType'].nil? || hSbContact['contactType'] == ''
79
+ hResponseObj[:readerExecutionMessages] << 'Contact contactType is missing'
80
+ hResponseObj[:readerExecutionPass] = false
81
+ return nil
82
+ end
83
+
84
+ # contact - name (required)
85
+ if hSbContact.has_key?('name')
86
+ hContact[:name] = hSbContact['name']
87
+ end
88
+ if hSbContact['name'].nil? || hSbContact['name'] == ''
89
+ hResponseObj[:readerExecutionMessages] << 'Contact name is missing'
90
+ hResponseObj[:readerExecutionPass] = false
91
+ return nil
92
+ end
93
+
94
+ if hSbContact.has_key?('jobTitle')
95
+ unless hSbContact['jobTitle'].nil? || hSbContact['jobTitle'] == ''
96
+ hContact[:positionName] = hSbContact['jobTitle']
97
+ end
98
+ end
99
+
100
+ # logos
101
+ if hSbContact.has_key?('logoUrl')
102
+ unless hSbContact['logoUrl'].nil? || hSbContact['logoUrl'] == ''
103
+ hGraphic = intMetadataClass.newGraphic
104
+ hOlRes = intMetadataClass.newOnlineResource
105
+ hGraphic[:graphicName] = 'logoUrl'
106
+ hOlRes[:olResURI] = hSbContact['logoUrl']
107
+ hGraphic[:graphicURI] << hOlRes
108
+ hContact[:logos] << hGraphic
109
+ end
110
+ end
111
+ if hSbContact.has_key?('smallLogoUrl')
112
+ unless hSbContact['smallLogoUrl'].nil? || hSbContact['smallLogoUrl'] == ''
113
+ hGraphic = intMetadataClass.newGraphic
114
+ hOlRes = intMetadataClass.newOnlineResource
115
+ hGraphic[:graphicName] = 'smallLogoUrl'
116
+ hOlRes[:olResURI] = hSbContact['smallLogoUrl']
117
+ hGraphic[:graphicURI] << hOlRes
118
+ hContact[:logos] << hGraphic
119
+ end
120
+ end
121
+
122
+ # primary location
123
+ if hSbContact.has_key?('primaryLocation')
124
+ unless hSbContact['primaryLocation'].empty?
125
+
126
+ hPrimary = hSbContact['primaryLocation']
127
+
128
+ # phones
129
+ if hPrimary.has_key?('officePhone')
130
+ unless hPrimary['officePhone'].nil? || hPrimary['officePhone'] == ''
131
+ hPhone = intMetadataClass.newPhone
132
+ hPhone[:phoneNumber] = hPrimary['officePhone']
133
+ hPhone[:phoneServiceTypes] << 'voice'
134
+ hContact[:phones] << hPhone
135
+ end
136
+ end
137
+ if hPrimary.has_key?('faxPhone')
138
+ unless hPrimary['faxPhone'].nil? || hPrimary['faxPhone'] == ''
139
+ hPhone = intMetadataClass.newPhone
140
+ hPhone[:phoneNumber] = hPrimary['faxPhone']
141
+ hPhone[:phoneServiceTypes] << 'facsimile'
142
+ hContact[:phones] << hPhone
143
+ end
144
+ end
145
+ if hPrimary.has_key?('ttyPhone')
146
+ unless hPrimary['ttyPhone'].nil? || hPrimary['ttyPhone'] == ''
147
+ hPhone = intMetadataClass.newPhone
148
+ hPhone[:phoneNumber] = hPrimary['ttyPhone']
149
+ hPhone[:phoneServiceTypes] << 'tty'
150
+ hContact[:phones] << hPhone
151
+ end
152
+ end
153
+
154
+ # street address
155
+ if hPrimary.has_key?('streetAddress')
156
+ unless hPrimary['streetAddress'].empty?
157
+ hAddress = intMetadataClass.newAddress
158
+ hAddress[:addressTypes] << 'physical'
159
+
160
+ if hPrimary.has_key?('name')
161
+ unless hPrimary['name'].nil? || hPrimary['name'] == ''
162
+ hAddress[:description] = hPrimary['name']
163
+ end
164
+ end
165
+
166
+ hContact[:addresses] << unpackAddress(hPrimary['streetAddress'], hAddress)
167
+ end
168
+ end
169
+
170
+ # mailing address
171
+ if hPrimary.has_key?('mailAddress')
172
+ unless hPrimary['mailAddress'].empty?
173
+ hAddress = intMetadataClass.newAddress
174
+ hAddress[:addressTypes] << 'mailing'
175
+
176
+ if hPrimary.has_key?('name')
177
+ unless hPrimary['name'].nil? || hPrimary['name'] == ''
178
+ hAddress[:description] = hPrimary['name']
179
+ end
180
+ end
181
+
182
+ hContact[:addresses] << unpackAddress(hPrimary['mailAddress'], hAddress)
183
+ end
184
+ end
185
+
186
+
187
+ end
188
+ end
189
+
190
+ # email / hours of service / contact instructions
191
+ if hSbContact.has_key?('email')
192
+ unless hSbContact['email'].nil? || hSbContact['email'] == ''
193
+ hContact[:eMailList] << hSbContact['email']
194
+ end
195
+ end
196
+ if hSbContact.has_key?('hours')
197
+ unless hSbContact['hours'].nil? || hSbContact['hours'] == ''
198
+ hContact[:hoursOfService] << hSbContact['hours']
199
+ end
200
+ end
201
+ if hSbContact.has_key?('instructions')
202
+ unless hSbContact['instructions'].nil? || hSbContact['instructions'] == ''
203
+ hContact[:contactInstructions] = hSbContact['instructions']
204
+ end
205
+ end
206
+
207
+ # contact - type (required)
208
+ if hSbContact.has_key?('type')
209
+ hContact[:contactType] = hSbContact['type']
210
+ end
211
+ if hSbContact['type'].nil? || hSbContact['type'] == ''
212
+ hResponseObj[:readerExecutionMessages] << 'Contact type is missing'
213
+ hResponseObj[:readerExecutionPass] = false
214
+ return nil
215
+ end
216
+
217
+ # member of organization
218
+ hContactOrg = {}
219
+ if hSbContact.has_key?('organization')
220
+ if hSbContact['organization'].has_key?('displayText')
221
+ sbText = hSbContact['organization']['displayText']
222
+ unless sbText.nil? || sbText == ''
223
+ hContactOrg = intMetadataClass.newContact
224
+ hContactOrg[:contactId] = UUIDTools::UUID.random_create.to_s
225
+ hContactOrg[:isOrganization] = true
226
+ hContactOrg[:name] = sbText
227
+ hContact[:memberOfOrgs] << hContactOrg[:contactId]
228
+ end
229
+ end
230
+ end
231
+
232
+ aContacts << hContact
233
+ aContacts << hContactOrg unless hContactOrg.empty?
234
+
235
+ end
236
+
237
+ end
238
+
239
+ return aContacts
240
+
241
+ end
242
+
243
+ end
244
+
245
+ end
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,49 @@
1
+ # unpack dates
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-25 original script
6
+
7
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
8
+ require 'adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module SbJson
14
+
15
+ module Date
16
+
17
+ @Namespace = ADIWG::Mdtranslator::Writers::SbJson
18
+
19
+ def self.unpack(hSbJson, hCitation, hResponseObj)
20
+
21
+ # instance classes needed in script
22
+ intMetadataClass = InternalMetadata.new
23
+
24
+ if hSbJson.has_key?('dates')
25
+ hSbJson['dates'].each do |hSbDate|
26
+ hDate = intMetadataClass.newDate
27
+ aReturn = AdiwgDateTimeFun.dateTimeFromString(hSbDate['dateString'])
28
+ unless aReturn.nil?
29
+ hDate[:date] = aReturn[0]
30
+ hDate[:dateResolution] = aReturn[1]
31
+ hDate[:description] = hSbDate['label']
32
+ type = @Namespace::Codelists.codelist_iso_to_sb('iso_sb_date', :sbCode => hSbDate['type'])
33
+ type = type.nil? ? hSbDate['type'] : type
34
+ hDate[:dateType] = type
35
+ hCitation[:dates] << hDate
36
+ end
37
+ end
38
+ end
39
+
40
+ return hCitation
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,62 @@
1
+ # unpack extent
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-28 original script
6
+
7
+ require 'json'
8
+ require 'open-uri'
9
+ require 'adiwg/mdtranslator/readers/mdJson/modules/module_extent'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Readers
14
+ module SbJson
15
+
16
+ module Extent
17
+
18
+ def self.unpack(extentId, hResponseObj)
19
+
20
+ begin
21
+ extentAdd = "http://www.sciencebase.gov/catalog/extent/#{extentId}?format=geojson"
22
+ web_contents = open(extentAdd, :read_timeout => 30) { |f| f.read }
23
+ rescue => readErr
24
+ hResponseObj[:readerExecutionMessages] << 'ScienceBase read failed - see following message(s):\n'
25
+ hResponseObj[:readerExecutionMessages] << readErr.to_s.slice(0, 300)
26
+ return {}
27
+ else
28
+ # parse geoJson file
29
+ begin
30
+ hGeoJson = JSON.parse(web_contents)
31
+ rescue JSON::JSONError => parseErr
32
+ hResponseObj[:readerExecutionMessages] << 'Parsing sbJson failed - see following message(s):\n'
33
+ hResponseObj[:readerExecutionMessages] << parseErr.to_s.slice(0, 300)
34
+ return {}
35
+ end
36
+ mdJson = {
37
+ 'description' => 'Extent extracted from ScienceBase',
38
+ 'geographicExtent' => [
39
+ {
40
+ 'containsData' => true,
41
+ 'identifier' => {
42
+ 'identifier' => ''
43
+ },
44
+ 'geographicElement' => []
45
+ }
46
+ ]
47
+ }
48
+ mdJson['geographicExtent'][0]['identifier']['identifier'] = extentId.to_s
49
+ mdJson['geographicExtent'][0]['identifier']['namespace'] = 'gov.sciencebase.catalog'
50
+ mdJson['geographicExtent'][0]['geographicElement'] << hGeoJson
51
+ hExtent = ADIWG::Mdtranslator::Readers::MdJson::Extent.unpack(mdJson, hResponseObj)
52
+ return hExtent
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end