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
@@ -4,6 +4,8 @@
4
4
  # History:
5
5
  # Stan Smith 2016-06-14 original script
6
6
 
7
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
8
+
7
9
  module ADIWG
8
10
  module Mdtranslator
9
11
  module Readers
@@ -11,19 +13,24 @@ module ADIWG
11
13
 
12
14
  module Id
13
15
 
14
- def self.unpack(hSbJson, hIdentifier, hResponseObj)
16
+ def self.unpack(hSbJson, hResponseObj)
17
+
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
15
20
 
16
- # title
17
21
  if hSbJson.has_key?('id')
22
+ hIdentifier = intMetadataClass.newIdentifier
23
+
18
24
  sbId = hSbJson['id']
19
25
  unless sbId.nil? || sbId == ''
20
26
  hIdentifier[:identifier] = sbId
21
27
  hIdentifier[:namespace] = 'gov.sciencebase.catalog'
22
28
  hIdentifier[:description] = 'USGS ScienceBase Identifier'
29
+ return hIdentifier
23
30
  end
24
31
  end
25
32
 
26
- return hIdentifier
33
+ return nil
27
34
 
28
35
  end
29
36
 
@@ -13,25 +13,27 @@ module ADIWG
13
13
 
14
14
  module Identifier
15
15
 
16
- # instance classes needed in script
17
- @intMetadataClass = InternalMetadata.new
18
-
19
16
  def self.unpack(hSbJson, hCitation, hResponseObj)
20
17
 
21
- hSbJson['identifiers'].each_with_index do |hSbIdentifier, i|
22
- hIdentifier = @intMetadataClass.newIdentifier
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
23
20
 
24
- unless hSbIdentifier['type'].nil? || hSbIdentifier['type'] == ''
25
- hIdentifier[:description] = hSbIdentifier['type']
26
- end
27
- unless hSbIdentifier['scheme'].nil? || hSbIdentifier['scheme'] == ''
28
- hIdentifier[:namespace] = hSbIdentifier['scheme']
29
- end
30
- unless hSbIdentifier['key'].nil? || hSbIdentifier['key'] == ''
31
- hIdentifier[:identifier] = hSbIdentifier['key']
32
- end
21
+ if hSbJson.has_key?('identifiers')
22
+ hSbJson['identifiers'].each_with_index do |hSbIdentifier, i|
23
+ hIdentifier = intMetadataClass.newIdentifier
24
+
25
+ unless hSbIdentifier['type'].nil? || hSbIdentifier['type'] == ''
26
+ hIdentifier[:description] = hSbIdentifier['type']
27
+ end
28
+ unless hSbIdentifier['scheme'].nil? || hSbIdentifier['scheme'] == ''
29
+ hIdentifier[:namespace] = hSbIdentifier['scheme']
30
+ end
31
+ unless hSbIdentifier['key'].nil? || hSbIdentifier['key'] == ''
32
+ hIdentifier[:identifier] = hSbIdentifier['key']
33
+ end
33
34
 
34
- hCitation[:identifiers] << hIdentifier
35
+ hCitation[:identifiers] << hIdentifier
36
+ end
35
37
  end
36
38
 
37
39
  return hCitation
