adiwg-mdtranslator 0.10.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -4
  3. data/Rakefile +4 -1
  4. data/adiwg-mdtranslator.gemspec +10 -8
  5. data/bin/mdtranslator +8 -2
  6. data/lib/adiwg/mdtranslator.rb +72 -147
  7. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +538 -538
  8. data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +78 -78
  9. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +153 -74
  10. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb +41 -108
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_additionalDocumentation.rb +54 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_address.rb +89 -0
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_associatedResource.rb +82 -0
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_boundingBox.rb +62 -0
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_browseGraphic.rb +69 -0
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_citation.rb +122 -0
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_contacts.rb +150 -0
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_coordinates.rb +63 -0
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_dataDictionary.rb +63 -0
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_dataQuality.rb +51 -0
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_dateTime.rb +38 -0
  22. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_descriptiveKeyword.rb +60 -0
  23. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_dictionaryInfo.rb +63 -0
  24. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_distributionInfo.rb +161 -0
  25. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_domain.rb +73 -0
  26. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_domainItem.rb +53 -0
  27. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_entity.rb +103 -0
  28. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_entityAttribute.rb +102 -0
  29. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_entityForeignKey.rb +54 -0
  30. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_entityIndex.rb +53 -0
  31. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_extent.rb +73 -0
  32. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_geoCoordSystem.rb +57 -0
  33. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_geoProperties.rb +100 -0
  34. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_geographicElement.rb +179 -0
  35. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_legalConstraint.rb +56 -0
  36. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_lineString.rb +36 -0
  37. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_lineage.rb +61 -0
  38. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_mdJson.rb +69 -0
  39. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_metadata.rb +88 -0
  40. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_metadataExtension.rb +51 -0
  41. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_metadataInfo.rb +123 -0
  42. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_onlineResource.rb +79 -0
  43. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_phone.rb +79 -0
  44. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_point.rb +36 -0
  45. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_polygon.rb +66 -0
  46. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_processStep.rb +75 -0
  47. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_resolution.rb +53 -0
  48. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_resourceFormat.rb +46 -0
  49. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_resourceIdentifier.rb +60 -0
  50. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_resourceInfo.rb +328 -0
  51. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_resourceMaintenance.rb +61 -0
  52. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_resourceSpecificUsage.rb +61 -0
  53. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_responsibleParty.rb +48 -0
  54. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_securityConstraint.rb +63 -0
  55. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_source.rb +59 -0
  56. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_spatialReference.rb +59 -0
  57. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_taxonClass.rb +54 -0
  58. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_taxonomy.rb +94 -0
  59. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_temporalElement.rb +82 -0
  60. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_timeInstant.rb +56 -0
  61. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_timePeriod.rb +64 -0
  62. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_verticalElement.rb +64 -0
  63. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_voucher.rb +49 -0
  64. data/lib/adiwg/mdtranslator/readers/mdJson/readme.md +1 -1
  65. data/lib/adiwg/mdtranslator/readers/mdJson/validator.rb +43 -0
  66. data/lib/adiwg/mdtranslator/readers/mdReaders.rb +55 -0
  67. data/lib/adiwg/mdtranslator/version.rb +15 -4
  68. data/lib/adiwg/mdtranslator/writers/iso/classes/class_address.rb +107 -86
  69. data/lib/adiwg/mdtranslator/writers/iso/classes/class_aggregateInformation.rb +68 -57
  70. data/lib/adiwg/mdtranslator/writers/iso/classes/class_boundingPolygon.rb +59 -48
  71. data/lib/adiwg/mdtranslator/writers/iso/classes/class_browseGraphic.rb +57 -46
  72. data/lib/adiwg/mdtranslator/writers/iso/classes/class_citation.rb +149 -138
  73. data/lib/adiwg/mdtranslator/writers/iso/classes/class_contact.rb +83 -72
  74. data/lib/adiwg/mdtranslator/writers/iso/classes/class_dataIdentification.rb +334 -322
  75. data/lib/adiwg/mdtranslator/writers/iso/classes/class_dataQuality.rb +46 -34
  76. data/lib/adiwg/mdtranslator/writers/iso/classes/class_date.rb +47 -36
  77. data/lib/adiwg/mdtranslator/writers/iso/classes/class_digitalTransferOptions.rb +42 -31
  78. data/lib/adiwg/mdtranslator/writers/iso/classes/class_distribution.rb +29 -18
  79. data/lib/adiwg/mdtranslator/writers/iso/classes/class_distributor.rb +77 -66
  80. data/lib/adiwg/mdtranslator/writers/iso/classes/class_extent.rb +87 -76
  81. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureAttribute.rb +113 -102
  82. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureConstraint.rb +44 -33
  83. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureType.rb +121 -110
  84. data/lib/adiwg/mdtranslator/writers/iso/classes/class_format.rb +45 -34
  85. data/lib/adiwg/mdtranslator/writers/iso/classes/class_genericMetaData.rb +45 -36
  86. data/lib/adiwg/mdtranslator/writers/iso/classes/class_geographicBoundingBox.rb +78 -67
  87. data/lib/adiwg/mdtranslator/writers/iso/classes/class_geographicDescription.rb +25 -14
  88. data/lib/adiwg/mdtranslator/writers/iso/classes/class_geographicElement.rb +30 -19
  89. data/lib/adiwg/mdtranslator/writers/iso/classes/class_identifier.rb +41 -30
  90. data/lib/adiwg/mdtranslator/writers/iso/classes/class_keyword.rb +58 -49
  91. data/lib/adiwg/mdtranslator/writers/iso/classes/class_legalConstraints.rb +65 -54
  92. data/lib/adiwg/mdtranslator/writers/iso/classes/class_lineString.rb +77 -66
  93. data/lib/adiwg/mdtranslator/writers/iso/classes/class_lineage.rb +62 -51
  94. data/lib/adiwg/mdtranslator/writers/iso/classes/class_listedValue.rb +70 -59
  95. data/lib/adiwg/mdtranslator/writers/iso/classes/class_maintenanceInformation.rb +54 -43
  96. data/lib/adiwg/mdtranslator/writers/iso/classes/class_medium.rb +58 -47
  97. data/lib/adiwg/mdtranslator/writers/iso/classes/class_metadataExtension.rb +154 -143
  98. data/lib/adiwg/mdtranslator/writers/iso/classes/class_multiGeometry.rb +138 -127
  99. data/lib/adiwg/mdtranslator/writers/iso/classes/class_multiplicity.rb +37 -26
  100. data/lib/adiwg/mdtranslator/writers/iso/classes/class_onlineResource.rb +79 -68
  101. data/lib/adiwg/mdtranslator/writers/iso/classes/class_point.rb +77 -66
  102. data/lib/adiwg/mdtranslator/writers/iso/classes/class_polygon.rb +98 -87
  103. data/lib/adiwg/mdtranslator/writers/iso/classes/class_processStep.rb +80 -69
  104. data/lib/adiwg/mdtranslator/writers/iso/classes/class_referenceIdentifier.rb +38 -27
  105. data/lib/adiwg/mdtranslator/writers/iso/classes/class_referenceSystem.rb +25 -14
  106. data/lib/adiwg/mdtranslator/writers/iso/classes/class_resolution.rb +51 -40
  107. data/lib/adiwg/mdtranslator/writers/iso/classes/class_responsibleParty.rb +88 -77
  108. data/lib/adiwg/mdtranslator/writers/iso/classes/class_securityConstraints.rb +70 -59
  109. data/lib/adiwg/mdtranslator/writers/iso/classes/class_source.rb +58 -47
  110. data/lib/adiwg/mdtranslator/writers/iso/classes/class_standardOrderProcess.rb +75 -63
  111. data/lib/adiwg/mdtranslator/writers/iso/classes/class_taxonClassification.rb +55 -44
  112. data/lib/adiwg/mdtranslator/writers/iso/classes/class_taxonSystem.rb +98 -87
  113. data/lib/adiwg/mdtranslator/writers/iso/classes/class_telephone.rb +73 -62
  114. data/lib/adiwg/mdtranslator/writers/iso/classes/class_temporalExtent.rb +58 -47
  115. data/lib/adiwg/mdtranslator/writers/iso/classes/class_timeInstant.rb +36 -27
  116. data/lib/adiwg/mdtranslator/writers/iso/classes/class_timePeriod.rb +42 -33
  117. data/lib/adiwg/mdtranslator/writers/iso/classes/class_usage.rb +59 -48
  118. data/lib/adiwg/mdtranslator/writers/iso/classes/class_useConstraints.rb +26 -15
  119. data/lib/adiwg/mdtranslator/writers/iso/classes/class_verticalExtent.rb +52 -41
  120. data/lib/adiwg/mdtranslator/writers/iso/classes/class_vouchers.rb +39 -28
  121. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_associationType.rb +41 -29
  122. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_characterSet.rb +82 -47
  123. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_classification.rb +42 -24
  124. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_datatype.rb +56 -34
  125. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_dateType.rb +34 -19
  126. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_initiativeType.rb +41 -29
  127. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_keywordType.rb +46 -27
  128. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_maintenanceFrequency.rb +55 -36
  129. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_mediumFormat.rb +44 -26
  130. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_mediumName.rb +68 -38
  131. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_obligation.rb +32 -25
  132. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_onlineFunction.rb +42 -25
  133. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_presentationForm.rb +58 -31
  134. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_progress.rb +44 -25
  135. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_restriction.rb +47 -32
  136. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_role.rb +52 -29
  137. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_scope.rb +58 -35
  138. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_spatialRepresentationType.rb +43 -30
  139. data/lib/adiwg/mdtranslator/writers/iso/codelists/code_topicCategory.rb +51 -44
  140. data/lib/adiwg/mdtranslator/writers/iso/units/class_baseUnit.rb +26 -15
  141. data/lib/adiwg/mdtranslator/writers/iso/units/class_conventionalUnit.rb +56 -45
  142. data/lib/adiwg/mdtranslator/writers/iso/units/class_definitionUnit.rb +23 -12
  143. data/lib/adiwg/mdtranslator/writers/iso/units/class_derivedUnit.rb +30 -19
  144. data/lib/adiwg/mdtranslator/writers/iso/units/class_unitsOfMeasure.rb +223 -212
  145. data/lib/adiwg/mdtranslator/writers/iso19110/class_FCfeatureCatalogue.rb +174 -0
  146. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +41 -12
  147. data/lib/adiwg/mdtranslator/writers/iso19115_2/class_MImetadata.rb +347 -0
  148. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +151 -119
  149. data/lib/adiwg/mdtranslator/writers/mdWriters.rb +63 -0
  150. data/test/readers/mdJson/v0_9/tc_reader_mdjson_additionalDocumentation.rb +84 -0
  151. data/test/readers/mdJson/v0_9/tc_reader_mdjson_address.rb +100 -0
  152. data/test/readers/mdJson/v0_9/tc_reader_mdjson_associatedResource.rb +100 -0
  153. data/test/readers/mdJson/v0_9/tc_reader_mdjson_browseGraphic.rb +66 -0
  154. data/test/readers/mdJson/v0_9/tc_reader_mdjson_citation.rb +115 -0
  155. data/test/readers/mdJson/v0_9/tc_reader_mdjson_contact.rb +137 -0
  156. data/test/readers/mdJson/v0_9/tc_reader_mdjson_onlineResource.rb +47 -0
  157. data/test/readers/mdJson/v0_9/tc_reader_mdjson_phone.rb +128 -0
  158. data/test/readers/mdJson/v0_9/tc_translation.rb +82 -0
  159. data/test/writers/iso19115_2/tc_writer_iso19115_2_address.rb +222 -0
  160. metadata +87 -60
  161. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_additionalDocumentation.rb +0 -36
  162. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_address.rb +0 -71
  163. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_associatedResource.rb +0 -66
  164. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_boundingBox.rb +0 -51
  165. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_browseGraphic.rb +0 -52
  166. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_citation.rb +0 -104
  167. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_contacts.rb +0 -121
  168. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_coordinates.rb +0 -52
  169. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dataDictionary.rb +0 -53
  170. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dataQuality.rb +0 -40
  171. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dateTime.rb +0 -27
  172. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_descriptiveKeyword.rb +0 -49
  173. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dictionaryInfo.rb +0 -52
  174. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_distributionInfo.rb +0 -150
  175. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domain.rb +0 -62
  176. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domainItem.rb +0 -42
  177. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entity.rb +0 -92
  178. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityAttribute.rb +0 -91
  179. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityForeignKey.rb +0 -43
  180. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityIndex.rb +0 -42
  181. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_extent.rb +0 -62
  182. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_geoCoordSystem.rb +0 -46
  183. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_geoProperties.rb +0 -89
  184. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_geographicElement.rb +0 -168
  185. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_legalConstraint.rb +0 -45
  186. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_lineString.rb +0 -25
  187. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_lineage.rb +0 -50
  188. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_metadata.rb +0 -77
  189. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_metadataExtension.rb +0 -40
  190. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_metadataInfo.rb +0 -112
  191. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_onlineResource.rb +0 -62
  192. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_phone.rb +0 -59
  193. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_point.rb +0 -25
  194. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_polygon.rb +0 -55
  195. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_processStep.rb +0 -64
  196. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_resolution.rb +0 -42
  197. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_resourceFormat.rb +0 -35
  198. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_resourceIdentifier.rb +0 -49
  199. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_resourceInfo.rb +0 -317
  200. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_resourceMaintenance.rb +0 -50
  201. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_resourceSpecificUsage.rb +0 -50
  202. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_responsibleParty.rb +0 -37
  203. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_securityConstraint.rb +0 -52
  204. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_source.rb +0 -48
  205. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_spatialReference.rb +0 -48
  206. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_taxonClass.rb +0 -43
  207. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_taxonomy.rb +0 -83
  208. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_temporalElement.rb +0 -71
  209. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_timeInstant.rb +0 -45
  210. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_timePeriod.rb +0 -53
  211. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_verticalElement.rb +0 -53
  212. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_voucher.rb +0 -38
  213. data/lib/adiwg/mdtranslator/validator.rb +0 -43
  214. data/lib/adiwg/mdtranslator/writers/iso/classes/class_FCfeatureCatalogue.rb +0 -171
  215. data/lib/adiwg/mdtranslator/writers/iso/classes/class_MImetadata.rb +0 -333
  216. data/test/tc_translation.rb +0 -73
