adiwg-mdtranslator 1.3.0 → 1.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.jsbeautifyrc +8 -0
- data/Rakefile +1 -3
- data/adiwg-mdtranslator.gemspec +2 -0
- data/bin/mdtranslator +2 -2
- data/lib/adiwg/mdtranslator.rb +2 -0
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +6 -3
- data/lib/adiwg/mdtranslator/internal/module_geoFormat.rb +183 -190
- data/lib/adiwg/mdtranslator/internal/module_lineString.rb +18 -0
- data/lib/adiwg/mdtranslator/internal/module_point.rb +18 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_contacts.rb +3 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_geographicElement.rb +18 -10
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_additionalDocumentation.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_boundingBox.rb +54 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_browseGraphic.rb +66 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_citation.rb +125 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_contacts.rb +144 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_dateTime.rb +31 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_distributionInfo.rb +64 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_extent.rb +61 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoCoordSystem.rb +50 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoProperties.rb +91 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geographicElement.rb +161 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadata.rb +70 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadataInfo.rb +131 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_onlineResource.rb +71 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceIdentifier.rb +73 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceInfo.rb +437 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_responsibleParty.rb +53 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_sbJson.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/version.rb +12 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/readme.md +12 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +205 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_validator.rb +44 -0
- data/lib/adiwg/mdtranslator/version.rb +1 -2
- data/lib/adiwg/mdtranslator/writers/html/sections/html_browseGraphic.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb +5 -5
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/readme.md +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_additionalDoc.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_address.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_associatedResource.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_attribute.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_base.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_citation.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_constraint.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_contact.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageInfo.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageItem.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dataQuality.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +18 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_distributionInfo.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domain.rb +25 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb +37 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_extent.rb +26 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_format.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicElement.rb +81 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_graphicOverview.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_gridInfo.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_imageInfo.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_keyword.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_locale.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadataInfo.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +21 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_phone.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +25 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceIdentifier.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +69 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceMaintenance.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_responsibleParty.rb +18 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_spatialreference.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxon.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxonomy.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_temporalElement.rb +38 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timePeriod.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_transferOption.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_usage.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_verticalElement.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/version.rb +13 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/readme.md +12 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +126 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_base.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb +49 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +13 -0
- data/test/readers/mdJson/v1/tc_reader_mdjson_translation.rb +83 -0
- data/test/readers/sbJson/v0/tc_reader_sbjson_translation.rb +79 -0
- data/test/readers/sbJson/v0/test.json +431 -0
- data/test/readers/sbJson/v0/test1.json +383 -0
- data/test/writers/mdJson/v1/tc_writer_mdJson.rb +60 -0
- data/test/writers/sbJson/v0/tc_writer_sbJson.rb +60 -0
- metadata +121 -7
- data/test/readers/mdJson/v1/tc_translation_19115_2.rb +0 -67
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'mdJson_citation'
|
3
|
+
|
4
|
+
module ADIWG
|
5
|
+
module Mdtranslator
|
6
|
+
module Writers
|
7
|
+
module MdJson
|
8
|
+
module ResourceIdentifier
|
9
|
+
def self.build(ident)
|
10
|
+
Jbuilder.new do |json|
|
11
|
+
json.identifier ident[:identifier]
|
12
|
+
json.namespace ident[:identifierNamespace]
|
13
|
+
json.version ident[:identifierVersion]
|
14
|
+
json.description ident[:identifierDescription]
|
15
|
+
json.type ident[:identifierType]
|
16
|
+
json.authority Citation.build(ident[:identifierCitation]) unless ident[:identifierCitation].empty?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'mdJson_base'
|
3
|
+
require_relative 'mdJson_citation'
|
4
|
+
require_relative 'mdJson_timePeriod'
|
5
|
+
require_relative 'mdJson_responsibleParty'
|
6
|
+
require_relative 'mdJson_locale'
|
7
|
+
require_relative 'mdJson_format'
|
8
|
+
require_relative 'mdJson_keyword'
|
9
|
+
require_relative 'mdJson_resourceMaintenance'
|
10
|
+
require_relative 'mdJson_usage'
|
11
|
+
require_relative 'mdJson_graphicOverview'
|
12
|
+
require_relative 'mdJson_constraint'
|
13
|
+
require_relative 'mdJson_taxonomy'
|
14
|
+
require_relative 'mdJson_spatialreference'
|
15
|
+
require_relative 'mdJson_extent'
|
16
|
+
require_relative 'mdJson_gridInfo'
|
17
|
+
require_relative 'mdJson_coverageInfo'
|
18
|
+
require_relative 'mdJson_dataQuality'
|
19
|
+
|
20
|
+
module ADIWG
|
21
|
+
module Mdtranslator
|
22
|
+
module Writers
|
23
|
+
module MdJson
|
24
|
+
module ResourceInfo
|
25
|
+
extend MdJson::Base
|
26
|
+
|
27
|
+
def self.build(_info)
|
28
|
+
Jbuilder.new do |json|
|
29
|
+
json.resourceType _info[:resourceType]
|
30
|
+
json.citation Citation.build(_info[:citation])
|
31
|
+
json.resourceTimePeriod TimePeriod.build(_info[:timePeriod]) # unless _info[:timePeriod].empty?
|
32
|
+
json.pointOfContact json_map(_info[:pointsOfContact], ResponsibleParty)
|
33
|
+
json.abstract _info[:abstract]
|
34
|
+
json.shortAbstract _info[:shortAbstract]
|
35
|
+
json.status _info[:status]
|
36
|
+
json.hasMapLocation _info[:hasMapLocation?]
|
37
|
+
json.hasDataAvailable _info[:hasDataAvailable?]
|
38
|
+
json.language (_info[:resourceLanguages])
|
39
|
+
json.characterSet (_info[:resourceCharacterSets])
|
40
|
+
json.locale json_map(_info[:resourceLocales], Locale)
|
41
|
+
json.purpose _info[:purpose]
|
42
|
+
json.credit (_info[:credits])
|
43
|
+
json.topicCategory (_info[:topicCategories])
|
44
|
+
json.environmentDescription _info[:environmentDescription]
|
45
|
+
json.resourceNativeFormat json_map(_info[:resourceFormats], Format)
|
46
|
+
json.keyword json_map(_info[:descriptiveKeywords], Keyword)
|
47
|
+
json.resourceMaintenance json_map(_info[:resourceMaint], ResourceMaintenance)
|
48
|
+
json.resourceSpecificUsage json_map(_info[:resourceUses], Usage)
|
49
|
+
json.graphicOverview json_map(_info[:graphicOverview], GraphicOverview)
|
50
|
+
json.constraint Constraint.build(_info[:useConstraints], _info[:legalConstraints], _info[:securityConstraints])
|
51
|
+
json.taxonomy Taxonomy.build(_info[:taxonomy])
|
52
|
+
json.spatialReferenceSystem SpatialReference.build(_info[:spatialReferenceSystem])
|
53
|
+
json.spatialResolution (_info[:spatialResolutions]) do |sr|
|
54
|
+
json.equivalentScale sr[:equivalentScale]
|
55
|
+
json.distance sr[:distance]
|
56
|
+
json.uom sr[:distanceUOM]
|
57
|
+
end
|
58
|
+
json.extent json_map(_info[:extents], Extent)
|
59
|
+
json.gridInfo json_map(_info[:gridInfo], GridInfo)
|
60
|
+
json.coverageInfo json_map(_info[:coverageInfo], CoverageInfo)
|
61
|
+
json.dataQualityInfo json_map(_info[:dataQualityInfo], DataQuality)
|
62
|
+
json.supplementalInfo _info[:supplementalInfo]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'mdJson_base'
|
3
|
+
require_relative 'mdJson_responsibleParty'
|
4
|
+
|
5
|
+
module ADIWG
|
6
|
+
module Mdtranslator
|
7
|
+
module Writers
|
8
|
+
module MdJson
|
9
|
+
module ResourceMaintenance
|
10
|
+
extend MdJson::Base
|
11
|
+
|
12
|
+
def self.build(intObj)
|
13
|
+
Jbuilder.new do |json|
|
14
|
+
json.maintenanceFrequency intObj[:maintFreq]
|
15
|
+
json.maintenanceNote (intObj[:maintNotes])
|
16
|
+
json.maintenanceContact json_map(intObj[:maintContacts], ResponsibleParty)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
|
3
|
+
module ADIWG
|
4
|
+
module Mdtranslator
|
5
|
+
module Writers
|
6
|
+
module MdJson
|
7
|
+
module ResponsibleParty
|
8
|
+
def self.build(intObj)
|
9
|
+
Jbuilder.new do |json|
|
10
|
+
json.contactId intObj[:contactId]
|
11
|
+
json.role intObj[:roleName]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
|
3
|
+
module ADIWG
|
4
|
+
module Mdtranslator
|
5
|
+
module Writers
|
6
|
+
module MdJson
|
7
|
+
module SpatialReference
|
8
|
+
def self.build(intObj)
|
9
|
+
Jbuilder.new do |json|
|
10
|
+
json.name(intObj[:sRNames])
|
11
|
+
json.epsgNumber(intObj[:sREPSGs])
|
12
|
+
json.wkt(intObj[:sRWKTs])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
|
3
|
+
module ADIWG
|
4
|
+
module Mdtranslator
|
5
|
+
module Writers
|
6
|
+
module MdJson
|
7
|
+
module Taxon
|
8
|
+
def self.build(intObj)
|
9
|
+
Jbuilder.new do |json|
|
10
|
+
json.taxonRank (intObj[:taxRankName])
|
11
|
+
json.taxonValue (intObj[:taxRankValue])
|
12
|
+
json.common (intObj[:commonName])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'mdJson_base'
|
3
|
+
require_relative 'mdJson_citation'
|
4
|
+
require_relative 'mdJson_responsibleParty'
|
5
|
+
require_relative 'mdJson_taxon'
|
6
|
+
|
7
|
+
module ADIWG
|
8
|
+
module Mdtranslator
|
9
|
+
module Writers
|
10
|
+
module MdJson
|
11
|
+
module Taxonomy
|
12
|
+
extend MdJson::Base
|
13
|
+
|
14
|
+
def self.build(intObj)
|
15
|
+
Jbuilder.new do |json|
|
16
|
+
json.classificationSystem json_map(intObj[:taxClassSys], Citation)
|
17
|
+
json.taxonGeneralScope intObj[:taxGeneralScope]
|
18
|
+
json.observer json_map(intObj[:taxObservers], ResponsibleParty)
|
19
|
+
json.taxonomicProcedure intObj[:taxIdProcedures]
|
20
|
+
json.voucher do
|
21
|
+
voucher = intObj[:taxVoucher]
|
22
|
+
json.specimen voucher.nil? ? nil : voucher[:specimen]
|
23
|
+
json.repository voucher.nil? ? nil : ResponsibleParty.build(voucher[:repository])
|
24
|
+
end
|
25
|
+
json.taxonClass json_map(intObj[:taxClasses], Taxon)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
|
3
|
+
require_relative 'mdJson_base'
|
4
|
+
require_relative 'mdJson_timePeriod'
|
5
|
+
|
6
|
+
module ADIWG
|
7
|
+
module Mdtranslator
|
8
|
+
module Writers
|
9
|
+
module MdJson
|
10
|
+
module TemporalElement
|
11
|
+
extend MdJson::Base
|
12
|
+
|
13
|
+
def self.build(intObj)
|
14
|
+
remap = {
|
15
|
+
date: [],
|
16
|
+
timeInstant: [],
|
17
|
+
timePeriod: []
|
18
|
+
}
|
19
|
+
|
20
|
+
intObj.each do |obj|
|
21
|
+
obj.each { |key, value| remap[key] << value unless value.empty? }
|
22
|
+
end
|
23
|
+
|
24
|
+
Jbuilder.new do |json|
|
25
|
+
json.timeInstant(remap[:timeInstant]) do |ti|
|
26
|
+
json.id ti[:timeId]
|
27
|
+
json.description ti[:description]
|
28
|
+
json.timePosition ti[:timePosition][:dateTime] unless ti[:timePosition].nil?
|
29
|
+
end unless remap[:timeInstant].empty?
|
30
|
+
json.timePeriod json_map(remap[:timePeriod], TimePeriod)
|
31
|
+
json.date(remap[:date]) { |dt| json.merge! dt[:dateTime] } unless remap[:date].empty?
|
32
|
+
end unless remap[:date].empty? && remap[:timeInstant].empty? && remap[:timePeriod].empty?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
|
3
|
+
module ADIWG
|
4
|
+
module Mdtranslator
|
5
|
+
module Writers
|
6
|
+
module MdJson
|
7
|
+
module TimePeriod
|
8
|
+
def self.build(intObj)
|
9
|
+
Jbuilder.new do |json|
|
10
|
+
json.id intObj[:timeId]
|
11
|
+
json.description intObj[:description]
|
12
|
+
json.beginPosition intObj[:beginTime][:dateTime] unless intObj[:beginTime].nil?
|
13
|
+
json.endPosition intObj[:endTime][:dateTime] unless intObj[:endTime].nil?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'mdJson_base'
|
3
|
+
require_relative 'mdJson_onlineResource'
|
4
|
+
require_relative 'mdJson_format'
|
5
|
+
|
6
|
+
module ADIWG
|
7
|
+
module Mdtranslator
|
8
|
+
module Writers
|
9
|
+
module MdJson
|
10
|
+
module TransferOption
|
11
|
+
extend MdJson::Base
|
12
|
+
|
13
|
+
def self.build(intObj)
|
14
|
+
Jbuilder.new do |json|
|
15
|
+
json.distributorFormat json_map(intObj[:dist], Format)
|
16
|
+
json.transferSize intObj[:transferSize]
|
17
|
+
json.transferSizeUnits intObj[:transferSizeUnits]
|
18
|
+
json.online json_map(intObj[:online], OnlineResource)
|
19
|
+
json.offline do
|
20
|
+
off = intObj[:offline]
|
21
|
+
json.name off[:mediumType]
|
22
|
+
json.mediumCapacity off[:mediumCapacity]
|
23
|
+
json.mediumCapacityUnits off[:mediumCapacityUnits]
|
24
|
+
json.mediumFormat off[:mediumFormat]
|
25
|
+
json.mediumNote off[:mediumNote]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'mdJson_base'
|
3
|
+
require_relative 'mdJson_responsibleParty'
|
4
|
+
|
5
|
+
module ADIWG
|
6
|
+
module Mdtranslator
|
7
|
+
module Writers
|
8
|
+
module MdJson
|
9
|
+
module Usage
|
10
|
+
extend MdJson::Base
|
11
|
+
|
12
|
+
def self.build(intObj)
|
13
|
+
Jbuilder.new do |json|
|
14
|
+
json.specificUsage intObj[:specificUsage]
|
15
|
+
json.userDeterminedLimitation (intObj[:userLimits])
|
16
|
+
json.userContactInfo json_map(intObj[:userContacts], ResponsibleParty)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
|
3
|
+
module ADIWG
|
4
|
+
module Mdtranslator
|
5
|
+
module Writers
|
6
|
+
module MdJson
|
7
|
+
module VerticalElement
|
8
|
+
def self.build(intObj)
|
9
|
+
Jbuilder.new do |json|
|
10
|
+
json.minimumValue intObj[:minValue]
|
11
|
+
json.maximumValue intObj[:maxValue]
|
12
|
+
json.verticalCRSTitle intObj[:crsTitle]
|
13
|
+
json.verticalCRSUri intObj[:crsURI]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
## sbJson
|
3
|
+
|
4
|
+
### Supported versions
|
5
|
+
|
6
|
+
> 0.0.x
|
7
|
+
|
8
|
+
### Writer for ScienceBase JSON metadata format (sbJSON)
|
9
|
+
|
10
|
+
The ScienceBase Item core is based on the Dublin Core Metadata Element Set but also includes other elements that may or may not be associated with other metadata standards that are useful for the core attribution of ScienceBase items. It is used as a means to integrate across multiple metadata standards, conventions, and practices in describing a wide array of scientific data and information assets important to science teams using ScienceBase.
|
11
|
+
|
12
|
+
The sbJSON format is fully documented on the [ScienceBase Confluence page](https://my.usgs.gov/confluence/display/sciencebase/ScienceBase+Information+Model).
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'jbuilder'
|
2
|
+
require_relative 'version'
|
3
|
+
require_relative 'sections/sbJson_base'
|
4
|
+
require_relative 'sections/sbJson_contact'
|
5
|
+
require_relative 'sections/sbJson_identifier'
|
6
|
+
require_relative 'sections/sbJson_spatial'
|
7
|
+
|
8
|
+
module ADIWG
|
9
|
+
module Mdtranslator
|
10
|
+
module Writers
|
11
|
+
module SbJson
|
12
|
+
extend SbJson::Base
|
13
|
+
def self.startWriter(_intObj, responseObj, _paramsObj)
|
14
|
+
@intObj = _intObj
|
15
|
+
|
16
|
+
# set output flag for null properties
|
17
|
+
Jbuilder.ignore_nil(!responseObj[:writerShowTags])
|
18
|
+
# set the format of the output file based on the writer specified
|
19
|
+
responseObj[:writerFormat] = 'sbJson'
|
20
|
+
responseObj[:writerVersion] = ADIWG::Mdtranslator::Writers::SbJson::VERSION
|
21
|
+
|
22
|
+
rInfo = _intObj[:metadata][:resourceInfo]
|
23
|
+
dInfo = _intObj[:metadata][:distributorInfo]
|
24
|
+
cite = rInfo[:citation]
|
25
|
+
ids = cite[:citResourceIds]
|
26
|
+
|
27
|
+
metadata = Jbuilder.new do |json|
|
28
|
+
json.identifiers json_map(ids, Identifier)
|
29
|
+
json.title cite[:citTitle]
|
30
|
+
json.alternateTitles([cite[:citAltTitle]]) unless cite[:citAltTitle].nil?
|
31
|
+
json.body rInfo[:abstract]
|
32
|
+
json.citation do
|
33
|
+
names = cite[:citResponsibleParty].map do |rp|
|
34
|
+
cnt = getContact(rp[:contactId])
|
35
|
+
cnt[:indName]
|
36
|
+
end
|
37
|
+
names = names.select! { |s| s }.nil? ? 'Unknown' : names.join(', ')
|
38
|
+
dates = cite[:citDate].map { |dt| dt[:dateTime].strftime('%F') + '(' + dt[:dateType] + ')' }
|
39
|
+
url = cite[:citOlResources].map { |ol| ol[:olResURI] }
|
40
|
+
json.merge! sprintf('%s, %s, %s, %s', names, dates.join(', '), cite[:citTitle], url.join(', '))
|
41
|
+
end
|
42
|
+
json.purpose rInfo[:purpose]
|
43
|
+
|
44
|
+
legal = []
|
45
|
+
rInfo[:legalConstraints].each do |lc|
|
46
|
+
legal += lc[:accessCodes] += lc[:useCodes] += lc[:otherCons]
|
47
|
+
end
|
48
|
+
json.rights legal.empty? ? nil : legal.join('; ')
|
49
|
+
json.provenance do
|
50
|
+
json.annotation 'Generated using the ADIwg mdTranslator, http://mdtranslator.adiwg.org'
|
51
|
+
end
|
52
|
+
|
53
|
+
mri = []
|
54
|
+
dInfo.each { |di| di[:distOrderProcs].each { |dop| mri << dop[:orderInstructions] } }
|
55
|
+
json.materialRequestInstructions mri.empty? ? nil : mri.join('; ')
|
56
|
+
|
57
|
+
json.contacts json_map(_intObj[:contacts].select! { |c| !(c[:internal]) }, Contact)
|
58
|
+
|
59
|
+
# grab links from citation, additionalDocumentation, distributionInfo
|
60
|
+
wl = []
|
61
|
+
wl += cite[:citOlResources]
|
62
|
+
dInfo.each { |di| di[:distTransOptions].each { |dto| wl += dto[:online] } }
|
63
|
+
_intObj[:metadata][:additionalDocuments].each { |ad| wl += ad[:citation][:citOlResources] }
|
64
|
+
|
65
|
+
json.webLinks(wl) do |lnk|
|
66
|
+
json.type 'webLink'
|
67
|
+
json.typeLabel 'Web Link'
|
68
|
+
json.uri lnk[:olResURI]
|
69
|
+
json.title lnk[:olResName]
|
70
|
+
end unless wl.empty?
|
71
|
+
|
72
|
+
tags = []
|
73
|
+
rInfo[:topicCategories].each do |tc|
|
74
|
+
tags << { type: 'Label',
|
75
|
+
scheme: 'ISO 19115 Topic Categories',
|
76
|
+
name: tc }
|
77
|
+
end
|
78
|
+
rInfo[:descriptiveKeywords].each do |kw|
|
79
|
+
type = kw[:keyTheCitation].fetch(:citTitle, kw[:keywordType]) || 'Theme'
|
80
|
+
scheme = kw[:keyTheCitation].fetch(:citOlResources, [])
|
81
|
+
kw[:keyword].each do |_k|
|
82
|
+
tags << { type: type,
|
83
|
+
scheme: scheme.empty? ? 'None' : scheme.first[:olResURI],
|
84
|
+
name: _k }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
json.tags(tags)
|
88
|
+
|
89
|
+
dates = cite[:citDate]
|
90
|
+
tp = rInfo[:timePeriod]
|
91
|
+
unless tp.empty?
|
92
|
+
dates << { dateType: 'Start', dateTime: tp[:beginTime][:dateTime].to_datetime
|
93
|
+
} unless tp[:beginTime].empty?
|
94
|
+
dates << { dateType: 'End', dateTime: tp[:endTime][:dateTime].to_datetime
|
95
|
+
} unless tp[:endTime].empty?
|
96
|
+
|
97
|
+
end
|
98
|
+
json.dates(dates) do |dt|
|
99
|
+
json.type dt[:dateType]
|
100
|
+
json.dateString dt[:dateTime].strftime('%F')
|
101
|
+
json.label dt[:dateType].split(/(?=[A-Z])/).join(' ').capitalize
|
102
|
+
end
|
103
|
+
|
104
|
+
json.spatial Spatial.build(rInfo[:extents])
|
105
|
+
end
|
106
|
+
# set writer pass to true if no messages
|
107
|
+
# false or warning will be set by code that places the message
|
108
|
+
responseObj[:writerPass] = true if responseObj[:writerMessages].empty?
|
109
|
+
|
110
|
+
# j = JSON.parse(metadata.target!)
|
111
|
+
# puts JSON.pretty_generate(j)
|
112
|
+
|
113
|
+
metadata.target!
|
114
|
+
end
|
115
|
+
|
116
|
+
# find contact in contact array and return the contact hash
|
117
|
+
def self.getContact(contactID)
|
118
|
+
@intObj[:contacts].each do |hContact|
|
119
|
+
return hContact if hContact[:contactId] == contactID
|
120
|
+
end
|
121
|
+
{}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|