@@ -0,0 +1,72 @@
1
+ # unpack material request instructions
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 MaterialRequest
16
+
17
+ def self.unpack(hSbJson, hResponseObj)
18
+
19
+ # instance classes needed in script
20
+ intMetadataClass = InternalMetadata.new
21
+
22
+ if hSbJson.has_key?('materialRequestInstructions')
23
+ sbRequest = hSbJson['materialRequestInstructions']
24
+ unless sbRequest.nil? || sbRequest == ''
25
+
26
+ # make a new request contact
27
+ hContact = intMetadataClass.newContact
28
+ hContact[:contactId] = UUIDTools::UUID.random_create.to_s
29
+ hContact[:name] = 'U.S. Geological Survey ScienceBase'
30
+ hContact[:contactType] = 'materialRequestInstructions'
31
+
32
+ # make a new distribution record
33
+ hDistribution = intMetadataClass.newDistribution
34
+ hDistributor = intMetadataClass.newDistributor
35
+ hResponsibility = intMetadataClass.newResponsibility
36
+ hParty = intMetadataClass.newParty
37
+ hProcess = intMetadataClass.newOrderProcess
38
+
39
+ # parties [] {party}
40
+ hParty[:contactId] = hContact[:contactId]
41
+ hParty[:contactType] = 'ScienceBase'
42
+
43
+ # contact {responsibility}
44
+ hResponsibility[:roleName] = 'distributor'
45
+ hResponsibility[:parties] << hParty
46
+
47
+ # orderProcess {orderProcess}
48
+ hProcess[:orderingInstructions] = sbRequest
49
+
50
+ # distributor {distributor}
51
+ hDistributor[:contact] = hResponsibility
52
+ hDistributor[:orderProcess] << hProcess
53
+
54
+ # distribution {distribution}
55
+ hDistribution[:description] = 'sbJson Material Request distributor generated by ADIwg mdTranslator'
56
+ hDistribution[:distributor] << hDistributor
57
+
58
+ return hContact, hDistribution
59
+
60
+ end
61
+ end
62
+
63
+ return nil
64
+
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,44 @@
1
+ # unpack parent id
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-21 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 ParentId
15
+
16
+ def self.unpack(hSbJson, hResponseObj)
17
+
18
+ # instance classes needed in script
19
+ intMetadataClass = InternalMetadata.new
20
+
21
+ if hSbJson.has_key?('parentId')
22
+ sbId = hSbJson['parentId']
23
+ unless sbId.nil? || sbId == ''
24
+ hCitation = intMetadataClass.newCitation
25
+ hIdentifier = intMetadataClass.newIdentifier
26
+ hCitation[:title] = 'U.S. Geological Survey ScienceBase parent identifier'
27
+ hIdentifier[:identifier] = sbId
28
+ hIdentifier[:namespace] = 'gov.sciencebase.catalog'
29
+ hIdentifier[:description] = 'USGS ScienceBase Identifier'
30
+ hCitation[:identifiers] << hIdentifier
31
+ return hCitation
32
+ end
33
+ end
34
+
35
+ return nil
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,48 @@
1
+ # unpack project facet
2
+ # Reader - ScienceBase JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2016-06-27 original script
6
+
7
+ require 'adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module SbJson
13
+
14
+ module Project
15
+
16
+ @Namespace = ADIWG::Mdtranslator::Writers::SbJson
17
+
18
+ def self.unpack(hFacet, hResourceInfo, hResponseObj)
19
+
20
+ # project status
21
+ if hFacet.has_key?('projectStatus')
22
+ unless hFacet['projectStatus'].nil? || ['projectStatus'] == ''
23
+ sbStatus = hFacet['projectStatus']
24
+ status = @Namespace::Codelists.codelist_iso_to_sb('iso_sb_progress', :sbCode => sbStatus)
25
+ status = status.nil? ? sbStatus : status
26
+ hResourceInfo[:status] << status
27
+ end
28
+ end
29
+
30
+ # short abstract
31
+ if hFacet.has_key?('parts')
32
+ hFacet['parts'].each do |hPart|
33
+ if hPart['type'] == 'Short Project Description'
34
+ hResourceInfo[:shortAbstract] = hPart['value']
35
+ end
36
+ end
37
+ end
38
+
39
+ return hResourceInfo
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,77 @@
1
+ # unpack citation 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
+ require 'adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module SbJson
14
+
15
+ module Publication
16
+
17
+ def self.unpack(hFacet, hResourceInfo, hCitation, hResponseObj)
18
+
19
+ @Namespace = ADIWG::Mdtranslator::Writers::SbJson
20
+
21
+ # instance classes needed in script
22
+ intMetadataClass = InternalMetadata.new
23
+
24
+ # set resource type
25
+ if hFacet.has_key?('citationType')
26
+ unless hFacet['citationType'].nil? || hFacet['citationType'] == ''
27
+ hResType = intMetadataClass.newResourceType
28
+ sbType = hFacet['citationType']
29
+ type = @Namespace::Codelists.codelist_iso_to_sb('iso_sb_scope', :sbCode => sbType)
30
+ type = type.nil? ? sbType : type
31
+ hResType[:type] = type
32
+ hResType[:name] = sbType
33
+ hResourceInfo[:resourceTypes] << hResType
34
+ end
35
+ end
36
+
37
+ # set citation
38
+ hSeries = intMetadataClass.newSeries
39
+ if hFacet.has_key?('note')
40
+ unless hFacet['note'].nil? || hFacet['note'] == ''
41
+ i = hCitation[:otherDetails].length
42
+ hCitation[:otherDetails][i] = hFacet['note']
43
+ end
44
+ end
45
+ if hFacet.has_key?('journal')
46
+ unless hFacet['journal'].nil? || hFacet['journal'] == ''
47
+ hSeries[:seriesName] = hFacet['journal']
48
+ end
49
+ end
50
+ if hFacet.has_key?('edition')
51
+ unless hFacet['edition'].nil? || hFacet['edition'] == ''
52
+ hSeries[:seriesIssue] = hFacet['edition']
53
+ end
54
+ end
55
+ unless hSeries.empty?
56
+ hCitation[:series] = hSeries
57
+ end
58
+
59
+ # set default language
60
+ if hFacet.has_key?('language')
61
+ unless hFacet['language'].nil? || hFacet['language'] == ''
62
+ hLocale = intMetadataClass.newLocale
63
+ hLocale[:languageCode] = hFacet['language']
64
+ hResourceInfo[:defaultResourceLocale] = hLocale
65
+ end
66
+ end
67
+
68
+ return hResourceInfo, hCitation
69
+
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end
@@ -14,6 +14,19 @@ require_relative 'module_identifier'
14
14
  require_relative 'module_purpose'
