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.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -6
  3. data/adiwg-mdtranslator.gemspec +2 -2
  4. data/bin/mdtranslator +10 -10
  5. data/lib/adiwg/mdtranslator.rb +54 -12
  6. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +87 -7
  7. data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_reader.rb → mdJson/mdJson_reader.rb} +13 -4
  8. data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_validator.rb → mdJson/mdJson_validator.rb} +18 -10
  9. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_additionalDocumentation.rb +2 -2
  10. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_address.rb +1 -1
  11. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_associatedResource.rb +3 -3
  12. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_boundingBox.rb +1 -1
  13. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_browseGraphic.rb +1 -1
  14. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_citation.rb +5 -5
  15. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_contacts.rb +7 -7
  16. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_coordinates.rb +1 -1
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dataDictionary.rb +53 -0
  18. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_dataQuality.rb +2 -2
  19. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_dateTime.rb +1 -1
  20. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_descriptiveKeyword.rb +2 -2
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dictionaryInfo.rb +52 -0
  22. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_distributionInfo.rb +4 -4
  23. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domain.rb +62 -0
  24. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domainItem.rb +42 -0
  25. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entity.rb +92 -0
  26. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityAttribute.rb +91 -0
  27. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityForeignKey.rb +43 -0
  28. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityIndex.rb +42 -0
  29. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_extent.rb +4 -4
  30. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geoCoordSystem.rb +1 -1
  31. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geoProperties.rb +4 -4
  32. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geographicElement.rb +12 -12
  33. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_legalConstraint.rb +1 -1
  34. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_lineString.rb +2 -2
  35. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_lineage.rb +3 -3
  36. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadata.rb +6 -6
  37. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadataExtension.rb +2 -2
  38. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadataInfo.rb +8 -8
  39. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_onlineResource.rb +1 -1
  40. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_phone.rb +1 -1
  41. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_point.rb +2 -2
  42. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_polygon.rb +2 -2
  43. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_processStep.rb +4 -4
  44. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resolution.rb +1 -1
  45. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceFormat.rb +1 -1
  46. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceIdentifier.rb +2 -2
  47. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceInfo.rb +16 -16
  48. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceMaintenance.rb +2 -2
  49. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceSpecificUsage.rb +2 -2
  50. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_responsibleParty.rb +2 -2
  51. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_securityConstraint.rb +1 -1
  52. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_source.rb +3 -3
  53. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_spatialReference.rb +1 -1
  54. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_taxonClass.rb +1 -1
  55. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_taxonomy.rb +5 -5
  56. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_temporalElement.rb +4 -4
  57. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_timeInstant.rb +3 -3
  58. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_timePeriod.rb +4 -4
  59. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_verticalElement.rb +1 -1
  60. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_voucher.rb +2 -2
  61. data/lib/adiwg/mdtranslator/readers/mdJson/readme.md +19 -0
  62. data/lib/adiwg/mdtranslator/version.rb +5 -1
  63. data/lib/adiwg/mdtranslator/writers/iso/classes/class_FCfeatureCatalogue.rb +171 -0
  64. data/lib/adiwg/mdtranslator/writers/{iso19115_2/classes/class_metadata.rb → iso/classes/class_MImetadata.rb} +3 -3
  65. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_address.rb +0 -0
  66. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_aggregateInformation.rb +0 -0
  67. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_boundingPolygon.rb +0 -0
  68. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_browseGraphic.rb +0 -0
  69. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_citation.rb +3 -3
  70. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_contact.rb +1 -1
  71. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_dataIdentification.rb +0 -0
  72. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_dataQuality.rb +0 -0
  73. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_date.rb +0 -0
  74. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_digitalTransferOptions.rb +0 -0
  75. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_distribution.rb +0 -0
  76. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_distributor.rb +0 -0
  77. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_extent.rb +0 -0
  78. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureAttribute.rb +114 -0
  79. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureConstraint.rb +55 -0
  80. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureType.rb +120 -0
  81. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_format.rb +0 -0
  82. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_genericMetaData.rb +0 -0
  83. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicBoundingBox.rb +0 -0
  84. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicDescription.rb +0 -0
  85. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicElement.rb +0 -0
  86. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_identifier.rb +0 -0
  87. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_keyword.rb +0 -0
  88. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_legalConstraints.rb +0 -0
  89. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_lineString.rb +1 -1
  90. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_lineage.rb +0 -0
  91. data/lib/adiwg/mdtranslator/writers/iso/classes/class_listedValue.rb +68 -0
  92. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_maintenanceInformation.rb +0 -0
  93. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_medium.rb +0 -0
  94. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_metadataExtension.rb +0 -0
  95. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_multiGeometry.rb +3 -3
  96. data/lib/adiwg/mdtranslator/writers/iso/classes/class_multiplicity.rb +44 -0
  97. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_onlineResource.rb +0 -0
  98. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_point.rb +1 -1
  99. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_polygon.rb +2 -2
  100. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_processStep.rb +1 -1
  101. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_referenceIdentifier.rb +0 -0
  102. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_referenceSystem.rb +0 -0
  103. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_resolution.rb +0 -0
  104. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_responsibleParty.rb +1 -1
  105. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_securityConstraints.rb +0 -0
  106. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_source.rb +0 -0
  107. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_standardOrderProcess.rb +0 -0
  108. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_taxonClassification.rb +0 -0
  109. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_taxonSystem.rb +0 -0
  110. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_telephone.rb +0 -0
  111. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_temporalExtent.rb +0 -0
  112. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_timeInstant.rb +1 -1
  113. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_timePeriod.rb +1 -1
  114. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_usage.rb +0 -0
  115. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_useConstraints.rb +0 -0
  116. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_verticalExtent.rb +0 -0
  117. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_vouchers.rb +0 -0
  118. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_associationType.rb +0 -0
  119. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_characterSet.rb +0 -0
  120. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_classification.rb +0 -0
  121. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_datatype.rb +0 -0
  122. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_dateType.rb +0 -0
  123. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_initiativeType.rb +0 -0
  124. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_keywordType.rb +0 -0
  125. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_maintenanceFrequency.rb +0 -0
  126. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_mediumFormat.rb +0 -0
  127. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_mediumName.rb +0 -0
  128. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_obligation.rb +0 -0
  129. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_onlineFunction.rb +0 -0
  130. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_presentationForm.rb +0 -0
  131. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_progress.rb +0 -0
  132. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_restriction.rb +0 -0
  133. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_role.rb +0 -0
  134. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_scope.rb +0 -0
  135. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_spatialRepresentationType.rb +0 -0
  136. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_topicCategory.rb +0 -0
  137. data/lib/adiwg/mdtranslator/writers/iso/units/class_baseUnit.rb +27 -0
  138. data/lib/adiwg/mdtranslator/writers/iso/units/class_conventionalUnit.rb +53 -0
  139. data/lib/adiwg/mdtranslator/writers/iso/units/class_definitionUnit.rb +24 -0
  140. data/lib/adiwg/mdtranslator/writers/iso/units/class_derivedUnit.rb +31 -0
  141. data/lib/adiwg/mdtranslator/writers/iso/units/class_unitsOfMeasure.rb +224 -0
  142. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +28 -0
  143. data/lib/adiwg/mdtranslator/writers/iso19110/readme.md +13 -0
  144. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +1 -1
  145. data/lib/adiwg/mdtranslator/writers/iso19115_2/readme.md +6 -9
  146. data/test/tc_translation.rb +35 -18
  147. metadata +166 -146
  148. data/lib/adiwg/mdtranslator/readers/adiwgJson/readme.md +0 -19
  149. data/mdtranslator.rb +0 -187
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 010b1cbf2339294147a58e5b78ded88b4df91be5
4
- data.tar.gz: 8364931e9e108a14613fc714c32062e6c76f068c
3
+ metadata.gz: eb133f79461697e8f43a63ffb954558529f1c32d
4
+ data.tar.gz: 8d3e5b49675cf8bd0232d2ff01a8935f9bd8bf0a
5
5
  SHA512:
6
- metadata.gz: 31f1fb5def4ba901a6c029f785c6c30d551e9e1e5a66aaaac3b7484d0bfbcfb78f47ee813997fd09d81a2193c7b626102712c2bb9b5b1a97daef9333509ac42a
7
- data.tar.gz: d941add4d9e083587fd7fb800b2bb828373022ae9920343d59278357fcc91ab0fc0070e5e196036b0c47adad33a06bfe7db24f5a0b59d6c06f2d0924c9c066b1
6
+ metadata.gz: 9274cdf2cbeb17c54e1f5592d0920d169ebb570a83abf83b896adb75e575393f4666a02332c2d215f44a360d521c2a1a47c01a24b50da93e6fb72e3bf26ea33c
7
+ data.tar.gz: 77005bdc01f83d02b127def3d4e5a3a9542d98b098c574facaaa3c22eb0cb4ae367a4f3b4fe7e291fa6b692758715debd31bd3ff660b0fcfb19a16e680c3efa0
data/.gitignore CHANGED
@@ -13,12 +13,7 @@ lib/bundler/man
13
13
  pkg
14
14
  rdoc
15
15
  spec/reports
16
- test/tmp
17
- test/version_tmp
18
- test/adiwgJson_full_test_example.json
19
- test/adiwgJson_min_test_example.json
20
- test/adiwgJson_template_data.json
21
- test/dev.rb
16
+ dev
22
17
  tmp
