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
@@ -9,90 +9,90 @@ require 'date'
9
9
 
10
10
  module AdiwgDateTimeFun
11
11
 
12
- def self.dateTimeFromString(inDateTime)
13
- hFormats = {'YMDhmsLZ'=> '%Y-%m-%dT%H:%M:%S.%L%z',
14
- 'YMDhmsL'=> '%Y-%m-%dT%H:%M:%S.%L',
15
- 'YMDhmsZ'=> '%Y-%m-%dT%H:%M:%S%z',
16
- 'YMDhms'=> '%Y-%m-%dT%H:%M:%S',
17
- 'YMDhmZ'=> '%Y-%m-%dT%H:%M%z',
18
- 'YMDhm'=> '%Y-%m-%dT%H:%M',
19
- 'YMDhZ'=> '%Y-%m-%dT%H%z',
20
- 'YMDh'=> '%Y-%m-%dT%H',
21
- 'YMD'=> '%Y-%m-%d',
22
- 'YM'=> '%Y-%m',
23
- 'Y'=> '%Y'}
24
- hFormats.each do |dateResolution, format|
25
- myDateTime = DateTime.strptime(inDateTime,format) rescue false
26
- return myDateTime, dateResolution if myDateTime
27
- end
12
+ def self.dateTimeFromString(inDateTime)
13
+ hFormats = {'YMDhmsLZ' => '%Y-%m-%dT%H:%M:%S.%L%z',
14
+ 'YMDhmsL' => '%Y-%m-%dT%H:%M:%S.%L',
15
+ 'YMDhmsZ' => '%Y-%m-%dT%H:%M:%S%z',
16
+ 'YMDhms' => '%Y-%m-%dT%H:%M:%S',
17
+ 'YMDhmZ' => '%Y-%m-%dT%H:%M%z',
18
+ 'YMDhm' => '%Y-%m-%dT%H:%M',
19
+ 'YMDhZ' => '%Y-%m-%dT%H%z',
20
+ 'YMDh' => '%Y-%m-%dT%H',
21
+ 'YMD' => '%Y-%m-%d',
22
+ 'YM' => '%Y-%m',
23
+ 'Y' => '%Y'}
24
+ hFormats.each do |dateResolution, format|
25
+ myDateTime = DateTime.strptime(inDateTime, format) rescue false
26
+ return myDateTime, dateResolution if myDateTime
27
+ end
28
28
 
29
- return nil, 'ERROR'
30
- end
29
+ return nil, 'ERROR'
30
+ end
31
31
 
32
- def self.stringDateFromDateTime(myDateTime,dateResolution)
33
- s = case dateResolution
34
- when 'YMDhmsLZ','YMDhmsL','YMDhmsZ', 'YMDhms',
35
- 'YMDhmZ', 'YMDhm', 'YMDhZ', 'YMDh','YMD'
36
- myDateTime.strftime('%Y-%m-%d')
37
- when 'YM'
38
- myDateTime.strftime('%Y-%m')
39
- when 'Y'
40
- myDateTime.strftime('%Y')
41
- else
42
- 'ERROR'
43
- end
32
+ def self.stringDateFromDateTime(myDateTime, dateResolution)
33
+ s = case dateResolution
34
+ when 'YMDhmsLZ', 'YMDhmsL', 'YMDhmsZ', 'YMDhms',
35
+ 'YMDhmZ', 'YMDhm', 'YMDhZ', 'YMDh', 'YMD'
36
+ myDateTime.strftime('%Y-%m-%d')
37
+ when 'YM'
38
+ myDateTime.strftime('%Y-%m')
39
+ when 'Y'
40
+ myDateTime.strftime('%Y')
41
+ else
42
+ 'ERROR'
43
+ end
44
44
 
45
- return s
46
- end
45
+ return s
46
+ end
47
47
 
