adiwg-mdtranslator 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -1
- data/adiwg-mdtranslator.gemspec +2 -2
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +66 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +7 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +36 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +21 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb +70 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb +132 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb +65 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_boundingBox.rb +116 -86
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicExtent.rb +91 -83
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_codelists.rb +22 -12
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_contact.rb +7 -9
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_extent.rb +1 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_relatedItem.rb +24 -13
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkDocument.rb +4 -5
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkGraphic.rb +3 -4
- data/lib/adiwg/mdtranslator/version.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_boundingBox.rb +22 -4
- data/lib/adiwg/mdtranslator/writers/html/sections/html_geographicExtent.rb +8 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_boundingBox.rb +5 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicExtent.rb +4 -2
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +2 -0
- metadata +10 -7
@@ -151,26 +151,36 @@ module ADIWG
|
|
151
151
|
{sb: 'Proposed', adiwg: 'proposed'}
|
152
152
|
]
|
153
153
|
|
154
|
-
|
154
|
+
# mdJson/mdTranslator view point is always: how the associated resource relates to the main resource
|
155
|
+
# dropped 'copiedFrom', 'copiedInfo' from translation tables
|
156
|
+
|
157
|
+
# scienceBaseId = relatedItemId (forward)
|
158
|
+
# assoc2main = the associated resource is (a) ___ of the main resource
|
159
|
+
# example = the associated resource is 'constituentOf' the main resource
|
160
|
+
# so the adiwg equivalent is 'ifPartOf'
|
161
|
+
@association_sb2adiwg_assoc2main = [
|
155
162
|
{sb: 'alternate', adiwg: 'alternate'},
|
156
|
-
{sb: 'constituentOf', adiwg: '
|
157
|
-
{sb: '
|
158
|
-
{sb: '
|
159
|
-
{sb: 'precededBy', adiwg: 'precededBy'},
|
163
|
+
{sb: 'constituentOf', adiwg: 'isPartOf'},
|
164
|
+
{sb: 'derivativeOf', adiwg: 'derivativeResource'},
|
165
|
+
{sb: 'precededBy', adiwg: 'series'},
|
160
166
|
{sb: 'productOf', adiwg: 'product'},
|
161
167
|
{sb: 'related', adiwg: 'crossReference'},
|
162
168
|
{sb: 'subprojectOf', adiwg: 'subProject'}
|
163
169
|
]
|
164
170
|
|
165
|
-
|
171
|
+
# scienceBaseId = itemId (reverse)
|
172
|
+
# main2assoc = the main resource is (a) ___ of the associated resource
|
173
|
+
# example = the main resource is 'constituentOf' the associated resource
|
174
|
+
# reverse the direction for mdJson/mdTranslator which is mono-directional
|
175
|
+
# so the adiwg equivalent is 'isComposedOf'
|
176
|
+
@association_sb2adiwg_main2assoc = [
|
166
177
|
{sb: 'alternate', adiwg: 'alternate'},
|
167
|
-
{sb: '
|
168
|
-
{sb: '
|
169
|
-
{sb: '
|
170
|
-
{sb: '
|
171
|
-
{sb: 'produced', adiwg: 'product'},
|
178
|
+
{sb: 'constituentOf', adiwg: 'isComposedOf'},
|
179
|
+
{sb: 'derivativeOf', adiwg: 'source'},
|
180
|
+
{sb: 'precededBy', adiwg: 'series'},
|
181
|
+
{sb: 'productOf', adiwg: 'parentProject'},
|
172
182
|
{sb: 'related', adiwg: 'crossReference'},
|
173
|
-
{sb: '
|
183
|
+
{sb: 'subprojectOf', adiwg: 'parentProject'}
|
174
184
|
]
|
175
185
|
|
176
186
|
# translate iso/adiwg code to sb
|
@@ -87,20 +87,19 @@ module ADIWG
|
|
87
87
|
hContact[:contactId] = UUIDTools::UUID.random_create.to_s
|
88
88
|
|
89
89
|
# contact - contactType [ person | organization ]
|
90
|
+
hContact[:isOrganization] = false
|
90
91
|
if hSbContact.has_key?('contactType')
|
91
92
|
if hSbContact['contactType'].nil? || hSbContact['contactType'] == ''
|
92
|
-
hResponseObj[:readerExecutionMessages] << 'Contact contactType is
|
93
|
-
hContact[:isOrganization] = false
|
93
|
+
hResponseObj[:readerExecutionMessages] << 'Contact contactType is empty, default to "person"'
|
94
94
|
elsif %w(person organization).include?(hSbContact['contactType'])
|
95
95
|
hContact[:isOrganization] = true if hSbContact['contactType'] == 'organization'
|
96
96
|
else
|
97
|
-
hResponseObj[:readerExecutionMessages] <<
|
98
|
-
hResponseObj[:
|
99
|
-
return nil
|
97
|
+
hResponseObj[:readerExecutionMessages] << "Contact contactType cannot be '#{hSbContact['contactType']}'"
|
98
|
+
hResponseObj[:readerExecutionMessages] << "Contact contactType set to 'person'"
|
100
99
|
end
|
101
100
|
else
|
102
101
|
hResponseObj[:readerExecutionMessages] << 'Contact contactType is missing'
|
103
|
-
|
102
|
+
hResponseObj[:readerExecutionMessages] << "Contact contactType set to 'person'"
|
104
103
|
end
|
105
104
|
|
106
105
|
# contact - name (required)
|
@@ -108,8 +107,7 @@ module ADIWG
|
|
108
107
|
hContact[:name] = hSbContact['name']
|
109
108
|
end
|
110
109
|
if hSbContact['name'].nil? || hSbContact['name'] == ''
|
111
|
-
hResponseObj[:readerExecutionMessages] << 'Contact name is missing'
|
112
|
-
hResponseObj[:readerExecutionPass] = false
|
110
|
+
hResponseObj[:readerExecutionMessages] << 'Contact name is missing, contact dropped'
|
113
111
|
return nil
|
114
112
|
end
|
115
113
|
|
@@ -254,7 +252,7 @@ module ADIWG
|
|
254
252
|
aContacts << hContact
|
255
253
|
aContacts << hContactOrg unless hContactOrg.empty?
|
256
254
|
|
257
|
-
# add contact to
|
255
|
+
# add contact to resourceInfo citation
|
258
256
|
hResponsibility = intMetadataClass.newResponsibility
|
259
257
|
roleType = Codelists.codelist_sb2adiwg('role_sb2adiwg', hContact[:contactType])
|
260
258
|
roleType = hContact[:contactType] if roleType.nil?
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# Reader - ScienceBase JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-10-11 revise forward and reverse association definition
|
5
6
|
# Stan Smith 2017-09-14 remove all identifiers except relatedItemId
|
6
7
|
# Stan Smith 2017-08-03 original script
|
7
8
|
|
@@ -68,23 +69,30 @@ module ADIWG
|
|
68
69
|
unless hItem.empty?
|
69
70
|
|
70
71
|
# determine relationship direction
|
72
|
+
# forward: how the associated resource relates to the main resource
|
73
|
+
# ... in other words - the relationship is defined in terms of the associated resource
|
74
|
+
# ... example: the associated resource is a 'subProject' of the main resource
|
75
|
+
# reverse: how the main resource relates to the associated resource
|
76
|
+
# ... in other words - the relationship is defined in terms of the main resource
|
77
|
+
# ... example: the main resource is the 'parentProject' of the associated resource
|
78
|
+
# all mdJson/mdTranslator relationships must be expressed as forward
|
71
79
|
forward = nil
|
72
80
|
if hItem.has_key?('itemId')
|
73
|
-
forward =
|
81
|
+
forward = false if sbId == hItem['itemId']
|
74
82
|
end
|
75
83
|
if hItem.has_key?('relatedItemId')
|
76
|
-
forward =
|
84
|
+
forward = true if sbId == hItem['relatedItemId']
|
77
85
|
end
|
78
86
|
if forward.nil?
|
79
87
|
hResponseObj[:readerExecutionMessages] << 'Main ScienceBase id was not referenced in related item'
|
80
88
|
return hMetadata
|
81
89
|
end
|
82
90
|
|
83
|
-
# fetch resourceTypes from related item
|
91
|
+
# fetch resourceTypes from related item's record
|
84
92
|
if forward
|
85
|
-
resourceId = hItem['relatedItemId']
|
86
|
-
else
|
87
93
|
resourceId = hItem['itemId']
|
94
|
+
else
|
95
|
+
resourceId = hItem['relatedItemId']
|
88
96
|
end
|
89
97
|
resourceLink = "https://www.sciencebase.gov/catalog/item/#{resourceId}?format=json"
|
90
98
|
begin
|
@@ -117,9 +125,9 @@ module ADIWG
|
|
117
125
|
unless sbAssocType.nil? || sbAssocType == ''
|
118
126
|
assocType = nil
|
119
127
|
if forward
|
120
|
-
assocType = Codelists.codelist_sb2adiwg('
|
128
|
+
assocType = Codelists.codelist_sb2adiwg('association_sb2adiwg_assoc2main', sbAssocType)
|
121
129
|
else
|
122
|
-
assocType = Codelists.codelist_sb2adiwg('
|
130
|
+
assocType = Codelists.codelist_sb2adiwg('association_sb2adiwg_main2assoc', sbAssocType)
|
123
131
|
end
|
124
132
|
if assocType.nil?
|
125
133
|
hResource[:associationType] = sbAssocType
|
@@ -134,12 +142,15 @@ module ADIWG
|
|
134
142
|
|
135
143
|
# fill in associated resource citation
|
136
144
|
hCitation = intMetadataClass.newCitation
|
137
|
-
citationTitle =
|
138
|
-
if
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
145
|
+
citationTitle = 'associated resource title'
|
146
|
+
if forward
|
147
|
+
if hItem.has_key?('title')
|
148
|
+
citationTitle = hItem['title']
|
149
|
+
end
|
150
|
+
else
|
151
|
+
if hItem.has_key?('relatedItemTitle')
|
152
|
+
citationTitle = hItem['relatedItemTitle']
|
153
|
+
end
|
143
154
|
end
|
144
155
|
hCitation[:title] = citationTitle
|
145
156
|
|
@@ -31,9 +31,8 @@ module ADIWG
|
|
31
31
|
type = hLink['type']
|
32
32
|
end
|
33
33
|
if type.nil? || type == ''
|
34
|
-
hResponseObj[:readerExecutionMessages] << '
|
35
|
-
|
36
|
-
return nil
|
34
|
+
hResponseObj[:readerExecutionMessages] << 'WebLink type is missing, set to "unknown"'
|
35
|
+
type = 'unknown'
|
37
36
|
end
|
38
37
|
|
39
38
|
# handle non-browse links
|
@@ -67,8 +66,8 @@ module ADIWG
|
|
67
66
|
hOlRes[:olResURI] = hLink['uri']
|
68
67
|
end
|
69
68
|
if hOlRes[:olResURI].nil? || hOlRes[:olResURI] == ''
|
70
|
-
hResponseObj[:readerExecutionMessages] << '
|
71
|
-
hResponseObj[:
|
69
|
+
hResponseObj[:readerExecutionMessages] << 'WebLink URI is missing'
|
70
|
+
hResponseObj[:readerExecutionMessages] << 'WebLink skipped'
|
72
71
|
return nil
|
73
72
|
end
|
74
73
|
hCitation[:onlineResources] << hOlRes
|
@@ -31,8 +31,7 @@ module ADIWG
|
|
31
31
|
type = hLink['type']
|
32
32
|
end
|
33
33
|
if type.nil? || type == ''
|
34
|
-
hResponseObj[:readerExecutionMessages] << '
|
35
|
-
hResponseObj[:readerExecutionPass] = false
|
34
|
+
hResponseObj[:readerExecutionMessages] << 'WebLink type is missing'
|
36
35
|
return nil
|
37
36
|
end
|
38
37
|
|
@@ -62,8 +61,8 @@ module ADIWG
|
|
62
61
|
hOlRes[:olResURI] = hLink['uri']
|
63
62
|
end
|
64
63
|
if hOlRes[:olResURI].nil? || hOlRes[:olResURI] == ''
|
65
|
-
hResponseObj[:readerExecutionMessages] << '
|
66
|
-
hResponseObj[:
|
64
|
+
hResponseObj[:readerExecutionMessages] << 'WebLink URI is missing'
|
65
|
+
hResponseObj[:readerExecutionMessages] << 'WebLink skipped'
|
67
66
|
return nil
|
68
67
|
end
|
69
68
|
hGraphic[:graphicURI] << hOlRes
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# adiwg mdTranslator
|
2
2
|
|
3
3
|
# version 2 history
|
4
|
+
# 2.3.3 2017-10-03 modify sbJson reader execution fail tests
|
4
5
|
# 2.3.2 2017-09-14 add associationType to sbJson relatedItems
|
5
6
|
# 2.3.2 2017-09-14 add contacts to resource citation
|
6
7
|
# 2.3.1 2017-09-13 fixed fgdc reader: removed conversion of hash to json
|
@@ -28,7 +29,7 @@
|
|
28
29
|
module ADIWG
|
29
30
|
module Mdtranslator
|
30
31
|
# current mdtranslator version
|
31
|
-
VERSION = "2.3.
|
32
|
+
VERSION = "2.3.3"
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -19,29 +19,47 @@ module ADIWG
|
|
19
19
|
|
20
20
|
# bounding box - edges
|
21
21
|
unless hBox[:westLongitude].nil?
|
22
|
-
@html.em('West Longitude')
|
22
|
+
@html.em('West Longitude:')
|
23
23
|
@html.text!(hBox[:westLongitude].to_s)
|
24
24
|
@html.br
|
25
25
|
end
|
26
26
|
|
27
27
|
unless hBox[:eastLongitude].nil?
|
28
|
-
@html.em('East Longitude')
|
28
|
+
@html.em('East Longitude:')
|
29
29
|
@html.text!(hBox[:eastLongitude].to_s)
|
30
30
|
@html.br
|
31
31
|
end
|
32
32
|
|
33
33
|
unless hBox[:southLatitude].nil?
|
34
|
-
@html.em('South Latitude')
|
34
|
+
@html.em('South Latitude:')
|
35
35
|
@html.text!(hBox[:southLatitude].to_s)
|
36
36
|
@html.br
|
37
37
|
end
|
38
38
|
|
39
39
|
unless hBox[:northLatitude].nil?
|
40
|
-
@html.em('North Latitude')
|
40
|
+
@html.em('North Latitude:')
|
41
41
|
@html.text!(hBox[:northLatitude].to_s)
|
42
42
|
@html.br
|
43
43
|
end
|
44
44
|
|
45
|
+
unless hBox[:minimumAltitude].nil?
|
46
|
+
@html.em('Minimum Altitude:')
|
47
|
+
@html.text!(hBox[:minimumAltitude].to_s)
|
48
|
+
@html.br
|
49
|
+
end
|
50
|
+
|
51
|
+
unless hBox[:maximumAltitude].nil?
|
52
|
+
@html.em('Maximum Altitude:')
|
53
|
+
@html.text!(hBox[:maximumAltitude].to_s)
|
54
|
+
@html.br
|
55
|
+
end
|
56
|
+
|
57
|
+
unless hBox[:unitsOfAltitude].nil?
|
58
|
+
@html.em('Altitude Units of Measure:')
|
59
|
+
@html.text!(hBox[:unitsOfAltitude].to_s)
|
60
|
+
@html.br
|
61
|
+
end
|
62
|
+
|
45
63
|
end # writeHtml
|
46
64
|
end # Html_BoundingBox
|
47
65
|
|
@@ -33,6 +33,14 @@ module ADIWG
|
|
33
33
|
@html.text!(hExtent[:containsData].to_s)
|
34
34
|
@html.br
|
35
35
|
|
36
|
+
# geographic extent - description
|
37
|
+
unless hExtent[:description].nil?
|
38
|
+
@html.em('Geographic Description: ')
|
39
|
+
@html.section(:class => 'block') do
|
40
|
+
@html.text!(hExtent[:description])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
36
44
|
# geographic extent - map {div}
|
37
45
|
@html.details do
|
38
46
|
@html.summary('Map', 'class' => 'h5 map-summary')
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# mdJson 2.0 writer - bounding box
|
2
2
|
|
3
3
|
# History:
|
4
|
-
#
|
4
|
+
# Stan Smith 2017-09-08 add altitude to support fgdc
|
5
|
+
# Stan Smith 2017-03-15 original script
|
5
6
|
|
6
7
|
require 'jbuilder'
|
7
8
|
|
@@ -19,6 +20,9 @@ module ADIWG
|
|
19
20
|
json.eastLongitude hBbox[:eastLongitude]
|
20
21
|
json.southLatitude hBbox[:southLatitude]
|
21
22
|
json.northLatitude hBbox[:northLatitude]
|
23
|
+
json.minimumAltitude hBbox[:minimumAltitude]
|
24
|
+
json.maximumAltitude hBbox[:maximumAltitude]
|
25
|
+
json.unitsOfAltitude hBbox[:unitsOfAltitude]
|
22
26
|
end
|
23
27
|
|
24
28
|
end # build
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# mdJson 2.0 writer - geographic extent
|
2
2
|
|
3
3
|
# History:
|
4
|
-
#
|
5
|
-
#
|
4
|
+
# Stan Smith 2017-09-28 add description to support fgdc
|
5
|
+
# Stan Smith 2017-03-15 refactored for mdJson/mdTranslator 2.0
|
6
|
+
# Josh Bradley original script
|
6
7
|
|
7
8
|
require 'jbuilder'
|
8
9
|
require_relative 'mdJson_identifier'
|
@@ -18,6 +19,7 @@ module ADIWG
|
|
18
19
|
def self.build(hGeographic)
|
19
20
|
|
20
21
|
Jbuilder.new do |json|
|
22
|
+
json.description hGeographic[:description]
|
21
23
|
json.containsData hGeographic[:containsData]
|
22
24
|
json.identifier Identifier.build(hGeographic[:identifier]) unless hGeographic[:identifier].empty?
|
23
25
|
json.boundingBox BoundingBox.build(hGeographic[:boundingBox]) unless hGeographic[:boundingBox].empty?
|
@@ -154,6 +154,8 @@ module ADIWG
|
|
154
154
|
{adiwg: 'withdrawn', sb: nil}
|
155
155
|
]
|
156
156
|
|
157
|
+
# related items are not written back to sbJson
|
158
|
+
# so this table has not been used, review before using
|
157
159
|
@association_adiwg2sb = [
|
158
160
|
{adiwg: 'alternate', sb: 'alternate'},
|
159
161
|
{adiwg: 'collectiveTitle', sb: nil},
|
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.3.
|
4
|
+
version: 2.3.3
|
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-
|
12
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -129,28 +129,28 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: 2.3.2
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: 2.3.2
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: adiwg-mdcodes
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: 2.3.2
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
151
|
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
153
|
+
version: 2.3.2
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: jbuilder
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,6 +270,9 @@ files:
|
|
270
270
|
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb
|
271
271
|
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialOrganization.rb
|
272
272
|
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialReference.rb
|
273
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb
|
274
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb
|
275
|
+
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb
|
273
276
|
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_timeInstant.rb
|
274
277
|
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb
|
275
278
|
- lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb
|
@@ -712,7 +715,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
712
715
|
version: '0'
|
713
716
|
requirements: []
|
714
717
|
rubyforge_project:
|
715
|
-
rubygems_version: 2.
|
718
|
+
rubygems_version: 2.6.12
|
716
719
|
signing_key:
|
717
720
|
specification_version: 4
|
718
721
|
summary: The mdtranslator (metadata translator) is a tool for translating metadata
|