adiwg-mdtranslator 2.0.0rc10 → 2.0.0rc11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adiwg/mdtranslator/version.rb +3 -1
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_budget.rb +9 -3
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +20 -4
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_date.rb +39 -7
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb +48 -3
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_metadataRepository.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_publication.rb +7 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb +33 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbce410a9f43321f9019509cb844144ff5ca950b
|
4
|
+
data.tar.gz: b9576143da46802dda31de1d03b0f56c6049c3b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9c62887d1941434a579619e3bed5a691c77652e87280e7e667d2683ae6d6a0cdab75caba2af26e824c50e1ab906e89b3625ee089e2ec75858ea300dddd5ac5e
|
7
|
+
data.tar.gz: aeb48e161931209ec8a077d1509ea8072eebd0e95727dd2f0ab3a45be0a9f67626563428983135f05732937453e838f712b1be5d0dbbabd8a339e92d7a1e87a5
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# adiwg mdTranslator
|
2
2
|
|
3
3
|
# version 2 history
|
4
|
+
# 2.0.0rc11 2017-06-08 apply changes to sbJson writer after second review session
|
5
|
+
# 2.0.0rc10 2017-06-05 apply changes to sbJson writer after review
|
4
6
|
# 2.0.0rc9 2017-05-26 allow choice of which dictionary to translate
|
5
7
|
# ... fix bug when no dictionary is provided in mdJson
|
6
8
|
# ... add sbJson writer
|
@@ -16,7 +18,7 @@
|
|
16
18
|
module ADIWG
|
17
19
|
module Mdtranslator
|
18
20
|
# current mdtranslator version
|
19
|
-
VERSION = "2.0.
|
21
|
+
VERSION = "2.0.0rc11"
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -33,7 +33,9 @@ module ADIWG
|
|
33
33
|
budget[:fundingSources] = fundingSources
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
# give priority to ending dateTime
|
37
|
+
# write year only
|
38
|
+
# use fiscal year beginning October 1
|
37
39
|
unless hFunding[:timePeriod].empty?
|
38
40
|
unless hFunding[:timePeriod][:startDateTime].empty?
|
39
41
|
startDateTime = hFunding[:timePeriod][:startDateTime][:dateTime]
|
@@ -41,9 +43,13 @@ module ADIWG
|
|
41
43
|
unless hFunding[:timePeriod][:endDateTime].empty?
|
42
44
|
endDateTime = hFunding[:timePeriod][:endDateTime][:dateTime]
|
43
45
|
end
|
44
|
-
dateTime =
|
46
|
+
dateTime = endDateTime.nil? ? startDateTime : endDateTime
|
45
47
|
unless dateTime.nil?
|
46
|
-
|
48
|
+
year = AdiwgDateTimeFun.stringDateFromDateTime(dateTime, 'Y')
|
49
|
+
if dateTime.month > 9
|
50
|
+
year.succ!
|
51
|
+
end
|
52
|
+
budget[:year] = year
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
@@ -94,22 +94,38 @@ module ADIWG
|
|
94
94
|
]
|
95
95
|
|
96
96
|
@iso_sb_date = [
|
97
|
-
{iso: 'creation', sb: '
|
97
|
+
{iso: 'creation', sb: 'creation'},
|
98
98
|
{iso: 'publication', sb: 'Publication'},
|
99
|
-
{iso: 'revision', sb: '
|
99
|
+
{iso: 'revision', sb: 'revision'},
|
100
100
|
{iso: 'expiry', sb: nil},
|
101
101
|
{iso: 'lastUpdate', sb: 'lastUpdate'},
|
102
102
|
{iso: 'lastRevision', sb: 'lastRevision'},
|
103
103
|
{iso: 'nextUpdate', sb: 'nextUpdate'},
|
104
104
|
{iso: 'unavailable', sb: 'unavailable'},
|
105
105
|
{iso: 'inForce', sb: 'inForce'},
|
106
|
-
{iso: 'adopted', sb: '
|
106
|
+
{iso: 'adopted', sb: 'Adopted'},
|
107
107
|
{iso: 'deprecated', sb: 'deprecated'},
|
108
108
|
{iso: 'suspended', sb: 'suspended'},
|
109
109
|
{iso: 'validityBegins', sb: 'validityBegins'},
|
110
110
|
{iso: 'validityExpires', sb: 'validityExpires'},
|
111
111
|
{iso: 'released', sb: 'Release'},
|
112
|
-
{iso: 'distribution', sb: '
|
112
|
+
{iso: 'distribution', sb: 'distribution'},
|
113
|
+
{iso: 'acquisition', sb: 'Acquisition'},
|
114
|
+
{iso: 'assessment', sb: 'AssessmentDate'},
|
115
|
+
{iso: 'award', sb: 'Award'},
|
116
|
+
{iso: nil, sb: 'beginPosition'},
|
117
|
+
{iso: 'collected', sb: 'Collected'},
|
118
|
+
{iso: 'deprecated', sb: 'deprecated'},
|
119
|
+
{iso: 'due', sb: 'Due'},
|
120
|
+
{iso: 'end', sb: 'End'},
|
121
|
+
{iso: nil, sb: 'endPosition'},
|
122
|
+
{iso: nil, sb: 'Info'},
|
123
|
+
{iso: 'received', sb: 'Received'},
|
124
|
+
{iso: 'reported', sb: 'Reported'},
|
125
|
+
{iso: nil, sb: 'Repository Created'},
|
126
|
+
{iso: nil, sb: 'Repository Updated'},
|
127
|
+
{iso: 'start', sb: 'Start'},
|
128
|
+
{iso: 'transmitted', sb: 'Transmitted'}
|
113
129
|
]
|
114
130
|
|
115
131
|
@iso_sb_progress = [
|
@@ -12,16 +12,48 @@ module ADIWG
|
|
12
12
|
|
13
13
|
module Date
|
14
14
|
|
15
|
-
def self.build(
|
15
|
+
def self.build(hResource)
|
16
16
|
|
17
17
|
aDates = []
|
18
|
+
hCitation = hResource[:citation]
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
# add citation dates to sbJson dates
|
21
|
+
unless hCitation.empty?
|
22
|
+
hCitation[:dates].each do |hDate|
|
23
|
+
sbDate = {}
|
24
|
+
dateType = Codelists.codelist_iso_to_sb('iso_sb_date', :isoCode => hDate[:dateType])
|
25
|
+
|
26
|
+
# if iso date codes does not map to scienceBase use type = 'Info'
|
27
|
+
if dateType.nil?
|
28
|
+
sbDate[:type] = 'Info'
|
29
|
+
sbDate[:dateString] = AdiwgDateTimeFun.stringFromDateObject(hDate)
|
30
|
+
sbDate[:label] = hDate[:dateType]
|
31
|
+
else
|
32
|
+
sbDate[:type] = dateType
|
33
|
+
sbDate[:dateString] = AdiwgDateTimeFun.stringFromDateObject(hDate)
|
34
|
+
sbDate[:label] = hDate[:description] unless hDate[:description].nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
aDates << sbDate
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# add resource timePeriod dates to sbJson dates
|
42
|
+
unless hResource[:timePeriod].empty?
|
43
|
+
unless hResource[:timePeriod][:startDateTime].empty?
|
44
|
+
sbDate = {}
|
45
|
+
sbDate[:type] = 'Start'
|
46
|
+
sbDate[:dateString] = AdiwgDateTimeFun.stringFromDateObject(hResource[:timePeriod][:startDateTime])
|
47
|
+
sbDate[:label] = hResource[:timePeriod][:description] unless hResource[:timePeriod][:description].nil?
|
48
|
+
aDates << sbDate
|
49
|
+
end
|
50
|
+
unless hResource[:timePeriod][:endDateTime].empty?
|
51
|
+
sbDate = {}
|
52
|
+
sbDate[:type] = 'End'
|
53
|
+
sbDate[:dateString] = AdiwgDateTimeFun.stringFromDateObject(hResource[:timePeriod][:endDateTime])
|
54
|
+
sbDate[:label] = hResource[:timePeriod][:description] unless hResource[:timePeriod][:description].nil?
|
55
|
+
aDates << sbDate
|
56
|
+
end
|
25
57
|
end
|
26
58
|
|
27
59
|
if aDates.empty?
|
@@ -10,18 +10,63 @@ module ADIWG
|
|
10
10
|
|
11
11
|
module GeographicExtent
|
12
12
|
|
13
|
+
def self.new_collection
|
14
|
+
{
|
15
|
+
'type' => 'FeatureCollection',
|
16
|
+
'features' => []
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.new_feature
|
21
|
+
{
|
22
|
+
'type' => 'Feature',
|
23
|
+
'geometry' => {}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
13
27
|
def self.build(aExtents)
|
14
28
|
|
15
|
-
|
29
|
+
aFeatureCollection = []
|
16
30
|
|
17
31
|
# gather geographicExtents geoJson blocks
|
18
32
|
aExtents.each do |hExtent|
|
19
33
|
hExtent[:geographicExtents].each do |hGeoExtent|
|
20
|
-
|
34
|
+
|
35
|
+
collection = new_collection()
|
36
|
+
hGeoExtent[:nativeGeoJson].each do |hGeoObj|
|
37
|
+
|
38
|
+
case hGeoObj['type']
|
39
|
+
when 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon'
|
40
|
+
feature = new_feature()
|
41
|
+
feature['geometry'] = hGeoObj
|
42
|
+
collection['features'] << feature
|
43
|
+
|
44
|
+
when 'GeometryCollection'
|
45
|
+
geoCollection = new_collection()
|
46
|
+
hGeoObj['geometries'].each do |hGeometry|
|
47
|
+
feature = new_feature()
|
48
|
+
feature['geometry'] = hGeometry
|
49
|
+
geoCollection['features'] << feature
|
50
|
+
end
|
51
|
+
aFeatureCollection << geoCollection
|
52
|
+
|
53
|
+
when 'Feature'
|
54
|
+
collection['features'] << hGeoObj
|
55
|
+
|
56
|
+
when 'FeatureCollection'
|
57
|
+
aFeatureCollection << hGeoObj
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
unless collection['features'].empty?
|
63
|
+
aFeatureCollection << collection
|
64
|
+
end
|
65
|
+
|
21
66
|
end
|
22
67
|
end
|
23
68
|
|
24
|
-
|
69
|
+
aFeatureCollection
|
25
70
|
|
26
71
|
end
|
27
72
|
|
@@ -17,8 +17,9 @@ module ADIWG
|
|
17
17
|
aRepositories.each do |hRepo|
|
18
18
|
if hRepo[:repository] == 'data.gov'
|
19
19
|
repository[:repository] = hRepo[:repository]
|
20
|
-
repository[:title] = 'Data.gov'
|
20
|
+
repository[:title] = 'Data.gov' # default
|
21
21
|
unless hRepo[:citation].empty?
|
22
|
+
repository[:title] = hRepo[:citation][:title] unless hRepo[:citation][:title].nil?
|
22
23
|
unless hRepo[:citation][:identifiers].empty?
|
23
24
|
repository[:identifier] = hRepo[:citation][:identifiers][0][:identifier]
|
24
25
|
end
|
@@ -33,6 +33,13 @@ module ADIWG
|
|
33
33
|
series = hCitation[:series]
|
34
34
|
hPublication[:journal] = series[:seriesName] unless series[:seriesName].nil?
|
35
35
|
hPublication[:edition] = series[:seriesIssue] unless series[:seriesIssue].nil?
|
36
|
+
unless series[:issuePage].nil?
|
37
|
+
hPublication[:parts] = []
|
38
|
+
part = {}
|
39
|
+
part[:type] = 'Page Number'
|
40
|
+
part[:value] = series[:issuePage]
|
41
|
+
hPublication[:parts] << part
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
unless hResource[:defaultResourceLocale].empty?
|
@@ -55,7 +55,7 @@ module ADIWG
|
|
55
55
|
json.webLinks WebLink.build(intObj[:metadata])
|
56
56
|
json.browseCategories BrowseCategory.build(resourceInfo[:resourceTypes])
|
57
57
|
json.tags Tag.build(resourceInfo)
|
58
|
-
json.dates Date.build(
|
58
|
+
json.dates Date.build(resourceInfo) unless resourceInfo.empty?
|
59
59
|
json.spatial Spatial.build(resourceInfo[:extents]) unless resourceInfo[:extents].empty?
|
60
60
|
json.facets Facet.build(intObj[:metadata])
|
61
61
|
json.metadataRepository Repository.build(intObj[:metadataRepositories]) unless intObj[:metadataRepositories].empty?
|
@@ -12,30 +12,48 @@ module ADIWG
|
|
12
12
|
|
13
13
|
def self.build(aExtents)
|
14
14
|
|
15
|
-
spatial = {}
|
16
15
|
aBoxObjects = []
|
17
16
|
|
18
17
|
aExtents.each do |hExtent|
|
19
18
|
hExtent[:geographicExtents].each do |hGeoExtent|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
19
|
+
# use computedBbox if exists
|
20
|
+
# ... this is always exists if geographic extent has objects
|
21
|
+
# otherwise use user provided boundingBox
|
22
|
+
hBbox = {}
|
23
|
+
if hGeoExtent[:computedBbox].empty?
|
24
|
+
unless hGeoExtent[:boundingBox].empty?
|
25
|
+
hBbox = hGeoExtent[:boundingBox]
|
26
|
+
end
|
27
|
+
else
|
28
|
+
hBbox = hGeoExtent[:computedBbox]
|
29
|
+
end
|
30
|
+
|
31
|
+
# turn the box into a polygon
|
32
|
+
unless hBbox.empty?
|
33
|
+
sw = [ hBbox[:westLongitude], hBbox[:southLatitude] ]
|
34
|
+
nw = [ hBbox[:westLongitude], hBbox[:northLatitude] ]
|
35
|
+
ne = [ hBbox[:eastLongitude], hBbox[:northLatitude] ]
|
36
|
+
se = [ hBbox[:eastLongitude], hBbox[:southLatitude] ]
|
37
|
+
aPoly = [ sw, nw, ne, se ]
|
38
|
+
geoJson = {
|
39
|
+
type: 'Polygon',
|
40
|
+
coordinates: [
|
41
|
+
aPoly
|
42
|
+
]
|
43
|
+
}
|
44
|
+
aBoxObjects << geoJson
|
45
|
+
end
|
46
|
+
|
33
47
|
end
|
34
48
|
end
|
35
49
|
|
50
|
+
spatial = {}
|
51
|
+
|
36
52
|
unless aBoxObjects.empty?
|
37
53
|
hBox = AdiwgCoordinates.computeBbox(aBoxObjects)
|
38
54
|
sbBox = {}
|
55
|
+
|
56
|
+
# transform to sbJson bbox format
|
39
57
|
sbBox[:maxY] = hBox[:northLatitude]
|
40
58
|
sbBox[:minY] = hBox[:southLatitude]
|
41
59
|
sbBox[:maxX] = hBox[:eastLongitude]
|
@@ -43,7 +61,7 @@ module ADIWG
|
|
43
61
|
spatial[:boundingBox] = sbBox
|
44
62
|
end
|
45
63
|
|
46
|
-
# representational point is not
|
64
|
+
# sbJson representational point is not provided
|
47
65
|
|
48
66
|
spatial
|
49
67
|
|
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.0.
|
4
|
+
version: 2.0.0rc11
|
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-06-
|
12
|
+
date: 2017-06-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -624,7 +624,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
624
624
|
version: 1.3.1
|
625
625
|
requirements: []
|
626
626
|
rubyforge_project:
|
627
|
-
rubygems_version: 2.
|
627
|
+
rubygems_version: 2.6.8
|
628
628
|
signing_key:
|
629
629
|
specification_version: 4
|
630
630
|
summary: The mdtranslator (metadata translator) is a tool for translating metadata
|