adiwg-mdtranslator 2.0.0rc13 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,56 @@
1
+ # unpack spatial
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 Spatial
15
+
16
+ def self.unpack(hSbJson, hResourceInfo, hResponseObj)
17
+
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
20
+
21
+ if hSbJson.has_key?('spatial')
22
+ unless hSbJson['spatial'].empty?
23
+ # representational point is not mapped
24
+ # map bounding box
25
+ if hSbJson['spatial'].has_key?('boundingBox')
26
+ hSbBbox = hSbJson['spatial']['boundingBox']
27
+ unless hSbBbox.empty?
28
+
29
+ hExtent = intMetadataClass.newExtent
30
+ hGeoExtent = intMetadataClass.newGeographicExtent
31
+ hBbox = intMetadataClass.newBoundingBox
32
+
33
+ hBbox[:westLongitude] = hSbBbox['minX']
34
+ hBbox[:eastLongitude] = hSbBbox['maxX']
35
+ hBbox[:southLatitude] = hSbBbox['minY']
36
+ hBbox[:northLatitude] = hSbBbox['maxY']
37
+
38
+ hGeoExtent[:boundingBox] = hBbox
39
+ hExtent[:geographicExtents] << hGeoExtent
40
+ hResourceInfo[:extents] << hExtent
41
+
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ return hResourceInfo
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,125 @@
1
+ # unpack tag
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-23 original script
6
+
7
+ require 'uri'
8
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module SbJson
14
+
15
+ module Tag
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?('tags')
25
+ aTags = hSbJson['tags']
26
+
27
+ # clean up
28
+ aTags.each do |hTag|
29
+
30
+ # scheme
31
+ if hTag.has_key?('scheme')
32
+ if hTag['scheme'].nil? || hTag['scheme'] == ''
33
+ hTag['scheme'] = 'none'
34
+ end
35
+ else
36
+ hTag['scheme'] = 'none'
37
+ end
38
+ if hTag['scheme'].downcase == 'none'
39
+ hTag['scheme'] = 'none'
40
+ end
41
+ if hTag['scheme'] == 'ISO 19115 Topic Categories'
42
+ hTag['scheme'] = 'none'
43
+ hTag['type'] = 'isoTopicCategory'
44
+ end
45
+
46
+ # type
47
+ if hTag.has_key?('type')
48
+ if hTag['type'].nil? || hTag['type'] == ''
49
+ hTag['type'] = 'none'
50
+ end
51
+ else
52
+ hTag['type'] = 'none'
53
+ end
54
+ if hTag['type'].downcase == 'none'
55
+ hTag['type'] = 'none'
56
+ end
57
+ if hTag['type'] == 'ISO 19115 Topic Categories'
58
+ hTag['scheme'] = 'none'
59
+ hTag['type'] = 'isoTopicCategory'
60
+ end
61
+
62
+ end
63
+
64
+ # group tags by scheme
65
+ aSchemes = aTags.group_by { |t| t['scheme'] }
66
+ aSchemes.each do |aScheme|
67
+
68
+ # group schemes by type
69
+ aThemes = aScheme[1].group_by { |t| t['type'] }
70
+ aThemes.each do |aTheme|
71
+
72
+ if aTheme[0] == 'Resource Type'
73
+ # tags that are 'resource types'
74
+ aTheme[1].each do |hType|
75
+ hResType = intMetadataClass.newResourceType
76
+
77
+ hResType[:type] = hType['name']
78
+ hResourceInfo[:resourceTypes] << hResType
79
+ end
80
+ else
81
+ # tags that are 'keywords'
82
+ hKeyword = intMetadataClass.newKeyword
83
+
84
+ aTheme[1].each do |hKey|
85
+ hKeyObj = intMetadataClass.newKeywordObject
86
+ hKeyObj[:keyword] = hKey['name']
87
+ hKeyword[:keywords] << hKeyObj
88
+ end
89
+
90
+ type = aTheme[1][0]['type']
91
+ unless type == 'none'
92
+ hKeyword[:keywordType] = type
93
+ end
94
+
95
+ scheme = aTheme[1][0]['scheme']
96
+ unless scheme == 'none'
97
+ hThesaurus = intMetadataClass.newCitation
98
+ hThesaurus[:title] = 'Keyword Thesaurus'
99
+ if scheme =~ URI::regexp
100
+ hOlRes = intMetadataClass.newOnlineResource
101
+ hOlRes[:olResURI] = scheme
102
+ hThesaurus[:onlineResources] << hOlRes
103
+ else
104
+ hThesaurus[:alternateTitles] << scheme
105
+ end
106
+ hKeyword[:thesaurus] = hThesaurus
107
+ end
108
+
109
+ hResourceInfo[:keywords] << hKeyword
110
+ end
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ return hResourceInfo
117
+
118
+ end
119
+
120
+ end
121
+
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,99 @@
1
+ # unpack web link (resource)
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
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module SbJson
13
+
14
+ module WebLinkDocument
15
+
16
+ def self.unpack(hSbJson, hResponseObj)
17
+
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
20
+
21
+ aLinks = []
22
+
23
+ if hSbJson.has_key?('webLinks')
24
+
25
+ hSbJson['webLinks'].each do |hLink|
26
+ unless hLink.empty?
27
+
28
+ # web link - type (required)
29
+ type = nil
30
+ if hLink.has_key?('type')
31
+ type = hLink['type']
32
+ end
33
+ if type.nil? || type == ''
34
+ hResponseObj[:readerExecutionMessages] << 'WebLinks type is missing'
35
+ hResponseObj[:readerExecutionPass] = false
36
+ return nil
37
+ end
38
+
39
+ # handle non-browse links
40
+ if type != 'browseImage'
41
+
42
+ hDocument = intMetadataClass.newAdditionalDocumentation
43
+ hResType = intMetadataClass.newResourceType
44
+
45
+ # web link - type
46
+ hResType[:type] = type
47
+
48
+ # web link - type label
49
+ if hLink.has_key?('typeLabel')
50
+ unless hLink['typeLabel'].nil? || hLink['typeLabel'] == ''
51
+ hResType[:name] = hLink['typeLabel']
52
+ end
53
+ end
54
+
55
+ # web link - title
56
+ hCitation = intMetadataClass.newCitation
57
+ if hLink.has_key?('title')
58
+ hCitation[:title] = hLink['title']
59
+ end
60
+ if hCitation[:title].nil? || hCitation[:title] == ''
61
+ hCitation[:title] = 'Online Resource'
62
+ end
63
+
64
+ # web link - uri (required)
65
+ hOlRes = intMetadataClass.newOnlineResource
66
+ if hLink.has_key?('uri')
67
+ hOlRes[:olResURI] = hLink['uri']
68
+ end
69
+ if hOlRes[:olResURI].nil? || hOlRes[:olResURI] == ''
70
+ hResponseObj[:readerExecutionMessages] << 'WebLinks URI is missing'
71
+ hResponseObj[:readerExecutionPass] = false
72
+ return nil
73
+ end
74
+ hCitation[:onlineResources] << hOlRes
75
+
76
+ hDocument[:resourceTypes] << hResType
77
+ hDocument[:citation] << hCitation
78
+ aLinks << hDocument
79
+
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+
86
+ return aLinks
87
+
88
+ end
89
+
90
+ return nil
91
+
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,92 @@
1
+ # unpack web link (graphic)
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
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module SbJson
13
+
14
+ module WebLinkGraphic
15
+
16
+ def self.unpack(hSbJson, hResponseObj)
17
+
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
20
+
21
+ aLinks = []
22
+
23
+ if hSbJson.has_key?('webLinks')
24
+
25
+ hSbJson['webLinks'].each do |hLink|
26
+ unless hLink.empty?
27
+
28
+ # web link - type (required)
29
+ type = nil
30
+ if hLink.has_key?('type')
31
+ type = hLink['type']
32
+ end
33
+ if type.nil? || type == ''
34
+ hResponseObj[:readerExecutionMessages] << 'WebLinks type is missing'
35
+ hResponseObj[:readerExecutionPass] = false
36
+ return nil
37
+ end
38
+
39
+ # only handle browse links
40
+ if type == 'browseImage'
41
+
42
+ hGraphic = intMetadataClass.newGraphic
43
+
44
+ # web link - type
45
+ hGraphic[:graphicType] = type
46
+
47
+ # web link - type label
48
+ if hLink.has_key?('typeLabel')
49
+ unless hLink['typeLabel'].nil? || hLink['typeLabel'] == ''
50
+ hGraphic[:graphicDescription] = hLink['typeLabel']
51
+ end
52
+ end
53
+
54
+ # web link - title
55
+ if hLink.has_key?('title')
56
+ hGraphic[:graphicName] = hLink['title']
57
+ end
58
+
59
+ # web link - uri (required)
60
+ hOlRes = intMetadataClass.newOnlineResource
61
+ if hLink.has_key?('uri')
62
+ hOlRes[:olResURI] = hLink['uri']
63
+ end
64
+ if hOlRes[:olResURI].nil? || hOlRes[:olResURI] == ''
65
+ hResponseObj[:readerExecutionMessages] << 'WebLinks URI is missing'
66
+ hResponseObj[:readerExecutionPass] = false
67
+ return nil
68
+ end
69
+ hGraphic[:graphicURI] << hOlRes
70
+
71
+ aLinks << hGraphic
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+
79
+ return aLinks
80
+
81
+ end
82
+
83
+ return nil
84
+
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+ end
91
+ end
92
+ end
@@ -1,6 +1,7 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.0.0 2017-06-28 added sbJson reader
4
5
  # 2.0.0rc13 2017-06-16 apply changes to sbJson writer after fourth review session
