adiwg-mdtranslator 2.9.2 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -2
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +8 -8
- data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +179 -160
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_albers.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_azimuthEquidistant.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_equidistantConic.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_equirectangular.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_generalVertical.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_gnomonic.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_lambertConic.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_lambertEqualArea.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_mercator.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_millerCylinder.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_modifiedAlaska.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_obliqueMercator.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_orthographic.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_polarStereo.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_polyconic.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_robinson.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_sinusoidal.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_spaceOblique.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_stereographic.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_transverseMercator.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_vanDerGrinten.rb +1 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +16 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_citation.rb +14 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_codeSet.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +36 -8
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_date.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_digitalForm.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +12 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +5 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +4 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +12 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geodeticReference.rb +13 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geographicResolution.rb +13 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geologicAge.rb +6 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_horizontalReference.rb +3 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +58 -12
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +36 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_lineage.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_localSystem.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapCoordinateInfo.rb +51 -12
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapGridSystem.rb +46 -9
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapLocalPlanar.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapProjection.rb +4 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +10 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_methodology.rb +4 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_offlineOption.rb +16 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_onlineOption.rb +13 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_orderProcess.rb +9 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_pointVector.rb +21 -4
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_process.rb +8 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_publication.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +14 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_range.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_raster.rb +12 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_security.rb +12 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_series.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_source.rb +20 -5
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +32 -8
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb +20 -5
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb +8 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +4 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_verticalAltitude.rb +12 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_verticalDepth.rb +9 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/version.rb +2 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +10 -10
- data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb +13 -16
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_additionalDocumentation.rb +55 -55
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_address.rb +85 -85
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_allocation.rb +8 -8
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_associatedResource.rb +91 -92
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_attribute.rb +212 -212
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_attributeGroup.rb +43 -43
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_bearingDistanceResolution.rb +8 -8
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_boundingBox.rb +11 -11
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_citation.rb +17 -17
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_constraint.rb +26 -13
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb +13 -12
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coordinateResolution.rb +8 -5
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coverageDescription.rb +77 -77
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb +9 -7
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_date.rb +54 -54
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dateTime.rb +35 -35
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dimension.rb +70 -70
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_distribution.rb +15 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_distributor.rb +53 -53
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domain.rb +5 -5
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domainItem.rb +5 -5
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_duration.rb +92 -91
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entity.rb +10 -10
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb +28 -18
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityForeignKey.rb +58 -59
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityIndex.rb +52 -53
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_extent.rb +70 -56
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_featureCollection.rb +64 -63
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_format.rb +6 -6
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_funding.rb +9 -6
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geoJson.rb +47 -47
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geodetic.rb +7 -7
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicExtent.rb +12 -7
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicResolution.rb +6 -5
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geologicAge.rb +6 -6
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryCollection.rb +63 -63
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryFeature.rb +84 -84
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryObject.rb +50 -49
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryProperties.rb +57 -57
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georectifiedRepresentation.rb +115 -100
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georeferenceableRepresentation.rb +85 -82
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gmlIdentifier.rb +46 -46
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_graphic.rb +78 -78
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gridRepresentation.rb +61 -56
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_identifier.rb +72 -72
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_imageDescription.rb +106 -107
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_keyword.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_keywordObject.rb +46 -46
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_legalConstraint.rb +55 -51
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_lineage.rb +87 -83
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_locale.rb +46 -46
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_maintenance.rb +73 -74
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_mdJson.rb +11 -5
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_measure.rb +56 -55
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_medium.rb +88 -88
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadata.rb +106 -105
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataInfo.rb +4 -3
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataRepository.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_obliqueLinePoint.rb +7 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_onlineResource.rb +60 -61
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_orderProcess.rb +47 -47
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_party.rb +57 -57
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_phone.rb +49 -51
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +6 -6
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_projectionParameters.rb +31 -30
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_referenceSystemParameters.rb +16 -2
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_releasability.rb +53 -47
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +15 -13
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceType.rb +46 -46
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceUsage.rb +95 -95
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_responsibleParty.rb +67 -67
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_schema.rb +47 -46
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_scope.rb +47 -47
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_scopeDescription.rb +68 -63
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_securityConstraint.rb +50 -50
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_series.rb +38 -38
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb +8 -8
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialReference.rb +6 -5
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialRepresentation.rb +77 -75
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb +8 -14
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicClassification.rb +71 -72
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicSystem.rb +46 -45
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomy.rb +118 -116
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_temporalExtent.rb +48 -46
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timeInstant.rb +8 -8
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timeInterval.rb +50 -50
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timePeriod.rb +21 -14
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_transferOption.rb +86 -75
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_valueRange.rb +4 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorObject.rb +45 -45
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorRepresentation.rb +45 -33
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_verticalDatum.rb +28 -6
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_verticalExtent.rb +59 -59
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_voucher.rb +43 -43
- data/lib/adiwg/mdtranslator/readers/mdReaders.rb +6 -2
- data/lib/adiwg/mdtranslator/version.rb +9 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_entityAttribute.rb +3 -3
- data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureConstraint.rb +50 -46
- data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_multiplicity.rb +53 -43
- data/lib/adiwg/mdtranslator/writers/iso19110/version.rb +3 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entityAttribute.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/mdWriters.rb +58 -58
- data/lib/adiwg/mdtranslator.rb +177 -165
- data/lib/adiwg/mdtranslator_cli.rb +8 -3
- metadata +2 -2
@@ -2,100 +2,100 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
5
|
+
# Stan Smith 2018-02-18 refactored error and warning messaging
|
6
|
+
# Stan Smith 2016-10-03 refactored for mdJson 2.0
|
7
|
+
# Stan Smith 2015-07-14 refactored to remove global namespace constants
|
8
|
+
# Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
|
9
|
+
# Stan Smith 2014-12-30 refactored
|
10
|
+
# ... electronicMailAddresses into internal object
|
11
|
+
# Stan Smith 2014-12-19 prevented passing blank deliveryPoints and
|
12
|
+
# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
|
13
|
+
# Stan Smith 2013-10-21 original script
|
13
14
|
|
14
15
|
module ADIWG
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
module Mdtranslator
|
17
|
+
module Readers
|
18
|
+
module MdJson
|
18
19
|
|
19
|
-
|
20
|
+
module Address
|
20
21
|
|
21
|
-
|
22
|
+
def self.unpack(hAddress, responseObj)
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
# instance classes needed in script
|
31
|
-
intMetadataClass = InternalMetadata.new
|
32
|
-
intAdd = intMetadataClass.newAddress
|
33
|
-
|
34
|
-
# address - address type [adiwg_addressType] (required)
|
35
|
-
if hAddress.has_key?('addressType')
|
36
|
-
hAddress['addressType'].each do |item|
|
37
|
-
if item != ''
|
38
|
-
intAdd[:addressTypes] << item
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
if intAdd[:addressTypes].empty?
|
43
|
-
responseObj[:readerExecutionMessages] << 'Address Type is missing'
|
44
|
-
responseObj[:readerExecutionPass] = false
|
45
|
-
return nil
|
46
|
-
end
|
47
|
-
|
48
|
-
# address - description
|
49
|
-
if hAddress.has_key?('description')
|
50
|
-
if hAddress['description'] != ''
|
51
|
-
intAdd[:description] = hAddress['description']
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# address - delivery point
|
56
|
-
if hAddress.has_key?('deliveryPoint')
|
57
|
-
hAddress['deliveryPoint'].each do |item|
|
58
|
-
if item != ''
|
59
|
-
intAdd[:deliveryPoints] << item
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
24
|
+
# return nil object if input is empty
|
25
|
+
if hAddress.empty?
|
26
|
+
responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: address object is empty'
|
27
|
+
return nil
|
28
|
+
end
|
63
29
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
intAdd[:city] = hAddress['city']
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# address - admin area
|
72
|
-
if hAddress.has_key?('administrativeArea')
|
73
|
-
if hAddress['administrativeArea'] != ''
|
74
|
-
intAdd[:adminArea] = hAddress['administrativeArea']
|
75
|
-
end
|
76
|
-
end
|
30
|
+
# instance classes needed in script
|
31
|
+
intMetadataClass = InternalMetadata.new
|
32
|
+
intAdd = intMetadataClass.newAddress
|
77
33
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
34
|
+
# address - address type [adiwg_addressType] (required)
|
35
|
+
if hAddress.has_key?('addressType')
|
36
|
+
hAddress['addressType'].each do |item|
|
37
|
+
unless item == ''
|
38
|
+
intAdd[:addressTypes] << item
|
83
39
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
40
|
+
end
|
41
|
+
end
|
42
|
+
if intAdd[:addressTypes].empty?
|
43
|
+
responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: address type is missing'
|
44
|
+
responseObj[:readerExecutionPass] = false
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
|
48
|
+
# address - description
|
49
|
+
if hAddress.has_key?('description')
|
50
|
+
unless hAddress['description'] == ''
|
51
|
+
intAdd[:description] = hAddress['description']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# address - delivery point
|
56
|
+
if hAddress.has_key?('deliveryPoint')
|
57
|
+
hAddress['deliveryPoint'].each do |item|
|
58
|
+
unless item == ''
|
59
|
+
intAdd[:deliveryPoints] << item
|
90
60
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# address - city
|
65
|
+
if hAddress.has_key?('city')
|
66
|
+
unless hAddress['city'] == ''
|
67
|
+
intAdd[:city] = hAddress['city']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# address - admin area
|
72
|
+
if hAddress.has_key?('administrativeArea')
|
73
|
+
unless hAddress['administrativeArea'] == ''
|
74
|
+
intAdd[:adminArea] = hAddress['administrativeArea']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# address - postal code
|
79
|
+
if hAddress.has_key?('postalCode')
|
80
|
+
unless hAddress['postalCode'] == ''
|
81
|
+
intAdd[:postalCode] = hAddress['postalCode']
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# address - country
|
86
|
+
if hAddress.has_key?('country')
|
87
|
+
unless hAddress['country'] == ''
|
88
|
+
intAdd[:country] = hAddress['country']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
return intAdd
|
93
|
+
|
94
|
+
end
|
97
95
|
|
98
96
|
end
|
99
|
-
|
100
|
-
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
101
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2018-02-18 refactored error and warning messaging
|
5
6
|
# Stan Smith 2017-08-30 refactored for mdJson schema 2.3
|
6
7
|
# Stan Smith 2016-10-30 original script
|
7
8
|
|
@@ -18,8 +19,7 @@ module ADIWG
|
|
18
19
|
|
19
20
|
# return nil object if input is empty
|
20
21
|
if hAlloc.empty?
|
21
|
-
responseObj[:readerExecutionMessages] << '
|
22
|
-
responseObj[:readerExecutionPass] = false
|
22
|
+
responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: budget allocation object is empty'
|
23
23
|
return nil
|
24
24
|
end
|
25
25
|
|
@@ -29,7 +29,7 @@ module ADIWG
|
|
29
29
|
|
30
30
|
# allocation - id
|
31
31
|
if hAlloc.has_key?('sourceAllocationId')
|
32
|
-
|
32
|
+
unless hAlloc['sourceAllocationId'] == ''
|
33
33
|
intAlloc[:id] = hAlloc['sourceAllocationId']
|
34
34
|
end
|
35
35
|
end
|
@@ -39,7 +39,7 @@ module ADIWG
|
|
39
39
|
intAlloc[:amount] = hAlloc['amount']
|
40
40
|
end
|
41
41
|
if intAlloc[:amount].nil? || intAlloc[:amount] == ''
|
42
|
-
responseObj[:readerExecutionMessages] << '
|
42
|
+
responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: budget allocation amount is missing'
|
43
43
|
responseObj[:readerExecutionPass] = false
|
44
44
|
return nil
|
45
45
|
end
|
@@ -49,21 +49,21 @@ module ADIWG
|
|
49
49
|
intAlloc[:currency] = hAlloc['currency']
|
50
50
|
end
|
51
51
|
if intAlloc[:currency].nil? || intAlloc[:currency] == ''
|
52
|
-
responseObj[:readerExecutionMessages] << '
|
52
|
+
responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: budget allocation currency is missing'
|
53
53
|
responseObj[:readerExecutionPass] = false
|
54
54
|
return nil
|
55
55
|
end
|
56
56
|
|
57
57
|
# allocation - source ID {contactId}
|
58
58
|
if hAlloc.has_key?('sourceId')
|
59
|
-
|
59
|
+
unless hAlloc['sourceId'] == ''
|
60
60
|
intAlloc[:sourceId] = hAlloc['sourceId']
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
# allocation - recipient ID {contactId}
|
65
65
|
if hAlloc.has_key?('recipientId')
|
66
|
-
|
66
|
+
unless hAlloc['recipientId'] == ''
|
67
67
|
intAlloc[:recipientId] = hAlloc['recipientId']
|
68
68
|
end
|
69
69
|
end
|
@@ -88,7 +88,7 @@ module ADIWG
|
|
88
88
|
|
89
89
|
# allocation - comment
|
90
90
|
if hAlloc.has_key?('comment')
|
91
|
-
|
91
|
+
unless hAlloc['comment'] == ''
|
92
92
|
intAlloc[:comment] = hAlloc['comment']
|
93
93
|
end
|
94
94
|
end
|
@@ -2,15 +2,16 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
5
|
+
# Stan Smith 2018-02-18 refactored error and warning messaging
|
6
|
+
# Stan Smith 2016-10-18 refactored for mdJson 2.0
|
7
|
+
# Stan Smith 2015-07-14 refactored to remove global namespace constants
|
8
|
+
# Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
|
9
|
+
# Stan Smith 2014-12-30 added return if empty input
|
10
|
+
# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
|
11
|
+
# Stan Smith 2014-11-06 added resourceType for 0.9.0
|
12
|
+
# Stan Smith 2014-11-06 changed resourceType to initiative type for 0.9.0
|
13
|
+
# Stan Smith 2014-08-18 moved resourceIdentifier to citation module schema 0.6.0
|
14
|
+
# Stan Smith 2014-07-08 resolve require statements using Mdtranslator.reader_module
|
14
15
|
# Stan Smith 2014-06-02 added resource metadata citation section
|
15
16
|
# Stan Smith 2014-05-28 added resource identifier section
|
16
17
|
# Stan Smith 2014-05-02 original script
|
@@ -18,94 +19,92 @@
|
|
18
19
|
require_relative 'module_citation'
|
19
20
|
|
20
21
|
module ADIWG
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
module Mdtranslator
|
23
|
+
module Readers
|
24
|
+
module MdJson
|
25
|
+
|
26
|
+
module AssociatedResource
|
27
|
+
|
28
|
+
def self.unpack(hAssocRes, responseObj)
|
29
|
+
|
30
|
+
# return nil object if input is empty
|
31
|
+
if hAssocRes.empty?
|
32
|
+
responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: associated resource object is empty'
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
36
|
+
# instance classes needed in script
|
37
|
+
intMetadataClass = InternalMetadata.new
|
38
|
+
intAssocRes = intMetadataClass.newAssociatedResource
|
39
|
+
|
40
|
+
# associated resource - resource type [] (required) {resourceType}
|
41
|
+
if hAssocRes.has_key?('resourceType')
|
42
|
+
hAssocRes['resourceType'].each do |item|
|
43
|
+
unless item.empty?
|
44
|
+
hReturn = ResourceType.unpack(item, responseObj)
|
45
|
+
unless hReturn.nil?
|
46
|
+
intAssocRes[:resourceTypes] << hReturn
|
47
|
+
end
|
34
48
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if intAssocRes[:resourceTypes].empty?
|
52
|
+
responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: associated resource resource type is missing'
|
53
|
+
responseObj[:readerExecutionPass] = false
|
54
|
+
return nil
|
55
|
+
end
|
56
|
+
|
57
|
+
# associated resource - association type (required)
|
58
|
+
if hAssocRes.has_key?('associationType')
|
59
|
+
intAssocRes[:associationType] = hAssocRes['associationType']
|
60
|
+
end
|
61
|
+
if intAssocRes[:associationType].nil? || intAssocRes[:associationType] == ''
|
62
|
+
responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: associated resource association type is missing'
|
63
|
+
responseObj[:readerExecutionPass] = false
|
64
|
+
return nil
|
65
|
+
end
|
66
|
+
|
67
|
+
# associated resource - initiative type
|
68
|
+
if hAssocRes.has_key?('initiativeType')
|
69
|
+
if hAssocRes['initiativeType'] != ''
|
70
|
+
intAssocRes[:initiativeType] = hAssocRes['initiativeType']
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# associated resource - resource citation (required) {CI_Citation}
|
75
|
+
if hAssocRes.has_key?('resourceCitation')
|
76
|
+
hObject = hAssocRes['resourceCitation']
|
77
|
+
unless hObject.empty?
|
78
|
+
hReturn = Citation.unpack(hObject, responseObj)
|
79
|
+
unless hReturn.nil?
|
80
|
+
intAssocRes[:resourceCitation] = hReturn
|
50
81
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
82
|
+
end
|
83
|
+
end
|
84
|
+
if intAssocRes[:resourceCitation].empty?
|
85
|
+
responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: associated resource citation is missing'
|
86
|
+
responseObj[:readerExecutionPass] = false
|
87
|
+
return nil
|
88
|
+
end
|
89
|
+
|
90
|
+
# associated resource - metadata citation
|
91
|
+
if hAssocRes.has_key?('metadataCitation')
|
92
|
+
hObject = hAssocRes['metadataCitation']
|
93
|
+
unless hObject.empty?
|
94
|
+
hReturn = Citation.unpack(hObject, responseObj)
|
95
|
+
unless hReturn.nil?
|
96
|
+
intAssocRes[:metadataCitation] = hReturn
|
55
97
|
end
|
98
|
+
end
|
99
|
+
end
|
56
100
|
|
57
|
-
|
58
|
-
if hAssocRes.has_key?('associationType')
|
59
|
-
intAssocRes[:associationType] = hAssocRes['associationType']
|
60
|
-
end
|
61
|
-
if intAssocRes[:associationType].nil? || intAssocRes[:associationType] == ''
|
62
|
-
responseObj[:readerExecutionMessages] << 'Associated Resource attribute associationType is missing'
|
63
|
-
responseObj[:readerExecutionPass] = false
|
64
|
-
return nil
|
65
|
-
end
|
101
|
+
return intAssocRes
|
66
102
|
|
67
|
-
|
68
|
-
if hAssocRes.has_key?('initiativeType')
|
69
|
-
if hAssocRes['initiativeType'] != ''
|
70
|
-
intAssocRes[:initiativeType] = hAssocRes['initiativeType']
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# associated resource - resource citation (required) {CI_Citation}
|
75
|
-
if hAssocRes.has_key?('resourceCitation')
|
76
|
-
hObject = hAssocRes['resourceCitation']
|
77
|
-
unless hObject.empty?
|
78
|
-
hReturn = Citation.unpack(hObject, responseObj)
|
79
|
-
unless hReturn.nil?
|
80
|
-
intAssocRes[:resourceCitation] = hReturn
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
if intAssocRes[:resourceCitation].empty?
|
85
|
-
responseObj[:readerExecutionMessages] << 'Associated Resource requires a resource citation'
|
86
|
-
responseObj[:readerExecutionPass] = false
|
87
|
-
return nil
|
88
|
-
end
|
89
|
-
|
90
|
-
# associated resource - metadata citation
|
91
|
-
if hAssocRes.has_key?('metadataCitation')
|
92
|
-
hObject = hAssocRes['metadataCitation']
|
93
|
-
unless hObject.empty?
|
94
|
-
hReturn = Citation.unpack(hObject, responseObj)
|
95
|
-
unless hReturn.nil?
|
96
|
-
intAssocRes[:metadataCitation] = hReturn
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
return intAssocRes
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
103
|
+
end
|
107
104
|
|
108
105
|
end
|
109
|
-
|
110
|
-
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
111
110
|
end
|