15
15
  require_relative 'module_rights'
16
16
  require_relative 'module_provenance'
17
+ require_relative 'module_materialRequest'
18
+ require_relative 'module_parentId'
19
+ require_relative 'module_contact'
20
+ require_relative 'module_webLinkDocument'
21
+ require_relative 'module_webLinkGraphic'
22
+ require_relative 'module_browseCategory'
23
+ require_relative 'module_tag'
24
+ require_relative 'module_date'
25
+ require_relative 'module_spatial'
26
+ require_relative 'module_budget'
27
+ require_relative 'module_publication'
28
+ require_relative 'module_project'
29
+ require_relative 'module_extent'
17
30
 
18
31
  module ADIWG
19
32
  module Mdtranslator
@@ -34,17 +47,18 @@ module ADIWG
34
47
  hMetadataInfo = intMetadataClass.newMetadataInfo
35
48
  hResourceInfo = intMetadataClass.newResourceInfo
36
49
  hCitation = intMetadataClass.newCitation
50
+ hSchema = intMetadataClass.newSchema
37
51
 
38
- hResourceInfo[:citation] = hCitation
39
- hMetadata[:metadataInfo] = hMetadataInfo
40
- hMetadata[:resourceInfo] = hResourceInfo
41
- intObj[:metadata] = hMetadata
52
+ # schema
53
+ hSchema[:name] = hSbJson['schema']['name']
54
+ hSchema[:version] = hSbJson['schema']['version']
42
55
 
43
56
  # titles / alternateTitles
44
57
  Title.unpack(hSbJson, hCitation, hResponseObj)
45
58
 
46
59
  # id
