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,53 @@
|
|
1
|
+
module ADIWG
|
2
|
+
module Mdtranslator
|
3
|
+
module Readers
|
4
|
+
module SbJson
|
5
|
+
|
6
|
+
module ResponsibleParty
|
7
|
+
|
8
|
+
def self.unpack(hRParty, responseObj)
|
9
|
+
|
10
|
+
# return nil object if input is empty
|
11
|
+
intResById = nil
|
12
|
+
return if hRParty.empty?
|
13
|
+
|
14
|
+
# instance classes needed in script
|
15
|
+
intMetadataClass = InternalMetadata.new
|
16
|
+
intResById = intMetadataClass.newRespParty
|
17
|
+
|
18
|
+
# responsible party - contact
|
19
|
+
if hRParty.has_key?('contactId')
|
20
|
+
s = hRParty['contactId']
|
21
|
+
if s != ''
|
22
|
+
intResById[:contactId] = s
|
23
|
+
if (!ADIWG::Mdtranslator::Readers::SbJson.findContact(s))
|
24
|
+
responseObj[:readerExecutionPass] = false
|
25
|
+
responseObj[:readerExecutionMessages] << "Responsible Party contact ID #{s} does not match with any contact provided\n"
|
26
|
+
end
|
27
|
+
else
|
28
|
+
responseObj[:readerExecutionPass] = false
|
29
|
+
responseObj[:readerExecutionMessages] << 'Responsible Party is missing the contact ID\n'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# responsible party - role - required
|
34
|
+
if hRParty.has_key?('role')
|
35
|
+
s = hRParty['role']
|
36
|
+
if s != ''
|
37
|
+
intResById[:roleName] = s
|
38
|
+
else
|
39
|
+
responseObj[:readerExecutionPass] = false
|
40
|
+
responseObj[:readerExecutionMessages] << 'Responsible Party is missing the contact role\n'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
return intResById
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_contacts')
|
2
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_metadata')
|
3
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_dataDictionary')
|
4
|
+
|
5
|
+
module ADIWG
|
6
|
+
module Mdtranslator
|
7
|
+
module Readers
|
8
|
+
module SbJson
|
9
|
+
|
10
|
+
def self.unpack(intObj, hSbJson, responseObj)
|
11
|
+
|
12
|
+
# get json schema name and version
|
13
|
+
hVersion = hSbJson['version']
|
14
|
+
intObj[:schema][:name] = hVersion['name']
|
15
|
+
intObj[:schema][:version] = hVersion['version']
|
16
|
+
|
17
|
+
# contact array
|
18
|
+
# load the array of contacts from the json input
|
19
|
+
if hSbJson.has_key?('contacts')
|
20
|
+
aContacts = hSbJson['contacts']
|
21
|
+
aContacts.each do |hContact|
|
22
|
+
unless hContact.empty?
|
23
|
+
intObj[:contacts] << Contact.unpack(hContact, responseObj)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
# add default contacts
|
28
|
+
intObj[:contacts].concat(Contact.setDefaultContacts)
|
29
|
+
|
30
|
+
# metadata section
|
31
|
+
# load metadata from the hash object
|
32
|
+
intObj[:metadata] = Metadata.unpack(hSbJson, responseObj, intObj)
|
33
|
+
|
34
|
+
# # data dictionary section
|
35
|
+
# if hSbJson.has_key?('dataDictionary')
|
36
|
+
# aDictionary = hSbJson['dataDictionary']
|
37
|
+
# aDictionary.each do |hDictionary|
|
38
|
+
# unless hDictionary.empty?
|
39
|
+
# intObj[:dataDictionary] << DataDictionary.unpack(hDictionary, responseObj)
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
|
44
|
+
# return ADIwg internal container
|
45
|
+
return intObj
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
## sbJson
|
3
|
+
|
4
|
+
### Supported versions
|
5
|
+
|
6
|
+
> 0.0.x
|
7
|
+
|
8
|
+
### Reader 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,205 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative 'sbJson_validator'
|
3
|
+
|
4
|
+
module ADIWG
|
5
|
+
module Mdtranslator
|
6
|
+
module Readers
|
7
|
+
module SbJson
|
8
|
+
|
9
|
+
def self.readFile(file, responseObj)
|
10
|
+
|
11
|
+
# set reference to responseObj for use throughout this module
|
12
|
+
@responseObj = responseObj
|
13
|
+
|
14
|
+
# receive json file into ruby hash
|
15
|
+
parseJson(file)
|
16
|
+
if !@responseObj[:readerStructurePass]
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
|
20
|
+
# set format of file in $response
|
21
|
+
@responseObj[:readerFormat] = 'json'
|
22
|
+
|
23
|
+
# check sbJson version name
|
24
|
+
checkVersionName
|
25
|
+
if !@responseObj[:readerStructurePass]
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
|
29
|
+
# check sbJson version number
|
30
|
+
checkVersionNumber
|
31
|
+
if !@responseObj[:readerStructurePass]
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
35
|
+
#validate file against sbJson schema definition
|
36
|
+
validate(file, @responseObj)
|
37
|
+
if !@responseObj[:readerValidationPass]
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
41
|
+
# load sbJson file into internal object
|
42
|
+
require readerModule('module_sbJson')
|
43
|
+
# instance classes needed in script
|
44
|
+
intMetadataClass = InternalMetadata.new
|
45
|
+
|
46
|
+
# create new internal metadata container for the reader
|
47
|
+
@intObj = intMetadataClass.newBase
|
48
|
+
|
49
|
+
#
|
50
|
+
ADIWG::Mdtranslator::Readers::SbJson.unpack(@intObj, @hSbJson, @responseObj)
|
51
|
+
return @intObj
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.parseJson(file)
|
56
|
+
# validate the input file structure
|
57
|
+
# test for valid json syntax by attempting to parse the file
|
58
|
+
begin
|
59
|
+
@hSbJson = JSON.parse(file)
|
60
|
+
|
61
|
+
# faking the version since sbJSON has no support
|
62
|
+
@hSbJson['version'] = {
|
63
|
+
"name" => "sbJson",
|
64
|
+
"version" => "0.0.0"
|
65
|
+
}
|
66
|
+
|
67
|
+
@responseObj[:readerStructurePass] = true
|
68
|
+
rescue JSON::JSONError => err
|
69
|
+
@responseObj[:readerStructurePass] = false
|
70
|
+
@responseObj[:readerStructureMessages] << 'JSON Parsing Failed - see following message(s):\n'
|
71
|
+
@responseObj[:readerStructureMessages] << err.to_s.slice(0,300)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.checkVersionName
|
76
|
+
# find version name on the input json file
|
77
|
+
if @hSbJson.has_key?('version')
|
78
|
+
hVersion = @hSbJson['version']
|
79
|
+
else
|
80
|
+
@responseObj[:readerStructurePass] = false
|
81
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
82
|
+
@responseObj[:readerStructureMessages] << 'The input file is missing the version:{} block.'
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
# check the version name
|
87
|
+
if hVersion.has_key?('name')
|
88
|
+
s = hVersion['name']
|
89
|
+
if s.nil?
|
90
|
+
@responseObj[:readerStructurePass] = false
|
91
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
92
|
+
@responseObj[:readerStructureMessages] << 'The input file version: => name: is missing.'
|
93
|
+
return
|
94
|
+
end
|
95
|
+
else
|
96
|
+
@responseObj[:readerStructurePass] = false
|
97
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
98
|
+
@responseObj[:readerStructureMessages] << "The input file version:{} block is missing the 'name:' attribute."
|
99
|
+
return
|
100
|
+
end
|
101
|
+
|
102
|
+
# check the version name is 'sbJson'
|
103
|
+
if s != 'sbJson'
|
104
|
+
@responseObj[:readerStructurePass] = false
|
105
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
106
|
+
@responseObj[:readerStructureMessages] << "The mdTranslator reader expected the input file version: name: to be 'sbJson'."
|
107
|
+
@responseObj[:readerStructureMessages] << "Version name found was: '#{s}'."
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.checkVersionNumber
|
112
|
+
# find version number on the input json file
|
113
|
+
hVersion = @hSbJson['version']
|
114
|
+
if hVersion.has_key?('version')
|
115
|
+
s = hVersion['version']
|
116
|
+
if !s.nil?
|
117
|
+
@responseObj[:readerVersionRequested] = s
|
118
|
+
end
|
119
|
+
else
|
120
|
+
@responseObj[:readerStructurePass] = false
|
121
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
122
|
+
@responseObj[:readerStructureMessages] << "The input file version:{} block is missing the 'version:' number attribute."
|
123
|
+
return
|
124
|
+
end
|
125
|
+
|
126
|
+
# split the version number into its parts
|
127
|
+
aReqVersion = s.split('.')
|
128
|
+
|
129
|
+
reqMajor = 0
|
130
|
+
if !aReqVersion[0].nil?
|
131
|
+
reqMajor = aReqVersion[0]
|
132
|
+
end
|
133
|
+
|
134
|
+
# test if the requested reader major version is supported
|
135
|
+
# look for a folder with modules for the major version number
|
136
|
+
dirName = File.join(File.dirname(__FILE__), 'modules_v' + reqMajor)
|
137
|
+
if !File.directory?(dirName)
|
138
|
+
@responseObj[:readerStructurePass] = false
|
139
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
140
|
+
@responseObj[:readerStructureMessages] << 'A reader for the requested version is not supported.'
|
141
|
+
@responseObj[:readerStructureMessages] << "sbJson version requested was '#{s}'"
|
142
|
+
return false
|
143
|
+
end
|
144
|
+
|
145
|
+
# the requested major version is supported
|
146
|
+
# get the full version number for this major version of sbJson
|
147
|
+
require File.join(dirName, 'version')
|
148
|
+
curVersion = ADIWG::Mdtranslator::Readers::SbJson::VERSION
|
149
|
+
@responseObj[:readerVersionUsed] = curVersion
|
150
|
+
aCurVersion = curVersion.split('.')
|
151
|
+
curMinor = aCurVersion[1]
|
152
|
+
|
153
|
+
# test that minor version number is not exceeded
|
154
|
+
reqMinor = 0
|
155
|
+
if !aReqVersion[1].nil?
|
156
|
+
reqMinor = aReqVersion[1]
|
157
|
+
if curMinor < reqMinor
|
158
|
+
@responseObj[:readerStructurePass] = false
|
159
|
+
@responseObj[:readerStructureMessages] << 'Invalid input file schema declaration - see following message(s):\n'
|
160
|
+
@responseObj[:readerStructureMessages] << 'The requested reader minor version is not supported.'
|
161
|
+
@responseObj[:readerStructureMessages] << "sbJson version requested was '#{s}'"
|
162
|
+
return false
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
# find the array pointer for a contact
|
169
|
+
def self.findContact(contactId)
|
170
|
+
pointer = nil
|
171
|
+
i = 0
|
172
|
+
@intObj[:contacts].each do |contact|
|
173
|
+
if contact[:contactId] == contactId
|
174
|
+
pointer = i
|
175
|
+
end
|
176
|
+
i += 1
|
177
|
+
end
|
178
|
+
|
179
|
+
return pointer
|
180
|
+
end
|
181
|
+
|
182
|
+
# require modules for the requested version
|
183
|
+
def self.readerModule(moduleName)
|
184
|
+
majVersion = @responseObj[:readerVersionUsed].split('.')[0]
|
185
|
+
dirName = File.join(File.dirname(__FILE__), 'modules_v' + majVersion.to_s)
|
186
|
+
fileName = File.join(dirName, moduleName)
|
187
|
+
|
188
|
+
# test for the existance of the module in the current sbJson version directory
|
189
|
+
if !File.exist?(File.join(dirName, moduleName + '.rb'))
|
190
|
+
# file not found
|
191
|
+
# ... look for module in previous version directory
|
192
|
+
# ... note: no previous version directories exist yet
|
193
|
+
|
194
|
+
# no prior version directory found
|
195
|
+
# ... file not found
|
196
|
+
return nil
|
197
|
+
end
|
198
|
+
|
199
|
+
return fileName
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'json-schema'
|
3
|
+
# temporary json-schema patch
|
4
|
+
# waiting for rubygem json-schema patch
|
5
|
+
#require 'adiwg/mdtranslator/readers/sbJson/validator.rb'
|
6
|
+
|
7
|
+
module ADIWG
|
8
|
+
module Mdtranslator
|
9
|
+
module Readers
|
10
|
+
module SbJson
|
11
|
+
|
12
|
+
# validate json against the schemas
|
13
|
+
# only one schema version is supported at this time
|
14
|
+
def self.validate(file, responseObj)
|
15
|
+
|
16
|
+
# begin
|
17
|
+
# schema = ADIWG::SbJsonSchemas::Utils.schema_path
|
18
|
+
# aValErrs = Array.new
|
19
|
+
# if responseObj[:readerValidationLevel] == 'strict'
|
20
|
+
# aValErrs = JSON::Validator.fully_validate(schema, file, :strict => true, :errors_as_objects => true)
|
21
|
+
# elsif responseObj[:readerValidationLevel] == 'normal'
|
22
|
+
# aValErrs = JSON::Validator.fully_validate(schema, file, :errors_as_objects => true)
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# if aValErrs.length > 0
|
26
|
+
# responseObj[:readerValidationPass] = false
|
27
|
+
# responseObj[:readerValidationMessages] << 'sbJson schema validation Failed - see following message(s):\n'
|
28
|
+
# responseObj[:readerValidationMessages] << aValErrs
|
29
|
+
# return
|
30
|
+
# end
|
31
|
+
# rescue JSON::Schema::ValidationError
|
32
|
+
# responseObj[:readerValidationPass] = false
|
33
|
+
# responseObj[:readerValidationMessages] << 'sbJson schema validation Failed - see following message(s):\n'
|
34
|
+
# responseObj[:readerValidationMessages] << $!.message
|
35
|
+
# return
|
36
|
+
# end
|
37
|
+
|
38
|
+
responseObj[:readerValidationPass] = true
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -11,8 +11,8 @@
|
|
11
11
|
# Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
|
12
12
|
# Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
|
13
13
|
|
14
|
-
require ADIWG::Mdtranslator::Readers::MdJson.readerModule('module_point')
|
15
|
-
require ADIWG::Mdtranslator::Readers::MdJson.readerModule('module_lineString')
|
14
|
+
#require ADIWG::Mdtranslator::Readers::MdJson.readerModule('module_point')
|
15
|
+
#require ADIWG::Mdtranslator::Readers::MdJson.readerModule('module_lineString')
|
16
16
|
require_relative 'class_point'
|
17
17
|
require_relative 'class_lineString'
|
18
18
|
require_relative 'class_polygon'
|
@@ -90,7 +90,7 @@ module ADIWG
|
|
90
90
|
aPoints.each do |aCoords|
|
91
91
|
intPoint = intMetadataClass.newGeoElement
|
92
92
|
intPoint[:elementSrs] = hGeoElement[:elementSrs]
|
93
|
-
intPoint[:elementGeometry] = ADIWG::Mdtranslator::
|
93
|
+
intPoint[:elementGeometry] = ADIWG::Mdtranslator::Point.unpack(aCoords, 'Point', @responseObj)
|
94
94
|
pointClass.writeXML(intPoint)
|
95
95
|
end
|
96
96
|
end
|
@@ -102,7 +102,7 @@ module ADIWG
|
|
102
102
|
aLines.each do |aCoords|
|
103
103
|
intLine = intMetadataClass.newGeoElement
|
104
104
|
intLine[:elementSrs] = hGeoElement[:elementSrs]
|
105
|
-
intLine[:elementGeometry] = ADIWG::Mdtranslator::
|
105
|
+
intLine[:elementGeometry] = ADIWG::Mdtranslator::LineString.unpack(aCoords, 'LineString', @responseObj)
|
106
106
|
lineClass.writeXML(intLine)
|
107
107
|
end
|
108
108
|
end
|
@@ -114,7 +114,7 @@ module ADIWG
|
|
114
114
|
aPolygons.each do |aCoords|
|
115
115
|
intPolygon = intMetadataClass.newGeoElement
|
116
116
|
intPolygon[:elementSrs] = hGeoElement[:elementSrs]
|
117
|
-
intPolygon[:elementGeometry] = ADIWG::Mdtranslator::
|
117
|
+
intPolygon[:elementGeometry] = ADIWG::Mdtranslator::LineString.unpack(aCoords, 'Polygon', @responseObj)
|
118
118
|
polygonClass.writeXML(intPolygon)
|
119
119
|
end
|
120
120
|
end
|
@@ -85,7 +85,7 @@ module ADIWG
|
|
85
85
|
# responsible party - role - required
|
86
86
|
s = rParty[:roleName]
|
87
87
|
if s.nil?
|
88
|
-
xml.tag!('gmd:role', {'gco:nilReason' => 'missing'})
|
88
|
+
@xml.tag!('gmd:role', {'gco:nilReason' => 'missing'})
|
89
89
|
else
|
90
90
|
@xml.tag! 'gmd:role' do
|
91
91
|
codelistClass.writeXML('iso_role',s)
|