@@ -5,127 +5,159 @@
5
5
  # Stan Smith 2014-06-04 add internal object pre-scan to create extents
6
6
  # ... for geometry supplemental information
7
7
  # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
8
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../iso/codelists'))
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../iso/classes'))
8
12
 
9
13
  require 'builder'
10
14
  require 'date'
11
15
  require 'uuidtools'
12
- require 'class_MImetadata'
13
-
14
- $idCount = '_000'
15
-
16
- class Iso191152Writer
17
-
18
- def initialize
19
- end
20
-
21
- def writeXML(internalObj)
22
-
23
- # pre-scan the internal object to create a new extents for each geometry
24
- # ... that has supplemental information (temporal, vertical, identity)
25
- # ... new extents will be added to internalObj as needed
26
- prescanGeoElements(internalObj)
27
-
28
- # create new XML document
29
- xml = Builder::XmlMarkup.new(indent: 3)
30
- metadataWriter = MI_Metadata.new(xml)
31
- metadata = metadataWriter.writeXML(internalObj)
32
-
33
- return metadata
34
- end
35
-
36
- def prescanGeoElements(internalObj)
37
- # supplemental information for the geographic element is carried in the
38
- # ... internal structure in the temporalElements:, verticalElements:,
39
- # ... and elementIdentifiers: attributes of the extGeoElements:
40
- # ... of the extent.
41
- # since temporal, vertical, and identify information in ISO is a property
42
- # ... of EX_Extent and not of the geographicElement,
43
- # ... this code creates a new extent for each geographicElement
44
- # ... that has supplemental information and
45
- # ... moves the supplemental information from the geometry to the new extent.
46
- # In this implementation, supplemental information is only allowed for
47
- # ... geometry types of Point, LineString, and Polygon
48
- aExtents = internalObj[:metadata][:resourceInfo][:extents]
49
- unless aExtents.empty?
50
- aExtents.each do |hExtent|
51
- aGeoElements = hExtent[:extGeoElements]
52
- unless aGeoElements.empty?
53
- aGeoElements.each do |hGeoElement|
54
- hGeometry = hGeoElement[:elementGeometry]
55
- unless hGeometry.empty?
56
- geoType = hGeometry[:geoType]
57
- case geoType
58
- when 'Point', 'LineString', 'Polygon'
59
- newExtent = extentFromGeoElement(hGeoElement, geoType)
60
- if !newExtent.nil?
61
- aExtents << newExtent
62
- end
63
-
64
- when 'MultiGeometry'
65
- aGeoMembers = hGeometry[:geometry]
66
- unless aGeoMembers.empty?
67
- aGeoMembers.each do |hGeoMemberElement|
68
- hGeometry = hGeoMemberElement[:elementGeometry]
69
- unless hGeometry.empty?
70
- geoType = hGeometry[:geoType]
71
- case geoType
72
- when 'Point', 'LineString', 'Polygon'
73
- newExtent = extentFromGeoElement(hGeoMemberElement, geoType)
74
- if !newExtent.nil?
75
- aExtents << newExtent
76
- end
77
- end
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end
87
- end
88
-
89
- def extentFromGeoElement(hGeoElement, geoType)
90
- # build new extent to portray supplemental information
91
- # from elementGeometry
92
- if !hGeoElement[:temporalElements].empty? ||
93
- !hGeoElement[:verticalElements].empty? ||
94
- !hGeoElement[:elementIdentifiers].empty?
95
-
96
- # get unique id for geometry
97
- # if geometry id was missing, set it at this time so
98
- # ... it will match the supplemental information extent description
99
- geoID = hGeoElement[:elementId]
100
- if geoID.nil?
101
- $idCount = $idCount.succ
102
- geoID = geoType + $idCount
103
- hGeoElement[:elementId] = geoID
104
- end
105
-
106
- # build unique id for extent geometry
107
- $idCount = $idCount.succ
108
- extGeoID = geoType + $idCount
109
-
110
- intMetadataClass = InternalMetadata.new
111
- intExtent = intMetadataClass.newExtent
112
- intGeoEle = intMetadataClass.newGeoElement
113
-
114
- intGeoEle[:elementId] = extGeoID
115
- intGeoEle[:elementGeometry] = hGeoElement[:elementGeometry]
116
-
117
- intExtent[:extDesc] = 'Supplemental information for ' + geoID
118
- intExtent[:extGeoElements] << intGeoEle
119
- intExtent[:extIdElements] = hGeoElement[:elementIdentifiers]
120
- intExtent[:extTempElements] = hGeoElement[:temporalElements]
121
- intExtent[:extVertElements] = hGeoElement[:verticalElements]
122
-
123
- return intExtent
124
-
125
- else
126
- return nil
127
- end
128
-
129
- end
130
-
16
+ require 'adiwg/mdtranslator/writers/iso19115_2/class_MImetadata'
17
+
18
+ module ADIWG
19
+ module Mdtranslator
20
+ module Writers
21
+ module Iso
22
+
23
+ # set writer namespace
24
+ $WriterNS = ADIWG::Mdtranslator::Writers::Iso
25
+
26
+ class Iso19115_2
27
+
28
+ def initialize
29
+ # reset ISO id='' counter
30
+ $idCount = '_000'
31
+ end
32
+
33
+ def writeXML(internalObj)
34
+
35
+
36
+ # set the format of the output file based on the writer specified
37
+ $response[:writerFormat] = 'xml'
38
+ $response[:writerVersion] = ADIWG::Mdtranslator::VERSION
39
+
40
+ # pre-scan the internal object to create a new extents for each geometry
41
+ # ... that has supplemental information (temporal, vertical, identity).
42
+ # ... the new extents will be added to internalObj
43
+ prescanGeoElements(internalObj)
44
+
45
+ # create new XML document
46
+ xml = Builder::XmlMarkup.new(indent: 3)
47
+ metadataWriter = $WriterNS::MI_Metadata.new(xml)
48
+ metadata = metadataWriter.writeXML(internalObj)
49
+
50
+ # set writer pass to true if no messages
51
+ # false or warning will be set by code that places the message
52
+ if $response[:writerMessages].length == 0
53
+ $response[:writerPass] = true
54
+ end
55
+
56
+ return metadata
57
+ end
58
+
59
+ def prescanGeoElements(internalObj)
60
+ # supplemental information for the geographic element is carried in the
61
+ # ... internal structure in the temporalElements:, verticalElements:,
62
+ # ... and elementIdentifiers: attributes of the extGeoElements:
63
+ # ... of the extent.
64
+ # since temporal, vertical, and identify information in ISO is a property
65
+ # ... of EX_Extent and not of the geographicElement,
66
+ # ... this code creates a new extent for each geographicElement
67
+ # ... that has supplemental information and
68
+ # ... moves the supplemental information from the geometry to the new extent.
69
+ # In this implementation, supplemental information is only allowed for
70
+ # ... geometry types of Point, LineString, and Polygon
71
+ aExtents = internalObj[:metadata][:resourceInfo][:extents]
72
+ unless aExtents.empty?
73
+ aExtents.each do |hExtent|
74
+ aGeoElements = hExtent[:extGeoElements]
75
+ unless aGeoElements.empty?
76
+ aGeoElements.each do |hGeoElement|
77
+ hGeometry = hGeoElement[:elementGeometry]
78
+ unless hGeometry.empty?
79
+ geoType = hGeometry[:geoType]
80
+ case geoType
81
+ when 'Point', 'LineString', 'Polygon'
82
+ newExtent = extentFromGeoElement(hGeoElement, geoType)
83
+ if !newExtent.nil?
84
+ aExtents << newExtent
85
+ end
86
+
87
+ when 'MultiGeometry'
88
+ aGeoMembers = hGeometry[:geometry]
89
+ unless aGeoMembers.empty?
90
+ aGeoMembers.each do |hGeoMemberElement|
91
+ hGeometry = hGeoMemberElement[:elementGeometry]
92
+ unless hGeometry.empty?
93
+ geoType = hGeometry[:geoType]
94
+ case geoType
95
+ when 'Point', 'LineString', 'Polygon'
96
+ newExtent = extentFromGeoElement(hGeoMemberElement, geoType)
97
+ if !newExtent.nil?
98
+ aExtents << newExtent
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ def extentFromGeoElement(hGeoElement, geoType)
113
+ # build new extent to portray supplemental information
114
+ # from elementGeometry
115
+ if !hGeoElement[:temporalElements].empty? ||
116
+ !hGeoElement[:verticalElements].empty? ||
117
+ !hGeoElement[:elementIdentifiers].empty?
118
+
119
+ # get unique id for geometry
120
+ # if geometry id was missing, set it at this time so
121
+ # ... it will match the supplemental information extent description
122
+ geoID = hGeoElement[:elementId]
123
+ if geoID.nil?
124
+ $idCount = $idCount.succ
125
+ geoID = geoType + $idCount
126
+ hGeoElement[:elementId] = geoID
127
+ end
128
+
129
+ # build unique id for extent geometry
130
+ $idCount = $idCount.succ
131
+ extGeoID = geoType + $idCount
132
+
133
+ intMetadataClass = InternalMetadata.new
134
+ intExtent = intMetadataClass.newExtent
135
+ intGeoEle = intMetadataClass.newGeoElement
136
+
137
+ intGeoEle[:elementId] = extGeoID
138
+ intGeoEle[:elementGeometry] = hGeoElement[:elementGeometry]
139
+
140
+ intExtent[:extDesc] = 'Supplemental information for ' + geoID
141
+ intExtent[:extGeoElements] << intGeoEle
142
+ intExtent[:extIdElements] = hGeoElement[:elementIdentifiers]
143
+ intExtent[:extTempElements] = hGeoElement[:temporalElements]
144
+ intExtent[:extVertElements] = hGeoElement[:verticalElements]
145
+
146
+ return intExtent
147
+
148
+ else
149
+ return nil
150
+ end
151
+
152
+ end
153
+
154
+ end
155
+
156
+ end
157
+ end
158
+ end
131
159
  end
