adiwg-mdtranslator 0.9.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -6
- data/adiwg-mdtranslator.gemspec +2 -2
- data/bin/mdtranslator +10 -10
- data/lib/adiwg/mdtranslator.rb +54 -12
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +87 -7
- data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_reader.rb → mdJson/mdJson_reader.rb} +13 -4
- data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_validator.rb → mdJson/mdJson_validator.rb} +18 -10
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_additionalDocumentation.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_address.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_associatedResource.rb +3 -3
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_boundingBox.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_browseGraphic.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_citation.rb +5 -5
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_contacts.rb +7 -7
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_coordinates.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dataDictionary.rb +53 -0
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_dataQuality.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_dateTime.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_descriptiveKeyword.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dictionaryInfo.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_distributionInfo.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domain.rb +62 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domainItem.rb +42 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entity.rb +92 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityAttribute.rb +91 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityForeignKey.rb +43 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityIndex.rb +42 -0
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_extent.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geoCoordSystem.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geoProperties.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geographicElement.rb +12 -12
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_legalConstraint.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_lineString.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_lineage.rb +3 -3
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadata.rb +6 -6
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadataExtension.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadataInfo.rb +8 -8
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_onlineResource.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_phone.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_point.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_polygon.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_processStep.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resolution.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceFormat.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceIdentifier.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceInfo.rb +16 -16
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceMaintenance.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceSpecificUsage.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_responsibleParty.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_securityConstraint.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_source.rb +3 -3
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_spatialReference.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_taxonClass.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_taxonomy.rb +5 -5
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_temporalElement.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_timeInstant.rb +3 -3
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_timePeriod.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_verticalElement.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_voucher.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/mdJson/readme.md +19 -0
- data/lib/adiwg/mdtranslator/version.rb +5 -1
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_FCfeatureCatalogue.rb +171 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2/classes/class_metadata.rb → iso/classes/class_MImetadata.rb} +3 -3
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_address.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_aggregateInformation.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_boundingPolygon.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_browseGraphic.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_citation.rb +3 -3
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_contact.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_dataIdentification.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_dataQuality.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_date.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_digitalTransferOptions.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_distribution.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_distributor.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_extent.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureAttribute.rb +114 -0
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureConstraint.rb +55 -0
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureType.rb +120 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_format.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_genericMetaData.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicBoundingBox.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicDescription.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicElement.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_identifier.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_keyword.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_legalConstraints.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_lineString.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_lineage.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_listedValue.rb +68 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_maintenanceInformation.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_medium.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_metadataExtension.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_multiGeometry.rb +3 -3
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_multiplicity.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_onlineResource.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_point.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_polygon.rb +2 -2
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_processStep.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_referenceIdentifier.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_referenceSystem.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_resolution.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_responsibleParty.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_securityConstraints.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_source.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_standardOrderProcess.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_taxonClassification.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_taxonSystem.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_telephone.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_temporalExtent.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_timeInstant.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_timePeriod.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_usage.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_useConstraints.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_verticalExtent.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_vouchers.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_associationType.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_characterSet.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_classification.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_datatype.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_dateType.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_initiativeType.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_keywordType.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_maintenanceFrequency.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_mediumFormat.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_mediumName.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_obligation.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_onlineFunction.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_presentationForm.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_progress.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_restriction.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_role.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_scope.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_spatialRepresentationType.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_topicCategory.rb +0 -0
- data/lib/adiwg/mdtranslator/writers/iso/units/class_baseUnit.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/iso/units/class_conventionalUnit.rb +53 -0
- data/lib/adiwg/mdtranslator/writers/iso/units/class_definitionUnit.rb +24 -0
- data/lib/adiwg/mdtranslator/writers/iso/units/class_derivedUnit.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/iso/units/class_unitsOfMeasure.rb +224 -0
- data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/iso19110/readme.md +13 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/iso19115_2/readme.md +6 -9
- data/test/tc_translation.rb +35 -18
- metadata +166 -146
- data/lib/adiwg/mdtranslator/readers/adiwgJson/readme.md +0 -19
- data/mdtranslator.rb +0 -187
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb133f79461697e8f43a63ffb954558529f1c32d
|
4
|
+
data.tar.gz: 8d3e5b49675cf8bd0232d2ff01a8935f9bd8bf0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9274cdf2cbeb17c54e1f5592d0920d169ebb570a83abf83b896adb75e575393f4666a02332c2d215f44a360d521c2a1a47c01a24b50da93e6fb72e3bf26ea33c
|
7
|
+
data.tar.gz: 77005bdc01f83d02b127def3d4e5a3a9542d98b098c574facaaa3c22eb0cb4ae367a4f3b4fe7e291fa6b692758715debd31bd3ff660b0fcfb19a16e680c3efa0
|
data/.gitignore
CHANGED
data/adiwg-mdtranslator.gemspec
CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_runtime_dependency "builder", "~>3.2"
|
28
28
|
spec.add_runtime_dependency "thor", "~>0.19"
|
29
29
|
spec.add_runtime_dependency "uuidtools", "~>2.1"
|
30
|
-
spec.add_runtime_dependency "json-schema", "~>2.4"
|
31
|
-
spec.add_runtime_dependency "adiwg-json_schemas", "~>0.9"
|
30
|
+
spec.add_runtime_dependency "json-schema", "~>2.4.0"
|
31
|
+
spec.add_runtime_dependency "adiwg-json_schemas", "~>0.9.4"
|
32
32
|
end
|
data/bin/mdtranslator
CHANGED
@@ -26,7 +26,7 @@ class Mdtranslator < Thor
|
|
26
26
|
in XML outputs, and choose level of validation for JSON inputs.
|
27
27
|
LONGDESC
|
28
28
|
# define cli options
|
29
|
-
method_option :reader, :aliases => '-r', :desc => 'Name of reader to read your input', :default => '
|
29
|
+
method_option :reader, :aliases => '-r', :desc => 'Name of reader to read your input', :default => 'mdJson'
|
30
30
|
method_option :writer, :aliases => '-w', :desc => 'Name of writer to create your metadata, or leave blank to validate input only'
|
31
31
|
method_option :validate, :aliases => '-v', :desc => 'Specify level of validation to be performed', :enum => %w{none normal strict}, :default => 'normal'
|
32
32
|
method_option :showAllTags, :aliases => '-s', :desc => 'Include tags for unused attributes', :type => :boolean, :default => false
|
@@ -60,10 +60,10 @@ class Mdtranslator < Thor
|
|
60
60
|
# ...no writer output will have been generated,
|
61
61
|
# ...and the return will be a string unless json was requested
|
62
62
|
if options[:messages] == 'json'
|
63
|
-
$stdout.
|
63
|
+
$stdout.puts mdReturn.to_json
|
64
64
|
return
|
65
65
|
else
|
66
|
-
$stdout.
|
66
|
+
$stdout.puts 'Success'
|
67
67
|
return
|
68
68
|
end
|
69
69
|
else
|
@@ -73,17 +73,17 @@ class Mdtranslator < Thor
|
|
73
73
|
# writer output was generated
|
74
74
|
# ...return the writer output in its native format unless json was requested
|
75
75
|
if options[:returnObject]
|
76
|
-
$stdout.
|
76
|
+
$stdout.puts mdReturn.to_json
|
77
77
|
return
|
78
78
|
else
|
79
|
-
$stdout.
|
79
|
+
$stdout.puts mdReturn[:writerOutput].to_s
|
80
80
|
return
|
81
81
|
end
|
82
82
|
else
|
83
83
|
# the writer failed or generated warnings to be reported
|
84
84
|
# ...return the messages as a string unless json was requested
|
85
85
|
if options[:messages] == 'json'
|
86
|
-
$stdout.
|
86
|
+
$stdout.puts mdReturn.to_json
|
87
87
|
return
|
88
88
|
else
|
89
89
|
# build a string with messages issues from parser and validator
|
@@ -100,7 +100,7 @@ class Mdtranslator < Thor
|
|
100
100
|
s += message + "\n"
|
101
101
|
end
|
102
102
|
|
103
|
-
$stdout.
|
103
|
+
$stdout.puts s
|
104
104
|
return
|
105
105
|
|
106
106
|
end
|
@@ -115,7 +115,7 @@ class Mdtranslator < Thor
|
|
115
115
|
# ...no writer output will have been generated,
|
116
116
|
# ...and return is always expected to be a string
|
117
117
|
if options[:messages] == 'json'
|
118
|
-
$stdout.
|
118
|
+
$stdout.puts mdReturn.to_json
|
119
119
|
return
|
120
120
|
else
|
121
121
|
# build a string with messages issues from parser and validator
|
@@ -152,7 +152,7 @@ class Mdtranslator < Thor
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
$stdout.
|
155
|
+
$stdout.puts s
|
156
156
|
return
|
157
157
|
|
158
158
|
end
|
@@ -165,7 +165,7 @@ class Mdtranslator < Thor
|
|
165
165
|
'mdtranslator version' returns the version number for mdTranslator
|
166
166
|
LONGDESC
|
167
167
|
def version
|
168
|
-
$stdout.
|
168
|
+
$stdout.puts ADIWG::Mdtranslator::VERSION
|
169
169
|
end
|
170
170
|
|
171
171
|
Mdtranslator.start(ARGV)
|
data/lib/adiwg/mdtranslator.rb
CHANGED
@@ -11,6 +11,10 @@
|
|
11
11
|
# Stan Smith 2014-09-26 added processing of minor release numbers
|
12
12
|
# Stan Smith 2014-10-10 added method to return path to readers and writers
|
13
13
|
# Stan Smith 2014-10-11 added methods to return content of readme files
|
14
|
+
# Stan Smith 2014-12-01 changed adiwgJson ot mdJson
|
15
|
+
# Stan Smith 2014-12-01 added writer iso19110 (feature catalogue)
|
16
|
+
# Stan Smith 2014-12-01 added translator version to $response
|
17
|
+
# Stan Smith 2014-12-02 organized shared class/code/units folders for 19115-2, 19110
|
14
18
|
|
15
19
|
# add main directories to load_path
|
16
20
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator'))
|
@@ -28,46 +32,78 @@ module ADIWG
|
|
28
32
|
def self.translate(file, reader, writer, validate, showAllTags)
|
29
33
|
|
30
34
|
$showAllTags = showAllTags
|
35
|
+
|
36
|
+
# load and return this hash
|
31
37
|
$response = {
|
32
38
|
readerFormat: nil,
|
33
39
|
readerStructurePass: nil,
|
34
40
|
readerStructureMessages: [],
|
35
|
-
|
36
|
-
|
41
|
+
readerRequested: reader,
|
42
|
+
readerFound: nil,
|
37
43
|
readerVersionFound: nil,
|
38
44
|
readerVersionUsed: nil,
|
39
45
|
readerValidationLevel: validate,
|
40
46
|
readerValidationPass: nil,
|
41
47
|
readerValidationMessages: [],
|
42
48
|
writerName: writer,
|
49
|
+
writerVersion: ADIWG::Mdtranslator::VERSION,
|
43
50
|
writerFormat: nil,
|
44
51
|
writerPass: nil,
|
45
52
|
writerMessages: [],
|
46
53
|
writerOutput: nil
|
47
54
|
}
|
48
55
|
|
49
|
-
# the mdtranslator gem loads and returns the above hash
|
50
|
-
|
51
56
|
case reader
|
52
|
-
|
53
|
-
|
57
|
+
|
58
|
+
# ADIwg mdJson JSON schema
|
59
|
+
when 'mdJson'
|
60
|
+
require 'mdJson/mdJson_validator'
|
54
61
|
|
55
62
|
# validate adiwgJson file
|
56
|
-
|
63
|
+
MdJsonValidation.validate(file)
|
57
64
|
if $response[:readerStructurePass] && $response[:readerValidationPass]
|
58
65
|
# initiate the reader
|
59
|
-
require '
|
60
|
-
readerClass =
|
66
|
+
require 'mdJson/mdJson_reader'
|
67
|
+
readerClass = MdJsonReader.new
|
61
68
|
internalObj = readerClass.unpack(file)
|
62
69
|
else
|
63
70
|
return $response
|
64
71
|
end
|
72
|
+
|
73
|
+
# reader name not provided or not supported
|
74
|
+
else
|
75
|
+
$response[:readerValidationPass] = false
|
76
|
+
$response[:readerValidationMessages] << 'Reader name is missing or not supported.'
|
77
|
+
return $response
|
78
|
+
|
65
79
|
end
|
66
80
|
|
67
81
|
case writer
|
82
|
+
|
83
|
+
# ISO 19110 standard for feature catalogue used to describe tabular data dictionaries
|
84
|
+
when 'iso19110'
|
85
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/iso/codelists'))
|
86
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/iso/classes'))
|
87
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/iso/units'))
|
88
|
+
require 'iso19110/iso19110_writer'
|
89
|
+
|
90
|
+
# set the format of the output file based on the writer specified
|
91
|
+
$response[:writerFormat] = 'xml'
|
92
|
+
|
93
|
+
writerClass = Iso19110Writer.new
|
94
|
+
|
95
|
+
# initiate the writer
|
96
|
+
$response[:writerOutput] = writerClass.writeXML(internalObj)
|
97
|
+
if $response[:writerMessages].length > 0
|
98
|
+
$response[:writerPass] = false
|
99
|
+
else
|
100
|
+
$response[:writerPass] = true
|
101
|
+
end
|
102
|
+
|
103
|
+
# ISO 19115-2:2009 standard for geospatial metadata
|
68
104
|
when 'iso19115_2'
|
69
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/
|
70
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/
|
105
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/iso/codelists'))
|
106
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/iso/classes'))
|
71
107
|
require 'iso19115_2/iso19115_2_writer'
|
72
108
|
|
73
109
|
# set the format of the output file based on the writer specified
|
@@ -82,6 +118,12 @@ module ADIWG
|
|
82
118
|
else
|
83
119
|
$response[:writerPass] = true
|
84
120
|
end
|
121
|
+
|
122
|
+
# writer name is missing or not supported
|
123
|
+
else
|
124
|
+
$response[:writerPass] = false
|
125
|
+
$response[:writerMessages] << 'Writer name is missing or not supported.'
|
126
|
+
|
85
127
|
end
|
86
128
|
|
87
129
|
return $response
|
@@ -89,7 +131,7 @@ module ADIWG
|
|
89
131
|
end
|
90
132
|
|
91
133
|
def self.reader_module(moduleName, version)
|
92
|
-
dir = File.join($response[:
|
134
|
+
dir = File.join($response[:readerFound], 'modules_' + version)
|
93
135
|
file = File.join(dir, moduleName)
|
94
136
|
return file
|
95
137
|
end
|
@@ -45,6 +45,7 @@
|
|
45
45
|
# Stan Smith 2014-11-06 added resourceType to resourceInfo for 0.9.0
|
46
46
|
# Stan Smith 2014-11-06 removed metadataScope from metadataInfo for 0.9.0
|
47
47
|
# Stan Smith 2014-11-06 added newAdditionalDocumentation
|
48
|
+
# Stan Smith 2014-12-01 added data dictionary
|
48
49
|
|
49
50
|
class InternalMetadata
|
50
51
|
|
@@ -62,7 +63,8 @@ class InternalMetadata
|
|
62
63
|
version: nil
|
63
64
|
},
|
64
65
|
contacts: [],
|
65
|
-
metadata: {}
|
66
|
+
metadata: {},
|
67
|
+
dataDictionary: {}
|
66
68
|
}
|
67
69
|
end
|
68
70
|
|
@@ -76,7 +78,7 @@ class InternalMetadata
|
|
76
78
|
|
77
79
|
def newContact
|
78
80
|
intObj = {
|
79
|
-
|
81
|
+
contactId: nil,
|
80
82
|
indName: nil,
|
81
83
|
orgName: nil,
|
82
84
|
position: nil,
|
@@ -132,7 +134,7 @@ class InternalMetadata
|
|
132
134
|
|
133
135
|
def newRespParty
|
134
136
|
intObj = {
|
135
|
-
|
137
|
+
contactId: nil,
|
136
138
|
roleName: nil
|
137
139
|
}
|
138
140
|
end
|
@@ -186,7 +188,7 @@ class InternalMetadata
|
|
186
188
|
citTitle: nil,
|
187
189
|
citDate: [],
|
188
190
|
citEdition: nil,
|
189
|
-
|
191
|
+
citResourceIds: [],
|
190
192
|
citResponsibleParty: [],
|
191
193
|
citResourceForms: [],
|
192
194
|
citOlResources: []
|
@@ -359,7 +361,7 @@ class InternalMetadata
|
|
359
361
|
|
360
362
|
def newTimeInstant
|
361
363
|
intObj = {
|
362
|
-
|
364
|
+
timeId: nil,
|
363
365
|
description: nil,
|
364
366
|
timePosition: {}
|
365
367
|
}
|
@@ -367,7 +369,7 @@ class InternalMetadata
|
|
367
369
|
|
368
370
|
def newTimePeriod
|
369
371
|
intObj = {
|
370
|
-
|
372
|
+
timeId: nil,
|
371
373
|
description: nil,
|
372
374
|
beginTime: {},
|
373
375
|
endTime: {}
|
@@ -459,7 +461,7 @@ class InternalMetadata
|
|
459
461
|
|
460
462
|
def newDataProcessStep
|
461
463
|
intObj = {
|
462
|
-
|
464
|
+
stepId: nil,
|
463
465
|
stepDescription: nil,
|
464
466
|
stepRationale: nil,
|
465
467
|
stepDateTime: {},
|
@@ -508,4 +510,82 @@ class InternalMetadata
|
|
508
510
|
}
|
509
511
|
end
|
510
512
|
|
513
|
+
def newDataDictionary
|
514
|
+
intObj = {
|
515
|
+
dictionaryInfo: {},
|
516
|
+
domains: [],
|
517
|
+
entities: []
|
518
|
+
}
|
519
|
+
end
|
520
|
+
|
521
|
+
def newDictionaryInfo
|
522
|
+
intObj = {
|
523
|
+
dictCitation: {},
|
524
|
+
dictDescription: nil,
|
525
|
+
dictResourceType: nil,
|
526
|
+
dictLanguage: nil
|
527
|
+
}
|
528
|
+
end
|
529
|
+
|
530
|
+
def newDictionaryDomain
|
531
|
+
intObj = {
|
532
|
+
domainId: nil,
|
533
|
+
domainName: nil,
|
534
|
+
domainCode: nil,
|
535
|
+
domainDescription: nil,
|
536
|
+
domainItems: []
|
537
|
+
}
|
538
|
+
end
|
539
|
+
|
540
|
+
def newDomainItem
|
541
|
+
intObj = {
|
542
|
+
itemName: nil,
|
543
|
+
itemValue: nil,
|
544
|
+
itemDefinition: nil
|
545
|
+
}
|
546
|
+
end
|
547
|
+
|
548
|
+
def newEntity
|
549
|
+
intObj = {
|
550
|
+
entityId: nil,
|
551
|
+
entityName: nil,
|
552
|
+
entityCode: nil,
|
553
|
+
entityDefinition: nil,
|
554
|
+
primaryKey: [],
|
555
|
+
indexes: [],
|
556
|
+
attributes: [],
|
557
|
+
foreignKeys: []
|
558
|
+
}
|
559
|
+
end
|
560
|
+
|
561
|
+
def newEntityIndex
|
562
|
+
intObj = {
|
563
|
+
indexCode: nil,
|
564
|
+
duplicate: false,
|
565
|
+
attributeNames: []
|
566
|
+
}
|
567
|
+
end
|
568
|
+
|
569
|
+
def newEntityAttribute
|
570
|
+
intObj = {
|
571
|
+
attributeName: nil,
|
572
|
+
attributeCode: nil,
|
573
|
+
attributeDefinition: nil,
|
574
|
+
dataType: nil,
|
575
|
+
allowNull: true,
|
576
|
+
unitOfMeasure: nil,
|
577
|
+
domainId: nil,
|
578
|
+
minValue: nil,
|
579
|
+
maxValue: nil
|
580
|
+
}
|
581
|
+
end
|
582
|
+
|
583
|
+
def newEntityForeignKey
|
584
|
+
intObj = {
|
585
|
+
fkLocalAttributes: [],
|
586
|
+
fkReferencedEntity: nil,
|
587
|
+
fkReferencedAttributes: []
|
588
|
+
}
|
589
|
+
end
|
590
|
+
|
511
591
|
end
|
data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_reader.rb → mdJson/mdJson_reader.rb}
RENAMED
@@ -9,12 +9,15 @@
|
|
9
9
|
# Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
|
10
10
|
# Stan Smith 2014-07-08 moved json schema version testing to 'adiwg_1_get_version'
|
11
11
|
# Stan Smith 2014-08-18 add json name/version to internal object
|
12
|
+
# Stan Smith 2014-12-01 add data dictionary
|
13
|
+
# Stan Smith 2014-12-03 changed class name to MdJsonReader from AdiwgJsonReader
|
12
14
|
|
13
15
|
require 'json'
|
14
16
|
require ADIWG::Mdtranslator.reader_module('module_contacts', $response[:readerVersionUsed])
|
15
17
|
require ADIWG::Mdtranslator.reader_module('module_metadata', $response[:readerVersionUsed])
|
18
|
+
require ADIWG::Mdtranslator.reader_module('module_dataDictionary', $response[:readerVersionUsed])
|
16
19
|
|
17
|
-
class
|
20
|
+
class MdJsonReader
|
18
21
|
|
19
22
|
def initialize
|
20
23
|
end
|
@@ -57,19 +60,25 @@ class AdiwgJsonReader
|
|
57
60
|
aContacts = hashObj['contact']
|
58
61
|
aContacts.each do |hContact|
|
59
62
|
unless hContact.empty?
|
60
|
-
intBase[:contacts] <<
|
63
|
+
intBase[:contacts] << Md_Contact.unpack(hContact)
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
68
|
# add default contacts
|
66
|
-
intBase[:contacts].concat(
|
69
|
+
intBase[:contacts].concat(Md_Contact.setDefaultContacts)
|
67
70
|
|
68
71
|
# metadata
|
69
72
|
# load metadata from the hash object
|
70
73
|
if hashObj.has_key?('metadata')
|
71
74
|
hMetadata = hashObj['metadata']
|
72
|
-
intBase[:metadata] =
|
75
|
+
intBase[:metadata] = Md_Metadata.unpack(hMetadata)
|
76
|
+
end
|
77
|
+
|
78
|
+
# data dictionary
|
79
|
+
if hashObj.has_key?('dataDictionary')
|
80
|
+
hDictionary = hashObj['dataDictionary']
|
81
|
+
intBase[:dataDictionary] = Md_DataDictionary.unpack(hDictionary)
|
73
82
|
end
|
74
83
|
|
75
84
|
# return ADIwg internal container
|
data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_validator.rb → mdJson/mdJson_validator.rb}
RENAMED
@@ -5,6 +5,8 @@
|
|
5
5
|
# Stan Smith 2014-07-21 added json structure validation method
|
6
6
|
# Stan Smith 2014-08-21 parsed json-schema validation message to readable text
|
7
7
|
# Stan Smith 2014-09-26 added processing of minor release numbers
|
8
|
+
# Stan Smith 2014-12-01 changed adiwgJson to mdJson in version name check
|
9
|
+
# Stan Smith 2014-12-03 changed class name to MdJsonValidation from AdiwgJsonValidation
|
8
10
|
|
9
11
|
require 'json'
|
10
12
|
require 'json-schema'
|
@@ -12,7 +14,7 @@ require 'adiwg-json_schemas'
|
|
12
14
|
#json-schema patch
|
13
15
|
require 'validator.rb'
|
14
16
|
|
15
|
-
module
|
17
|
+
module MdJsonValidation
|
16
18
|
|
17
19
|
def self.validate(file)
|
18
20
|
|
@@ -43,10 +45,10 @@ module AdiwgJsonValidation
|
|
43
45
|
if hVersion.has_key?('name')
|
44
46
|
s = hVersion['name']
|
45
47
|
if !s.nil?
|
46
|
-
$response[:
|
47
|
-
if s != '
|
48
|
+
$response[:readerFound] = s
|
49
|
+
if s != 'mdJson'
|
48
50
|
$response[:readerStructurePass] = false
|
49
|
-
$response[:readerStructureMessages] << "input file version name must be '
|
51
|
+
$response[:readerStructureMessages] << "input file version name must be 'mdJson'"
|
50
52
|
$response[:readerStructureMessages] << "found version name '#{s}'"
|
51
53
|
return
|
52
54
|
end
|
@@ -67,15 +69,21 @@ module AdiwgJsonValidation
|
|
67
69
|
# ...example: 'modules_1.2.0'
|
68
70
|
if !requestReaderVersion.nil?
|
69
71
|
aVersionParts = requestReaderVersion.split('.')
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
if 3 == aVersionParts.length
|
73
|
+
readerVersion = aVersionParts[0] +'.' + aVersionParts[1] + '.0'
|
74
|
+
dir = File.join(File.dirname(__FILE__),'modules_' + readerVersion)
|
75
|
+
if !File.directory?(dir)
|
76
|
+
$response[:readerStructurePass] = false
|
77
|
+
$response[:readerStructureMessages] << 'input file version is not supported'
|
78
|
+
$response[:readerStructureMessages] << "mdJson version requested was '#{requestReaderVersion}'"
|
79
|
+
return
|
80
|
+
end
|
81
|
+
$response[:readerVersionUsed] = readerVersion
|
82
|
+
else
|
73
83
|
$response[:readerStructurePass] = false
|
74
|
-
$response[:readerStructureMessages] <<
|
75
|
-
$response[:readerStructureMessages] << "adiwgJson version requested was '#{requestReaderVersion}'"
|
84
|
+
$response[:readerStructureMessages] << "input file version must be in the form MAJOR.MINOR.PATCH, e.g. 1.2.3"
|
76
85
|
return
|
77
86
|
end
|
78
|
-
$response[:readerVersionUsed] = readerVersion
|
79
87
|
end
|
80
88
|
else
|
81
89
|
$response[:readerStructurePass] = false
|