adiwg-mdtranslator 2.1.0 → 2.1.1
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/adiwg-mdtranslator.gemspec +1 -0
- data/lib/adiwg/mdtranslator/internal/module_coordinates.rb +13 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb +49 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_citation.rb +144 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_date.rb +57 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +108 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +193 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +136 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_onlineResource.rb +35 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_publication.rb +63 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_responsibility.rb +46 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_series.rb +44 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +184 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialOrganization.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialReference.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timeInstant.rb +40 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +88 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/readme.md +18 -0
- data/lib/adiwg/mdtranslator/readers/{fgcd → fgdc}/version.rb +0 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/readme.md +1 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/version.rb +2 -1
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_browseCategory.rb +5 -5
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_relatedItem.rb +4 -10
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/sbJson/readme.md +1 -1
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/sbJson/version.rb +1 -1
- data/lib/adiwg/mdtranslator/version.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceType.rb +1 -0
- metadata +37 -3
@@ -0,0 +1,88 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc time period
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-17 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
require_relative 'module_dateTime'
|
10
|
+
|
11
|
+
module ADIWG
|
12
|
+
module Mdtranslator
|
13
|
+
module Readers
|
14
|
+
module Fgdc
|
15
|
+
|
16
|
+
module TimePeriod
|
17
|
+
|
18
|
+
def self.unpack(xTimePeriod, hResponseObj)
|
19
|
+
|
20
|
+
# instance classes needed in script
|
21
|
+
intMetadataClass = InternalMetadata.new
|
22
|
+
hTimePeriod = intMetadataClass.newTimePeriod
|
23
|
+
|
24
|
+
# time period 9 (timeinfo) - time period information
|
25
|
+
xTimeInfo = xTimePeriod.xpath('./timeinfo')
|
26
|
+
current = xTimePeriod.xpath('./current').text
|
27
|
+
|
28
|
+
unless xTimeInfo.empty?
|
29
|
+
|
30
|
+
# time period 9.1 (sngdate) - single date
|
31
|
+
xSingle = xTimeInfo.xpath('./sngdate')
|
32
|
+
unless xSingle.empty?
|
33
|
+
|
34
|
+
# single date 9.1.1/9.1.2 (caldate/time) - single date/time {date} (required) {time}
|
35
|
+
date = xSingle.xpath('./caldate').text
|
36
|
+
time = xSingle.xpath('./time').text
|
37
|
+
hDateTime = DateTime.unpack(date, time, hResponseObj)
|
38
|
+
unless hDateTime.nil?
|
39
|
+
hTimePeriod[:endDateTime] = hDateTime
|
40
|
+
end
|
41
|
+
hTimePeriod[:description] = current
|
42
|
+
|
43
|
+
return hTimePeriod
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# time period 9.2 (mdattim) - multiple date times
|
48
|
+
# placed in temporal extent
|
49
|
+
|
50
|
+
# time period 9.3 (rngdates) - range of dates
|
51
|
+
xRange = xTimeInfo.xpath('./rngdates')
|
52
|
+
unless xRange.empty?
|
53
|
+
|
54
|
+
# range of dates 9.3.1 (begdate) - begin date {date} (required)
|
55
|
+
# range of dates 9.3.2 (begtime) - begin time {time}
|
56
|
+
beginDate = xRange.xpath('./begdate').text
|
57
|
+
beginTime = xRange.xpath('./begtime').text
|
58
|
+
hDateTime = DateTime.unpack(beginDate, beginTime, hResponseObj)
|
59
|
+
unless hDateTime.nil?
|
60
|
+
hTimePeriod[:startDateTime] = hDateTime
|
61
|
+
end
|
62
|
+
|
63
|
+
# range of dates 9.3.3 (enddate) - end date {date} (required)
|
64
|
+
# range of dates 9.3.4 (endtime) - end time {time}
|
65
|
+
endDate = xRange.xpath('./enddate').text
|
66
|
+
endTime = xRange.xpath('./endtime').text
|
67
|
+
hDateTime = DateTime.unpack(endDate, endTime, hResponseObj)
|
68
|
+
unless hDateTime.nil?
|
69
|
+
hTimePeriod[:endDateTime] = hDateTime
|
70
|
+
end
|
71
|
+
hTimePeriod[:description] = current
|
72
|
+
|
73
|
+
return hTimePeriod
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
return nil
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
## sbJson
|
3
|
+
|
4
|
+
### Supported versions
|
5
|
+
|
6
|
+
> 1.x (FGDC-STD-001-1998)
|
7
|
+
|
8
|
+
### Reader for Federal Geographic Data Committee's Content Standard for Digital Geospatial Metadata (fgdc)
|
9
|
+
|
10
|
+
Content Standard for Digital Geospatial Metadata (CSDGM), Vers. 2
|
11
|
+
(FGDC-STD-001-1998) is the current version of this FGDC authored and
|
12
|
+
endorsed standard. Executive Order 12906, directed that Federal agencies
|
13
|
+
document geospatial resources using this standard. Since the publication
|
14
|
+
of EO 12906, the FGDC has endorsed several ISO Geospatial Metadata
|
15
|
+
Standards that are now encouraged for use.
|
16
|
+
|
17
|
+
The FGDC CSDGM format standard is fully documented on the
|
18
|
+
[Content Standard for Digital Geospatial Metadata page](https://www.fgdc.gov/metadata/csdgm-standard).
|
File without changes
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# adiwg mdTranslator / readers / mdJson
|
2
2
|
|
3
3
|
# version 2 history
|
4
|
+
# 2.2.0 2017-08-10 added sbJson reader and writer
|
4
5
|
# 2.1.2 2017-05-19 deprecated iso topicCategory
|
5
6
|
# 2.0.0 2016-10-01 start of version 2
|
6
7
|
|
@@ -8,7 +9,7 @@ module ADIWG
|
|
8
9
|
module Mdtranslator
|
9
10
|
module Readers
|
10
11
|
module MdJson
|
11
|
-
VERSION = "2.
|
12
|
+
VERSION = "2.2.0"
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -14,13 +14,13 @@ module ADIWG
|
|
14
14
|
|
15
15
|
module BrowseCategory
|
16
16
|
|
17
|
-
def self.unpack(
|
17
|
+
def self.unpack(hJson, aResourceTypes, hResponseObj)
|
18
18
|
|
19
19
|
# instance classes needed in script
|
20
20
|
intMetadataClass = InternalMetadata.new
|
21
21
|
|
22
|
-
if
|
23
|
-
|
22
|
+
if hJson.has_key?('browseCategories')
|
23
|
+
hJson['browseCategories'].each do |category|
|
24
24
|
hResType = intMetadataClass.newResourceType
|
25
25
|
scope = Codelists.codelist_sb2adiwg('scope_sb2adiwg', category)
|
26
26
|
if scope.nil?
|
@@ -29,11 +29,11 @@ module ADIWG
|
|
29
29
|
else
|
30
30
|
hResType[:type] = scope
|
31
31
|
end
|
32
|
-
|
32
|
+
aResourceTypes << hResType
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
return
|
36
|
+
return aResourceTypes
|
37
37
|
|
38
38
|
end
|
39
39
|
|
@@ -8,6 +8,7 @@ require 'json'
|
|
8
8
|
require 'open-uri'
|
9
9
|
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
10
10
|
require_relative 'module_codelists'
|
11
|
+
require_relative 'module_browseCategory'
|
11
12
|
|
12
13
|
module ADIWG
|
13
14
|
module Mdtranslator
|
@@ -93,6 +94,7 @@ module ADIWG
|
|
93
94
|
hResponseObj[:readerExecutionMessages] << 'Either the item does not exist or the item is secured and requires authentication to access.'
|
94
95
|
break
|
95
96
|
else
|
97
|
+
|
96
98
|
# parse related item
|
97
99
|
begin
|
98
100
|
hRelatedItem = JSON.parse(web_contents)
|
@@ -105,16 +107,8 @@ module ADIWG
|
|
105
107
|
# create mew associated resource
|
106
108
|
hResource = intMetadataClass.newAssociatedResource
|
107
109
|
|
108
|
-
|
109
|
-
|
110
|
-
aBrowse.each do |category|
|
111
|
-
resourceType = Codelists.codelist_sb2adiwg('scope_sb2adiwg', category)
|
112
|
-
resourceType = resourceType.nil? ? category : resourceType
|
113
|
-
hResource[:resourceTypes] << resourceType
|
114
|
-
end
|
115
|
-
else
|
116
|
-
hResponseObj[:readerExecutionMessages] << "Related item #{resourceId} did not have browseCategories"
|
117
|
-
end
|
110
|
+
# add resource types
|
111
|
+
BrowseCategory.unpack(hRelatedItem, hResource[:resourceTypes], hResponseObj)
|
118
112
|
|
119
113
|
# fill in associated resource citation
|
120
114
|
hCitation = intMetadataClass.newCitation
|
@@ -104,7 +104,7 @@ module ADIWG
|
|
104
104
|
hResourceInfo[:graphicOverviews].concat(aReturn) unless aReturn.nil?
|
105
105
|
|
106
106
|
# browse categories
|
107
|
-
BrowseCategory.unpack(hSbJson, hResourceInfo, hResponseObj)
|
107
|
+
BrowseCategory.unpack(hSbJson, hResourceInfo[:resourceTypes], hResponseObj)
|
108
108
|
|
109
109
|
# tags
|
110
110
|
Tag.unpack(hSbJson, hResourceInfo, hResponseObj)
|
@@ -15,4 +15,4 @@ integrate across multiple metadata standards, conventions, and
|
|
15
15
|
practices in describing a wide array of scientific data and
|
16
16
|
information assets important to science teams using ScienceBase.
|
17
17
|
|
18
|
-
The sbJSON format is
|
18
|
+
The sbJSON format is partially documented on the [ScienceBase Confluence page](https://my.usgs.gov/confluence/display/sciencebase/ScienceBase+Information+Model).
|
@@ -25,14 +25,14 @@ module ADIWG
|
|
25
25
|
return {}
|
26
26
|
end
|
27
27
|
|
28
|
-
# file must contain an
|
28
|
+
# file must contain an sbJson object
|
29
29
|
if hSbJson.empty?
|
30
30
|
hResponseObj[:readerStructureMessages] << 'sbJson object is empty'
|
31
31
|
hResponseObj[:readerStructurePass] = false
|
32
32
|
return {}
|
33
33
|
end
|
34
34
|
|
35
|
-
# faking the version since
|
35
|
+
# faking the version since sbJson has no version support
|
36
36
|
hSbJson['schema'] = {
|
37
37
|
'name' => 'sbJson',
|
38
38
|
'version' => '0.0.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adiwg-mdtranslator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-08-
|
12
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -193,6 +193,20 @@ dependencies:
|
|
193
193
|
- - "~>"
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '1.1'
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: nokogiri
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - "~>"
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '1.7'
|
203
|
+
type: :runtime
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - "~>"
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '1.7'
|
196
210
|
description: The mdtranslator was written by the Alaska Data Integration Working Group
|
197
211
|
(ADIwg) to assist with creating ISO 19139 metadata records. Input to the mdtranslator
|
198
212
|
is JSON conforming to the mdJson-schema. The mdtranslator architecture allows developers
|
@@ -221,7 +235,27 @@ files:
|
|
221
235
|
- lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb
|
222
236
|
- lib/adiwg/mdtranslator/internal/module_coordinates.rb
|
223
237
|
- lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb
|
224
|
-
- lib/adiwg/mdtranslator/readers/
|
238
|
+
- lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
|
239
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_citation.rb
|
240
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_date.rb
|
241
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb
|
242
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb
|
243
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb
|
244
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb
|
245
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb
|
246
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb
|
247
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_onlineResource.rb
|
248
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_publication.rb
|
249
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb
|
250
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_responsibility.rb
|
251
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_series.rb
|
252
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb
|
253
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialOrganization.rb
|
254
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialReference.rb
|
255
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_timeInstant.rb
|
256
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb
|
257
|
+
- lib/adiwg/mdtranslator/readers/fgdc/readme.md
|
258
|
+
- lib/adiwg/mdtranslator/readers/fgdc/version.rb
|
225
259
|
- lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb
|
226
260
|
- lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb
|
227
261
|
- lib/adiwg/mdtranslator/readers/mdJson/modules/module_additionalDocumentation.rb
|