47
- Id.unpack(hSbJson, hMetadataInfo[:metadataIdentifier], hResponseObj)
60
+ hReturn = Id.unpack(hSbJson, hResponseObj)
61
+ hMetadataInfo[:metadataIdentifier] = hReturn unless hReturn.nil?
48
62
 
49
63
  # body / summary
50
64
  Body.unpack(hSbJson, hResourceInfo, hResponseObj)
@@ -66,9 +80,78 @@ module ADIWG
66
80
  Provenance.unpack(hSbJson, hCitation, hResponseObj)
67
81
 
68
82
  # materialRequestInstructions
83
+ aReturn = MaterialRequest.unpack(hSbJson, hResponseObj)
84
+ unless aReturn.nil?
85
+ hContact = aReturn[0]
86
+ myIndex = intObj[:contacts].length
87
+ intObj[:contacts] << hContact
88
+ aReturn[1][:distributor][0][:contact][:parties][0][:contactIndex] = myIndex
89
+ hMetadata[:distributorInfo] << aReturn[1]
90
+ end
91
+
92
+ # parent ID
93
+ hReturn = ParentId.unpack(hSbJson, hResponseObj)
94
+ hMetadataInfo[:parentMetadata] = hReturn unless hReturn.nil?
95
+
96
+ # contacts
97
+ Contact.unpack(hSbJson, intObj[:contacts], hResponseObj)
98
+
99
+ # web links
100
+ aReturn = WebLinkDocument.unpack(hSbJson, hResponseObj)
101
+ hMetadata[:additionalDocuments].concat(aReturn) unless aReturn.nil?
102
+ aReturn = WebLinkGraphic.unpack(hSbJson, hResponseObj)
103
+ hResourceInfo[:graphicOverviews].concat(aReturn) unless aReturn.nil?
104
+
105
+ # browse categories
106
+ BrowseCategory.unpack(hSbJson, hResourceInfo, hResponseObj)
107
+
108
+ # tags
109
+ Tag.unpack(hSbJson, hResourceInfo, hResponseObj)
110
+
111
+ # dates
112
+ Date.unpack(hSbJson, hCitation, hResponseObj)
113
+
114
+ # Spatial
115
+ Spatial.unpack(hSbJson, hResourceInfo, hResponseObj)
116
+
117
+ # facets
118
+ if hSbJson.has_key?('facets')
119
+ hSbJson['facets'].each do |hFacet|
120
+ if hFacet.has_key?('className')
121
+
122
+ # budget facet
123
+ if hFacet['className'] == 'gov.sciencebase.catalog.item.facet.BudgetFacet'
124
+ Budget.unpack(hFacet, hMetadata, hResponseObj)
125
+ end
69
126
 
70
- # something goes here
71
- @contacts = []
127
+ # project facet
128
+ if hFacet['className'] == 'gov.sciencebase.catalog.item.facet.ProjectFacet'
129
+ Project.unpack(hFacet, hResourceInfo, hResponseObj)
130
+ end
131
+
132
+ # citation facet
133
+ if hFacet['className'] == 'gov.sciencebase.catalog.item.facet.CitationFacet'
134
+ Publication.unpack(hFacet, hResourceInfo, hCitation, hResponseObj)
135
+ end
136
+
137
+ end
138
+ end
139
+ end
140
+
141
+ # extents
142
+ if hSbJson.has_key?('extents')
143
+ hSbJson['extents'].each do |extentId|
144
+ hReturn = Extent.unpack(extentId, hResponseObj)
145
+ hResourceInfo[:extents] << hReturn unless hReturn.empty?
146
+ end
147
+ end
148
+
149
+ hResourceInfo[:citation] = hCitation
150
+ hMetadata[:metadataInfo] = hMetadataInfo
151
+ hMetadata[:resourceInfo] = hResourceInfo
152
+ intObj[:schema] = hSchema
153
+ intObj[:metadata] = hMetadata
154
+ @contacts = intObj[:contacts]
72
155
 
73
156
  return intObj
74
157