5
6
  # 2.0.0rc12 2017-06-14 apply changes to sbJson writer after third review session
6
7
  # 2.0.0rc11 2017-06-08 apply changes to sbJson writer after second review session
@@ -20,7 +21,7 @@
20
21
  module ADIWG
21
22
  module Mdtranslator
22
23
  # current mdtranslator version
23
- VERSION = "2.0.0rc13"
24
+ VERSION = "2.0.0"
24
25
  end
25
26
  end
26
27
 
@@ -163,7 +163,12 @@ if ( typeof L === "object") {
163
163
  var header = geoExtent.querySelector('summary.map-summary');
164
164
  // get the GeoJSON from the geojson div
165
165
  var geoJsonDiv = geoExtent.querySelector('div.geojson');
166
- var geojson = JSON.parse(geoJsonDiv.textContent || geoJsonDiv.innerText);
166
+ if (geoJsonDiv) {
167
+ var geojson = JSON.parse(geoJsonDiv.textContent || geoJsonDiv.innerText);
168
+ }
169
+ else {
170
+ var geojson = [];
171
+ }
167
172
  // get the user provided bounding box for the extent - if any
168
173
  var userBBox = geoExtent.querySelector('div.userBBox');
169
174
  if (userBBox) {
@@ -33,9 +33,13 @@ module ADIWG
33
33
  onlineClass = Html_OnlineResource.new(@html)
34
34
  graphicClass = Html_Graphic.new(@html)
35
35
 
36
- # citation - title - required
36
+ # citation - title
37
37
  @html.em('Title: ')
38
- @html.text!(hCitation[:title])
38
+ unless hCitation[:title].nil?
39
+ @html.text!(hCitation[:title])
40
+ else
41
+ @html.text!('*MISSING*')
42
+ end
39
43
  @html.br
40
44
 
41
45
  # citation - alternate title
@@ -60,7 +60,7 @@ module ADIWG
60
60
  'xmlns:gfc' => 'http://www.isotc211.org/2005/gfc',
61
61
  'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
62
62
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
63
- 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc C:\Users\StanSmith\Projects\ISO\19115\NOAA\schema\gfc\gfc.xsd'}) do
63
+ 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc ftp://ftp.ncddc.noaa.gov/pub/Metadata/Online_ISO_Training/Intro_to_ISO/schemas/ISObio/gfc/gfc.xsd'}) do
64
64
 
65
65
  # local schema for development
66
66
  # 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc C:\Users\StanSmith\Projects\ISO\19115\NOAA\schema\gfc\gfc.xsd'}) do
@@ -202,4 +202,3 @@ module ADIWG
202
202
  end
203
203
  end
204
204
  end
205
-
@@ -14,25 +14,52 @@ module ADIWG
14
14
 
15
15
  def self.build(aFunding)
16
16
 
17
+ @Namespace = ADIWG::Mdtranslator::Writers::SbJson
18
+
17
19
  hBudget = {}
18
20
  hBudget[:className] = 'gov.sciencebase.catalog.item.facet.BudgetFacet'
19
21
  hBudget[:annualBudgets] = []
20
22
 
21
23
  aFunding.each do |hFunding|
22
24
  budget = {}
25
+
26
+ # funding sources
23
27
  fundingSources = []
28
+ total = 0.0
24
29
  hFunding[:allocations].each do |hAllocation|
25
30
  hSource = {}
26
31
  hSource[:amount] = hAllocation[:amount] unless hAllocation[:amount].nil?
32
+ total += hAllocation[:amount] unless hAllocation[:amount].nil?
27
33
  hSource[:matching] = hAllocation[:matching].to_s
28
- hSource[:recipient] = hAllocation[:recipientId] unless hAllocation[:recipientId].nil?
29
- hSource[:source] = hAllocation[:sourceId] unless hAllocation[:sourceId].nil?
34
+
35
+ # recipient id
36
+ unless hAllocation[:recipientId].nil?
37
+ hContact = @Namespace.get_contact_by_id(hAllocation[:recipientId])
38
+ unless hContact.empty?
39
+ hSource[:recipient] = hContact[:name]
40
+ end
41
+ end
42
+
43
+ # source id
44
+ unless hAllocation[:sourceId].nil?
45
+ hContact = @Namespace.get_contact_by_id(hAllocation[:sourceId])
46
+ unless hContact.empty?
47
+ hSource[:source] = hContact[:name]
48
+ end
49
+ end
50
+
30
51
  fundingSources << hSource
31
52
  end
32
53
  unless fundingSources.empty?
33
54
  budget[:fundingSources] = fundingSources
34
55
  end
35
56
 
57
+ # total funds
58
+ unless total == 0.0
59
+ budget[:totalFunds] = total
60
+ end
61
+
62
+ # year
36
63
  # give priority to ending dateTime
37
64
  # write year only
38
65
  # use fiscal year beginning October 1