48
- def self.stringDateTimeFromDateTime(myDateTime,dateResolution)
49
- s = case dateResolution
50
- when 'YMDhmsLZ'
51
- myDateTime.strftime('%Y-%m-%dT%H:%M:%S.%L%:z')
52
- when 'YMDhmsL'
53
- myDateTime.strftime('%Y-%m-%dT%H:%M:%S.%L')
54
- when 'YMDhmsZ'
55
- myDateTime.strftime('%Y-%m-%dT%H:%M:%S%:z')
56
- when 'YMDhms', 'YMD', 'YM', 'Y'
57
- myDateTime.strftime('%Y-%m-%dT%H:%M:%S')
58
- when 'YMDhmZ'
59
- myDateTime.strftime('%Y-%m-%dT%H:%M%:z')
60
- when 'YMDhm'
61
- myDateTime.strftime('%Y-%m-%dT%H:%M')
62
- when 'YMDhZ'
63
- myDateTime.strftime('%Y-%m-%dT%H%:z')
64
- when 'YMDh'
65
- myDateTime.strftime('%Y-%m-%dT%H')
66
- else
67
- 'ERROR'
68
- end
48
+ def self.stringDateTimeFromDateTime(myDateTime, dateResolution)
49
+ s = case dateResolution
50
+ when 'YMDhmsLZ'
51
+ myDateTime.strftime('%Y-%m-%dT%H:%M:%S.%L%:z')
52
+ when 'YMDhmsL'
53
+ myDateTime.strftime('%Y-%m-%dT%H:%M:%S.%L')
54
+ when 'YMDhmsZ'
55
+ myDateTime.strftime('%Y-%m-%dT%H:%M:%S%:z')
56
+ when 'YMDhms', 'YMD', 'YM', 'Y'
57
+ myDateTime.strftime('%Y-%m-%dT%H:%M:%S')
58
+ when 'YMDhmZ'
59
+ myDateTime.strftime('%Y-%m-%dT%H:%M%:z')
60
+ when 'YMDhm'
61
+ myDateTime.strftime('%Y-%m-%dT%H:%M')
62
+ when 'YMDhZ'
63
+ myDateTime.strftime('%Y-%m-%dT%H%:z')
64
+ when 'YMDh'
65
+ myDateTime.strftime('%Y-%m-%dT%H')
66
+ else
67
+ 'ERROR'
68
+ end
69
69
 
70
- return s
71
- end
70
+ return s
71
+ end
72
72
 
73
- def self.stringTimeFromDateTime(myDateTime,dateResolution)
74
- s = case dateResolution
75
- when 'YMDhmsLZ'
76
- myDateTime.strftime('%H:%M:%S.%L%:z')
77
- when 'YMDhmsL'
78
- myDateTime.strftime('%H:%M:%S.%L')
79
- when 'YMDhmsZ'
80
- myDateTime.strftime('%H:%M:%S%:z')
81
- when 'YMDhms'
82
- myDateTime.strftime('%H:%M:%S')
83
- when 'YMDhmZ'
84
- myDateTime.strftime('%H:%M%:z')
85
- when 'YMDhm'
86
- myDateTime.strftime('%H:%M')
87
- when 'YMDhZ'
88
- myDateTime.strftime('%H%:z')
89
- when 'YMDh'
90
- myDateTime.strftime('%H')
91
- else
92
- 'ERROR'
93
- end
73
+ def self.stringTimeFromDateTime(myDateTime, dateResolution)
74
+ s = case dateResolution
75
+ when 'YMDhmsLZ'
76
+ myDateTime.strftime('%H:%M:%S.%L%:z')
77
+ when 'YMDhmsL'
78
+ myDateTime.strftime('%H:%M:%S.%L')
79
+ when 'YMDhmsZ'
80
+ myDateTime.strftime('%H:%M:%S%:z')
81
+ when 'YMDhms'
82
+ myDateTime.strftime('%H:%M:%S')
83
+ when 'YMDhmZ'
84
+ myDateTime.strftime('%H:%M%:z')
85
+ when 'YMDhm'
86
+ myDateTime.strftime('%H:%M')
87
+ when 'YMDhZ'
88
+ myDateTime.strftime('%H%:z')
89
+ when 'YMDh'
90
+ myDateTime.strftime('%H')
91
+ else
92
+ 'ERROR'
93
+ end
94
94
 
95
- return s
96
- end
95
+ return s
96
+ end
97
97
 
98
98
  end
@@ -11,79 +11,158 @@
11
11
  # Stan Smith 2014-08-18 add json name/version to internal object
12
12
  # Stan Smith 2014-12-01 add data dictionary
13
13
  # Stan Smith 2014-12-03 changed class name to MdJsonReader from AdiwgJsonReader
14
+ # Stan Smith 2014-12-11 refactored to handle namespacing readers and writers
14
15
 