160
+
161
+
162
+
163
+
@@ -0,0 +1,63 @@
1
+ # MdTranslator - controller for evaluating and directing writers
2
+
3
+ # History:
4
+ # Stan Smith 2014-12-11 original script
5
+ # Stan Smith 2012-12-16 generalized handleWriter to use :writerName
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+
11
+ def self.handleWriter(intObj)
12
+
13
+ # use writer name to load and initiate requested writer
14
+ # build directory path for writer from writerName
15
+ writerDir = File.join(path_to_resources, $response[:writerName])
16
+ if File.directory?(writerDir)
17
+
18
+ # if directory path exists, build writer file name and then require it
19
+ writerFile = File.join(writerDir, $response[:writerName] + '_writer')
20
+ require writerFile
21
+
22
+ # build class name for writer from writerName
23
+ # ... class name must begin with upper case
24
+ # ... (1) writer file name must be writerName_writer.rb
25
+ # ... (2) writer class name must be capitalized writerName
26
+ # ... (3) $WriterNS is the writer namespace constant set in
27
+ # ... writerName_writer.rb and initialized when the file is required
28
+ writerUpCase = $response[:writerName][0].upcase + $response[:writerName][1..-1]
29
+ writerClass = $WriterNS.const_get(writerUpCase).new
30
+
31
+ # pass internal object to requested writer
32
+ $response[:writerOutput] = writerClass.writeXML(intObj)
33
+ return $response
34
+ else
35
+ # directory path was not found
36
+ $response[:writerValidationPass] = false
37
+ $response[:readerValidationMessages] << "Writer name '#{$response[:writerName]}' is not supported."
38
+ return false
39
+ end
40
+
41
+ end
42
+
43
+ # return path to writers
44
+ def self.path_to_resources
45
+ File.dirname(File.expand_path(__FILE__))
46
+ end
47
+
48
+ # return writer readme text
49
+ def self.get_writer_readme(writer)
50
+ readmeText = 'No readme found'
51
+ path = File.join(path_to_resources, writer, 'readme.md')
52
+ if File.exist?(path)
53
+ file = File.open(path, 'r')
54
+ readmeText = file.read
55
+ file.close
56
+ end
57
+ return readmeText
58
+ end
59
+
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,84 @@
1
+ # MdTranslator - minitest of
2
+ # reader / mdJson / module_additionalDocumentation
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-30 original script
6
+
7
+ #set globals used in testing
8
+ #set globals used by mdJson_reader.rb before requiring module
9
+ $response = {
10
+ readerVersionUsed: '0.9'
11
+ }
12
+
13
+ require 'minitest/autorun'
14
+ require 'json'
15
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
16
+ require 'adiwg/mdtranslator/readers/mdJson/mdJson_reader'
17
+ require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_additionalDocumentation'
18
+
19
+ class TestReaderMdJsonAdditionalDocumentation_v0_9 < MiniTest::Test
20
+
21
+ # get json test example
22
+ file = File.open('test/schemas/v0_9/examples/additionalDocumentation.json', 'r')
23
+ jsonFile = file.read
24
+ file.close
25
+ aIn = JSON.parse(jsonFile)
26
+ @@hIn = aIn[0]
27
+
28
+ # set namespace
29
+ @@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::AdditionalDocumentation
30
+
31
+ def test_complete_additionalDocumentation_object
32
+
33
+ hIn = @@hIn.clone
34
+ hIn.delete('citation')
35
+
36
+ intObj = {
37
+ resourceType: 'resourceType',
38
+ citation: {}
39
+ }
40
+
41
+ assert_equal intObj, @@NameSpace.unpack(hIn)
42
+
43
+ end
44
+
45
+ def test_empty_additionalDocumentation_elements
46
+
47
+ hIn = @@hIn.clone
48
+ hIn['resourceType'] = ''
49
+ hIn['citation'] = {}
50
+
51
+ intObj = {
52
+ resourceType: nil,
53
+ citation: {}
54
+ }
55
+
56
+ assert_equal intObj, @@NameSpace.unpack(hIn)
57
+
58
+ end
59
+
60
+ def test_missing_additionalDocumentation_citation
61
+
62
+ # note: except for resourceType
63
+
64
+ hIn = @@hIn.clone
65
+ hIn.delete('citation')
66
+
67
+ intObj = {
68
+ resourceType: 'resourceType',
69
+ citation: {}
70
+ }
71
+
72
+ assert_equal intObj, @@NameSpace.unpack(hIn)
73
+
74
+ end
75
+
76
+ def test_empty_additionalDocumentation_object
77
+
78
+ hIn = JSON.parse('{}')
79
+
80
+ assert_equal nil, @@NameSpace.unpack(hIn)
81
+
82
+ end
83
+
84
+ end
@@ -0,0 +1,100 @@
1
+ # MdTranslator - minitest of
2
+ # reader / mdJson / module_address
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-09 original script
6
+ # Stan Smith 2014-12-15 modified to use namespaces added to mdTranslator
7
+ # Stan Smith 2014-12-16 restructure tests to use schema examples
8
+ # Stan Smith 2014-12-19 added test for blank elements
9
+
10
+ require 'minitest/autorun'
11
+ require 'json'
12
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
13
+ require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_address'
14
+
15
+ class TestReaderMdJsonAddress_v0_9 < MiniTest::Test
16
+
17
+ # get json test example
18
+ file = File.open('test/schemas/v0_9/examples/address.json', 'r')
19
+ jsonFile = file.read
20
+ file.close
21
+ aIn = JSON.parse(jsonFile)
22
+ @@hIn = aIn[0]
23
+
24
+ # set namespace
25
+ @@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::Address
26
+
27
+ def test_complete_address_object
28
+
29
+ hIn = @@hIn.clone
30
+
31
+ intObj = {
32
+ deliveryPoints: %w[deliveryPoint1 deliveryPoint2],
33
+ city: 'city',
34
+ adminArea: 'administrativeArea',
35
+ postalCode: 'postalCode',
36
+ country: 'country',
37
+ eMailList: %w[example1@example.com example2@example.com]
38
+ }
39
+
40
+ assert_equal intObj, @@NameSpace.unpack(hIn)
41
+
42
+ end
43
+
44
+ def test_email_address_only
45
+
46
+ # note: this test also serves to test missing elements
47
+ # ... except for missing electronicMailAddress
48
+
49
+ hIn = @@hIn.clone
50
+ hIn.delete('deliveryPoint')
51
+ hIn.delete('city')
52
+ hIn.delete('administrativeArea')
53
+ hIn.delete('postalCode')
54
+ hIn.delete('country')
55
+
56
+ intObj = {
57
+ deliveryPoints: [],
58
+ city: nil,
59
+ adminArea: nil,
60
+ postalCode: nil,
61
+ country: nil,
62
+ eMailList: %w[example1@example.com example2@example.com]
63
+ }
64
+
65
+ assert_equal intObj,@@NameSpace.unpack(hIn)
66
+
67
+ end
68
+
69
+ def test_empty_address_elements
70
+
71
+ hIn = @@hIn.clone
72
+ hIn['deliveryPoint'] = ['']
73
+ hIn['city'] = ''
74
+ hIn['administrativeArea'] = ''
75
+ hIn['postalCode'] = ''
76
+ hIn['country'] = ''
77
+ hIn['electronicMailAddress'] = ['']
78
+
79
+ intObj = {
80
+ deliveryPoints: [],
81
+ city: nil,
82
+ adminArea: nil,
83
+ postalCode: nil,
84
+ country: nil,
85
+ eMailList: []
86
+ }
87
+
88
+ assert_equal intObj,@@NameSpace.unpack(hIn)
89
+
90
+ end
91
+
92
+ def test_empty_address_object
93
+
94
+ hIn = JSON.parse('{}')
95
+
96
+ assert_equal nil, @@NameSpace.unpack(hIn)
97
+
98
+ end
99
+
100
+ end