23
18
  *.bundle
24
19
  *.so
@@ -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
@@ -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 => 'adiwgJson'
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.write mdReturn.to_json
63
+ $stdout.puts mdReturn.to_json
64
64
  return
65
65
  else
66
- $stdout.write 'Success'
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.write mdReturn.to_json
76
+ $stdout.puts mdReturn.to_json
77
77
  return
78
78
  else
79
- $stdout.write mdReturn[:writerOutput].to_s
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.write mdReturn.to_json
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.write s
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.write mdReturn.to_json
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.write s
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.write ADIWG::Mdtranslator::VERSION
168
+ $stdout.puts ADIWG::Mdtranslator::VERSION
169
169
  end
170
170
 
171
171
  Mdtranslator.start(ARGV)
@@ -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
- readerName: reader,
36
- readerNameFound: nil,
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
- when 'adiwgJson'
53
- require 'adiwgJson/adiwgJson_validator'
57
+
58
+ # ADIwg mdJson JSON schema
59
+ when 'mdJson'
60
+ require 'mdJson/mdJson_validator'
54
61
 
55
62
  # validate adiwgJson file
56
- AdiwgJsonValidation.validate(file)
63
+ MdJsonValidation.validate(file)
57
64
  if $response[:readerStructurePass] && $response[:readerValidationPass]
58
65
  # initiate the reader
59
- require 'adiwgJson/adiwgJson_reader'
60
- readerClass = AdiwgJsonReader.new
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/iso19115_2/codelists'))
70
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'mdtranslator/writers/iso19115_2/classes'))
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[:readerName], 'modules_' + version)
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
- contactID: nil,
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
- contactID: nil,
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
- citResourceIDs: [],
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
- timeID: nil,
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
- timeID: nil,
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
- stepID: nil,
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
@@ -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 AdiwgJsonReader
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] << Adiwg_Contact.unpack(hContact)
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(Adiwg_Contact.setDefaultContacts)
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] = Adiwg_Metadata.unpack(hMetadata)
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
@@ -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 AdiwgJsonValidation
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[:readerNameFound] = s
47
- if s != 'adiwgJson'
48
+ $response[:readerFound] = s
49
+ if s != 'mdJson'
48
50
  $response[:readerStructurePass] = false
49
- $response[:readerStructureMessages] << "input file version name must be 'adiwgJson'"
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
- readerVersion = aVersionParts[0] +'.' + aVersionParts[1] + '.0'
71
- dir = File.join(File.dirname(__FILE__),'modules_' + readerVersion)
72
- if !File.directory?(dir)
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] << 'input file version is not supported'
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