15
16
  require 'json'
16
- require ADIWG::Mdtranslator.reader_module('module_contacts', $response[:readerVersionUsed])
17
- require ADIWG::Mdtranslator.reader_module('module_metadata', $response[:readerVersionUsed])
18
- require ADIWG::Mdtranslator.reader_module('module_dataDictionary', $response[:readerVersionUsed])
19
-
20
- class MdJsonReader
21
-
22
- def initialize
23
- end
24
-
25
- def unpack(jsonObj)
26
-
27
- # instance classes needed in script
28
- intMetadataClass = InternalMetadata.new
29
-
30
- # create new internal metadata container for the reader
31
- intBase = intMetadataClass.newBase
32
-
33
- # convert the received JSON to a Ruby hash
34
- hashObj = JSON.parse(jsonObj)
35
-
36
- # get json schema name and version
37
- if hashObj.has_key?('version')
38
- hVersion = hashObj['version']
39
- unless hVersion.empty?
40
- if hVersion.has_key?('name')
41
- s = hVersion['name']
42
- if !s.nil?
43
- intBase[:jsonVersion][:name] = s
44
- end
45
- end
46
- if hVersion.has_key?('version')
47
- s = hVersion['version']
48
- if !s.nil?
49
- intBase[:jsonVersion][:version] = s
50
- end
51
- end
52
- end
53
- end
54
-
55
- # contact
56
- # load the array of contacts from the json object
57
- # ... the contacts array uses a local id to reference the
58
- # ... contact in the array from elsewhere in the json metadata
59
- if hashObj.has_key?('contact')
60
- aContacts = hashObj['contact']
61
- aContacts.each do |hContact|
62
- unless hContact.empty?
63
- intBase[:contacts] << Md_Contact.unpack(hContact)
64
- end
65
- end
66
- end
67
-
68
- # add default contacts
69
- intBase[:contacts].concat(Md_Contact.setDefaultContacts)
70
-
71
- # metadata
72
- # load metadata from the hash object
73
- if hashObj.has_key?('metadata')
74
- hMetadata = hashObj['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)
82
- end
83
-
84
- # return ADIwg internal container
85
- return intBase
86
-
87
- end
88
-
89
- end
17
+
18
+ module ADIWG
19
+ module Mdtranslator
20
+ module Readers
21
+ module MdJson
22
+
23
+ # set reader namespace
24
+ $ReaderNS = ADIWG::Mdtranslator::Readers::MdJson
25
+
26
+ def self.readFile(file)
27
+ # set anticipated format of file in $response
28
+ $response[:readerFormat] = 'json'
29
+
30
+ # receive json file into ruby hash
31
+ parseJson(file)
32
+ if !$response[:readerStructurePass]
33
+ return false
34
+ end
35
+
36
+ # check mdJson version name
37
+ checkVersionName
38
+ if !$response[:readerStructurePass]
39
+ return false
40
+ end
41
+
42
+ # check mdJson version number
43
+ checkVersionNumber
44
+ if !$response[:readerStructurePass]
45
+ return false
46
+ end
47
+
48
+ # validate file against mdJson schema definition
49
+ require 'adiwg/mdtranslator/readers/mdJson/mdJson_validator'
50
+ $ReaderNS.validate(file)
51
+ if !$response[:readerValidationPass]
52
+ return false
53
+ end
54
+
55
+ # unpack mdJson file
56
+ require readerModule('module_mdJson')
57
+ intObj = $ReaderNS.unpack(@hMdJson)
58
+ return intObj
59
+
60
+ end
61
+
62
+ def self.parseJson(file)
63
+ # validate the input file structure
64
+ # test for valid json syntax by attempting to parse the file
65
+ begin
66
+ @hMdJson = JSON.parse(file)
67
+ $response[:readerStructurePass] = true
68
+ rescue JSON::JSONError => err
69
+ $response[:readerStructurePass] = false
70
+ $response[:readerStructureMessages] << err
71
+ return
72
+ end
73
+ end
74
+
75
+ def self.checkVersionName
76
+ # find version name on the input json file
77
+ if @hMdJson.has_key?('version')
78
+ hVersion = @hMdJson['version']
79
+ else
80
+ $response[:readerStructurePass] = false
81
+ $response[:readerStructureMessages] << 'The input file is missing the version:{} block.'
82
+ return
83
+ end
84
+
85
+ # check the version name
86
+ if hVersion.has_key?('name')
87
+ s = hVersion['name']
88
+ if !s.nil?
89
+ $response[:readerFound] = s
90
+ else
91
+ $response[:readerStructurePass] = false
92
+ $response[:readerStructureMessages] << 'The input file version name is missing.'
93
+ return
94
+ end
95
+ else
96
+ $response[:readerStructurePass] = false
97
+ $response[:readerStructureMessages] << "The input file version:{} block is missing the 'name' attribute."
98
+ return
99
+ end
100
+
101
+ # check the version name is 'mdJson'
102
+ if s != 'mdJson'
103
+ $response[:readerStructurePass] = false
104
+ $response[:readerStructureMessages] << "The mdTranslator reader expected the input file version name to be 'mdJson'."
105
+ $response[:readerStructureMessages] << "Version name found was: '#{s}'."
106
+ return
107
+ end
108
+ end
109
+
110
+ def self.checkVersionNumber
111
+ # find version number on the input json file
112
+ hVersion = @hMdJson['version']
113
+ if hVersion.has_key?('version')
114
+ s = hVersion['version']
115
+ if !s.nil?
116
+ $response[:readerVersionFound] = s
117
+ end
118
+ else
119
+ $response[:readerStructurePass] = false
120
+ $response[:readerStructureMessages] << "The input file version:{} block is missing the 'version' number attribute."
121
+ return
122
+ end
123
+
124
+ # test the reader version requested is supported
125
+ # remove maintenance release number first
126
+ # ... then look for a module folder name ending with the requested version
127
+ # ... example: 'modules_1.2'
128
+ aVersionParts = s.split('.')
129
+ if aVersionParts.length >= 2
130
+ readerVersion = aVersionParts[0] +'.' + aVersionParts[1]
131
+ dir = File.join(File.dirname(__FILE__), 'modules_' + readerVersion)
132
+ if !File.directory?(dir)
133
+ $response[:readerStructurePass] = false
134
+ $response[:readerStructureMessages] << 'The input file version is not supported.'
135
+ $response[:readerStructureMessages] << "mdJson version requested was '#{s}'"
136
+ return
137
+ end
138
+ $response[:readerVersionUsed] = readerVersion
139
+ else
140
+ $response[:readerStructurePass] = false
141
+ $response[:readerStructureMessages] << 'The input file version number must be in the form MAJOR.MINOR.PATCH, e.g. 1.2.3'
142
+ $response[:readerStructureMessages] << 'Note the PATCH number is optional.'
143
+ return
144
+ end
145
+ end
146
+
147
+ # require modules for the requested version
148
+ def self.readerModule(moduleName)
149
+ dir = File.join(File.dirname(__FILE__), 'modules_' + $response[:readerVersionUsed])
150
+ file = File.join(dir, moduleName)
151
+
152
+ # test for the existance of the module in the current mdJson version directory
153
+ if !File.exist?(File.join(dir, moduleName + '.rb'))
154
+ # file not found
155
+ # ... look for module in previous version directory
156
+ # ... note: no previous version directories exist yet
157
+
158
+ # no prior version directory found
159
+ # ... file not found
160
+ return nil
161
+ end
162
+ return file
163
+ end
164
+
165
+ end
166
+ end
167
+ end
168
+ end
@@ -7,117 +7,50 @@
7
7
  # Stan Smith 2014-09-26 added processing of minor release numbers
8
8
  # Stan Smith 2014-12-01 changed adiwgJson to mdJson in version name check
9
9
  # Stan Smith 2014-12-03 changed class name to MdJsonValidation from AdiwgJsonValidation
10
+ # Stan Smith 2014-12-11 added namespace
10
11
 
11
12
  require 'json'
12
13
  require 'json-schema'
13
14
  require 'adiwg-json_schemas'
14
- #json-schema patch
15
- require 'validator.rb'
15
+ # temporary json-schema patch
16
+ # waiting for rubygem json-schema patch
17
+ require 'adiwg/mdtranslator/readers/mdJson/validator.rb'
18
+
19
+ module ADIWG
20
+ module Mdtranslator
21
+ module Readers
22
+ module MdJson
23
+
24
+ # validate json against the adiwg-json_schemas
25
+ # only one schema version is supported at this time
26
+ def self.validate(file)
27
+ begin
28
+
29
+ schema = ADIWG::JsonSchemas::Utils.schema_path
30
+ aValErrs = Array.new
31
+ if $response[:readerValidationLevel] == 'strict'
32
+ aValErrs = JSON::Validator.fully_validate(schema, file, :strict => true, :errors_as_objects => true)
33
+ elsif $response[:readerValidationLevel] == 'normal'
34
+ aValErrs = JSON::Validator.fully_validate(schema, file, :errors_as_objects => true)
35
+ end
36
+
37
+ if aValErrs.length > 0
38
+ $response[:readerValidationPass] = false
39
+ $response[:readerValidationMessages] = aValErrs
40
+ return
41
+ end
42
+ rescue JSON::Schema::ValidationError
43
+ $response[:readerValidationPass] = false
44
+ $response[:readerValidationMessages] << $!.message
45
+ return
46
+ end
47
+
48
+ $response[:readerValidationPass] = true
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
16
55
 
17
- module MdJsonValidation
18
56
 
19
- def self.validate(file)
20
-
21
- # set the anticipated format of the input file based on the reader specified
22
- $response[:readerFormat] = 'json'
23
-
24
- # validate the input file structure
25
- # test for valid json syntax by attempting to parse the file
26
- begin
27
- hashObj = JSON.parse(file)
28
- $response[:readerStructurePass] = true
29
- rescue JSON::JSONError => err
30
- $response[:readerStructurePass] = false
31
- $response[:readerStructureMessages] << err
32
- return
33
- end
34
-
35
- # find name and version of input json file
36
- if hashObj.has_key?('version')
37
- hVersion = hashObj['version']
38
- else
39
- $response[:readerStructurePass] = false
40
- $response[:readerStructureMessages] << 'input file is missing the version:{} block'
41
- return
42
- end
43
-
44
- # get the version name
45
- if hVersion.has_key?('name')
46
- s = hVersion['name']
47
- if !s.nil?
48
- $response[:readerFound] = s
49
- if s != 'mdJson'
50
- $response[:readerStructurePass] = false
51
- $response[:readerStructureMessages] << "input file version name must be 'mdJson'"
52
- $response[:readerStructureMessages] << "found version name '#{s}'"
53
- return
54
- end
55
- end
56
- else
57
- $response[:readerStructurePass] = false
58
- $response[:readerStructureMessages] << "input file version:{} block is missing the 'name' attribute"
59
- return
60
- end
61
-
62
- # get version number
63
- if hVersion.has_key?('version')
64
- requestReaderVersion = hVersion['version']
65
- $response[:readerVersionFound] = requestReaderVersion
66
- # test if reader version is supported
67
- # remove minor release number
68
- # ...and look for a module folder name ending with the requested version
69
- # ...example: 'modules_1.2.0'
70
- if !requestReaderVersion.nil?
71
- aVersionParts = requestReaderVersion.split('.')
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
83
- $response[:readerStructurePass] = false
84
- $response[:readerStructureMessages] << "input file version must be in the form MAJOR.MINOR.PATCH, e.g. 1.2.3"
85
- return
86
- end
87
- end
88
- else
89
- $response[:readerStructurePass] = false
90
- $response[:readerStructureMessages] << "input file version:{} block is missing the 'version' attribute"
91
- return
92
- end
93
-
94
- # validate json against the adiwg-json_schemas
95
- # only one schema version is supported at this time
96
- begin
97
-
98
- schema = ADIWG::JsonSchemas::Utils.schema_path
99
- aValErrs = Array.new
100
- if $response[:readerValidationLevel] == 'strict'
101
- aValErrs = JSON::Validator.fully_validate(schema, file, :strict => true, :errors_as_objects => true)
102
- elsif $response[:readerValidationLevel] == 'normal'
103
- aValErrs = JSON::Validator.fully_validate(schema, file, :errors_as_objects => true)
104
- end
105
-
106
- if aValErrs.length > 0
107
- $response[:readerValidationPass] = false
108
- $response[:readerValidationMessages] = aValErrs
109
- return
110
- end
111
-
112
- rescue JSON::Schema::ValidationError
113
- $response[:readerValidationPass] = false
114
- $response[:readerValidationMessages] << $!.message
115
- return
116
- end
117
-
118
- $response[:readerValidationPass] = true
119
- return
120
-
121
- end
122
-
123
- end