adiwg-mdtranslator 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +24 -0
- data/README.md +31 -0
- data/Rakefile +13 -0
- data/adiwg-mdtranslator.gemspec +31 -0
- data/bin/mdtranslator +164 -0
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +499 -0
- data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +98 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/adiwgJson_reader.rb +80 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/adiwgJson_validator.rb +115 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_address.rb +71 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_associatedResource.rb +57 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_boundingBox.rb +51 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_browseGraphic.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_citation.rb +104 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_contacts.rb +121 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_coordinates.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_dataQuality.rb +40 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_dateTime.rb +27 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_descriptiveKeyword.rb +49 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_distributionInfo.rb +150 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_extent.rb +62 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_geoCoordSystem.rb +46 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_geoProperties.rb +89 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_geographicElement.rb +168 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_legalConstraint.rb +45 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_lineString.rb +25 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_lineage.rb +50 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_metadata.rb +76 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_metadataExtension.rb +40 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_metadataInfo.rb +119 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_onlineResource.rb +62 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_phone.rb +59 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_point.rb +25 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_polygon.rb +55 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_processStep.rb +64 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_resolution.rb +42 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_resourceFormat.rb +35 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_resourceIdentifier.rb +49 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_resourceInfo.rb +298 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_resourceMaintenance.rb +50 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_resourceSpecificUsage.rb +50 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_responsibleParty.rb +37 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_securityConstraint.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_source.rb +48 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_spatialReference.rb +48 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_taxonClass.rb +43 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_taxonomy.rb +83 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_temporalElement.rb +71 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_timeInstant.rb +45 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_timePeriod.rb +53 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_verticalElement.rb +53 -0
- data/lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_voucher.rb +38 -0
- data/lib/adiwg/mdtranslator/validator.rb +43 -0
- data/lib/adiwg/mdtranslator/version.rb +7 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_address.rb +91 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_aggregateInformation.rb +68 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_boundingPolygon.rb +75 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_browseGraphic.rb +51 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb +157 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_contact.rb +85 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb +338 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataQuality.rb +55 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb +60 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_digitalTransferOptions.rb +51 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distribution.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distributor.rb +80 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_extent.rb +94 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_format.rb +40 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_genericMetaData.rb +65 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geographicBoundingBox.rb +74 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geographicDescription.rb +29 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geographicElement.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_identifier.rb +51 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_keyword.rb +63 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_legalConstraints.rb +63 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineString.rb +74 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineage.rb +63 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_maintenanceInformation.rb +64 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_medium.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_metadata.rb +277 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_metadataExtension.rb +156 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb +140 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_onlineResource.rb +78 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_point.rb +74 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb +94 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processStep.rb +81 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_referenceIdentifier.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_referenceSystem.rb +29 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_resolution.rb +46 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +90 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_securityConstraints.rb +68 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_source.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_standardOrderProcess.rb +74 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonClassification.rb +65 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonSystem.rb +100 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb +77 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_temporalExtent.rb +58 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timeInstant.rb +47 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timePeriod.rb +54 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_usage.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_useConstraints.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_verticalExtent.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_vouchers.rb +48 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_associationType.rb +35 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_characterSet.rb +58 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_classification.rb +35 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_datatype.rb +45 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_dateType.rb +29 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_initiativeType.rb +35 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_keywordType.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_maintenanceFrequency.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_mediumFormat.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_mediumName.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_obligation.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_onlineFunction.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_presentationForm.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_progress.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_restriction.rb +38 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_role.rb +37 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_scope.rb +46 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_spatialRepresentationType.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/codelists/code_topicCategory.rb +50 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +131 -0
- data/lib/adiwg/mdtranslator.rb +97 -0
- data/lib/adiwg-mdtranslator.rb +1 -0
- data/mdtranslator.rb +178 -0
- data/test/adiwgJson_full_test_example.json +1717 -0
- data/test/adiwgJson_template.json +977 -0
- data/test/dev.rb +32 -0
- data/test/tc_translation.rb +31 -0
- metadata +317 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
# ADIwg ISO Translator internal data structure
|
|
2
|
+
|
|
3
|
+
# History:
|
|
4
|
+
# Stan Smith 2013-08-09 original script
|
|
5
|
+
# Stan Smith 2013-08-10 adding methods as needed
|
|
6
|
+
# Stan Smith 2013-09-19 added keywords
|
|
7
|
+
# Stan Smith 2013-09-20 change '' to nil for value attributes
|
|
8
|
+
# Stan Smith 2013-09-23 added distributor
|
|
9
|
+
# Stan Smith 2013-09-24 added distributor order process
|
|
10
|
+
# Stan Smith 2013-09-24 added digital transfer options
|
|
11
|
+
# Stan Smith 2013-09-24 added data transfer medium
|
|
12
|
+
# Stan Smith 2013-10-17 added browse graphic
|
|
13
|
+
# Stan Smith 2013-10-21 added address (separated from contact)
|
|
14
|
+
# Stan Smith 2013-10-25 added extent
|
|
15
|
+
# Stan Smith 2013-10-25 added bounding box
|
|
16
|
+
# Stan Smith 2013-10-25 added point
|
|
17
|
+
# Stan Smith 2013-10-25 added multi point
|
|
18
|
+
# Stan Smith 2013-10-25 added line string
|
|
19
|
+
# Stan Smith 2013-10-25 added polygon
|
|
20
|
+
# Stan Smith 2013-10-25 added linear ring
|
|
21
|
+
# Stan Smith 2013-10-25 added temporal extent
|
|
22
|
+
# Stan Smith 2013-10-25 added time instant
|
|
23
|
+
# Stan Smith 2013-10-25 added time period
|
|
24
|
+
# Stan Smith 2013-10-25 added vertical extent
|
|
25
|
+
# Stan Smith 2013-10-30 added constraint
|
|
26
|
+
# Stan Smith 2013-10-31 added resource maintenance
|
|
27
|
+
# Stan Smith 2013-11-19 added usage
|
|
28
|
+
# Stan Smith 2013-11-19 added taxonomy
|
|
29
|
+
# Stan Smith 2013-11-20 added data quality
|
|
30
|
+
# Stan Smith 2013-11-20 modified citation
|
|
31
|
+
# Stan Smith 2013-12-16 added phone book
|
|
32
|
+
# Stan Smith 2014-04-23 added protocol and doi to online resource
|
|
33
|
+
# Stan Smith 2014-04-24 added jsonVersion to newBase
|
|
34
|
+
# Stan Smith 2014-04-24 renamed newDataId to newResourceInfo
|
|
35
|
+
# Stan Smith 2014-04-24 reorganized newMetadata, newResourceInfo
|
|
36
|
+
# Stan Smith 2014-04-24 added newMetadataInfo
|
|
37
|
+
# Stan Smith 2014-04-25 modified newCitation for json schema 0.3.0
|
|
38
|
+
# Stan Smith 2014-04-25 added resource Ids to newCitation
|
|
39
|
+
# Stan Smith 2014-04-30 reorganized geometry blocks for json schema 0.3.0
|
|
40
|
+
# Stan Smith 2014-05-02 added associatedResource
|
|
41
|
+
# Stan Smith 2014-05-02 added additionalDocument
|
|
42
|
+
# Stan Smith 2014-05-28 modified resourceId & responsibleParty for schema 0.5.0
|
|
43
|
+
# Stan Smith 2014-08-15 modified citation, onlineResource, resourceId for 0.6.0
|
|
44
|
+
# Stan Smith 2014-09-03 added spatialReferenceSystems for name, EPSG, and WKT for 0.6.0
|
|
45
|
+
|
|
46
|
+
class InternalMetadata
|
|
47
|
+
|
|
48
|
+
# initialize attribute values - nil
|
|
49
|
+
# initialize arrays - []
|
|
50
|
+
# initialize hashes - {}
|
|
51
|
+
|
|
52
|
+
def initialize
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def newBase
|
|
56
|
+
intObj = {
|
|
57
|
+
jsonVersion: {
|
|
58
|
+
name: nil,
|
|
59
|
+
version: nil
|
|
60
|
+
},
|
|
61
|
+
contacts: [],
|
|
62
|
+
metadata: {}
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def newDateTime
|
|
67
|
+
intObj = {
|
|
68
|
+
dateTime: nil,
|
|
69
|
+
dateType: nil,
|
|
70
|
+
dateResolution: nil
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def newContact
|
|
75
|
+
intObj = {
|
|
76
|
+
contactID: nil,
|
|
77
|
+
indName: nil,
|
|
78
|
+
orgName: nil,
|
|
79
|
+
position: nil,
|
|
80
|
+
phones: [],
|
|
81
|
+
address: {},
|
|
82
|
+
onlineRes: [],
|
|
83
|
+
contactInstructions: nil
|
|
84
|
+
}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def newPhone
|
|
88
|
+
intObj = {
|
|
89
|
+
phoneServiceType: nil,
|
|
90
|
+
phoneName: nil,
|
|
91
|
+
phoneNumber: nil
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def newAddress
|
|
96
|
+
intObj = {
|
|
97
|
+
deliveryPoints: [],
|
|
98
|
+
city: nil,
|
|
99
|
+
adminArea: nil,
|
|
100
|
+
postalCode: nil,
|
|
101
|
+
country: nil,
|
|
102
|
+
eMailList: []
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def newMetadata
|
|
107
|
+
intObj = {
|
|
108
|
+
metadataInfo: {},
|
|
109
|
+
resourceInfo: {},
|
|
110
|
+
distributorInfo: [],
|
|
111
|
+
associatedResources: [],
|
|
112
|
+
additionalDocuments: []
|
|
113
|
+
}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def newMetadataInfo
|
|
117
|
+
intObj = {
|
|
118
|
+
metadataId: {},
|
|
119
|
+
parentMetadata: {},
|
|
120
|
+
metadataScope: [],
|
|
121
|
+
metadataCustodians: [],
|
|
122
|
+
metadataCreateDate: {},
|
|
123
|
+
metadataUpdateDate: {},
|
|
124
|
+
metadataURI: nil,
|
|
125
|
+
metadataStatus: nil,
|
|
126
|
+
maintInfo: {},
|
|
127
|
+
extensions: []
|
|
128
|
+
}
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def newRespParty
|
|
132
|
+
intObj = {
|
|
133
|
+
contactID: nil,
|
|
134
|
+
roleName: nil
|
|
135
|
+
}
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def newOnlineResource
|
|
139
|
+
intObj = {
|
|
140
|
+
olResURI: nil,
|
|
141
|
+
olResProtocol: nil,
|
|
142
|
+
olResName: nil,
|
|
143
|
+
olResDesc: nil,
|
|
144
|
+
olResFunction: nil
|
|
145
|
+
}
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def newResourceInfo
|
|
149
|
+
intObj = {
|
|
150
|
+
citation: {},
|
|
151
|
+
abstract: nil,
|
|
152
|
+
shortAbstract: nil,
|
|
153
|
+
hasMapLocation?: nil,
|
|
154
|
+
hasDataAvailable?: nil,
|
|
155
|
+
purpose: nil,
|
|
156
|
+
credits: [],
|
|
157
|
+
status: nil,
|
|
158
|
+
pointsOfContact: [],
|
|
159
|
+
resourceMaint: [],
|
|
160
|
+
graphicOverview: [],
|
|
161
|
+
resourceFormats: [],
|
|
162
|
+
resourceLanguages: [],
|
|
163
|
+
descriptiveKeywords: [],
|
|
164
|
+
resourceUses: [],
|
|
165
|
+
useConstraints: [],
|
|
166
|
+
legalConstraints: [],
|
|
167
|
+
securityConstraints: [],
|
|
168
|
+
taxonomy: {},
|
|
169
|
+
spatialReferenceSystem: {},
|
|
170
|
+
spatialRepresentationTypes: [],
|
|
171
|
+
spatialResolutions: [],
|
|
172
|
+
topicCategories: [],
|
|
173
|
+
environmentDescription: nil,
|
|
174
|
+
extents: [],
|
|
175
|
+
dataQualityInfo: [],
|
|
176
|
+
supplementalInfo: nil
|
|
177
|
+
}
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def newCitation
|
|
181
|
+
intObj = {
|
|
182
|
+
citTitle: nil,
|
|
183
|
+
citDate: [],
|
|
184
|
+
citEdition: nil,
|
|
185
|
+
citResourceIDs: [],
|
|
186
|
+
citResponsibleParty: [],
|
|
187
|
+
citResourceForms: [],
|
|
188
|
+
citOlResources: []
|
|
189
|
+
}
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def newResourceId
|
|
193
|
+
intObj = {
|
|
194
|
+
identifier: nil,
|
|
195
|
+
identifierType: nil,
|
|
196
|
+
identifierCitation: {}
|
|
197
|
+
}
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def newResourceFormat
|
|
201
|
+
intObj = {
|
|
202
|
+
formatName: nil,
|
|
203
|
+
formatVersion: nil
|
|
204
|
+
}
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def newResourceMaint
|
|
208
|
+
intObj = {
|
|
209
|
+
maintFreq: nil,
|
|
210
|
+
maintNotes: [],
|
|
211
|
+
maintContacts: []
|
|
212
|
+
}
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def newKeyword
|
|
216
|
+
intObj = {
|
|
217
|
+
keyword: [],
|
|
218
|
+
keywordType: nil,
|
|
219
|
+
keyTheCitation: {}
|
|
220
|
+
}
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def newLegalCon
|
|
224
|
+
intObj = {
|
|
225
|
+
accessCons: [],
|
|
226
|
+
useCons: [],
|
|
227
|
+
otherCons: []
|
|
228
|
+
}
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def newSecurityCon
|
|
232
|
+
intObj = {
|
|
233
|
+
classification: nil,
|
|
234
|
+
userNote: nil,
|
|
235
|
+
classSystem: nil,
|
|
236
|
+
handlingDesc: nil
|
|
237
|
+
}
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def newDistributor
|
|
241
|
+
intObj = {
|
|
242
|
+
distContact: {},
|
|
243
|
+
distOrderProc: [],
|
|
244
|
+
distFormat: [],
|
|
245
|
+
distTransOption: []
|
|
246
|
+
}
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def newDistOrder
|
|
250
|
+
intObj = {
|
|
251
|
+
fees: nil,
|
|
252
|
+
plannedDateTime: {},
|
|
253
|
+
orderInstructions: nil,
|
|
254
|
+
turnaround: nil
|
|
255
|
+
}
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def newDigitalTransOption
|
|
259
|
+
intObj = {
|
|
260
|
+
online: [],
|
|
261
|
+
offline: {}
|
|
262
|
+
}
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def newMedium
|
|
266
|
+
intObj = {
|
|
267
|
+
mediumName: nil,
|
|
268
|
+
mediumFormat: nil,
|
|
269
|
+
mediumNote: nil
|
|
270
|
+
}
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def newBrowseGraphic
|
|
274
|
+
intObj = {
|
|
275
|
+
bGName: nil,
|
|
276
|
+
bGDescription: nil,
|
|
277
|
+
bGType: nil,
|
|
278
|
+
bGURI: nil
|
|
279
|
+
}
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def newSpatialReferenceSystem
|
|
283
|
+
intObj = {
|
|
284
|
+
sRNames: [],
|
|
285
|
+
sREPSGs: [],
|
|
286
|
+
sRWKTs: []
|
|
287
|
+
}
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def newExtent
|
|
291
|
+
intObj = {
|
|
292
|
+
extDesc: nil,
|
|
293
|
+
extGeoElements: [],
|
|
294
|
+
extIdElements: [],
|
|
295
|
+
extTempElements: [],
|
|
296
|
+
extVertElements: []
|
|
297
|
+
}
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def newGeoElement
|
|
301
|
+
intObj = {
|
|
302
|
+
elementId: nil,
|
|
303
|
+
elementIncludeData: nil,
|
|
304
|
+
elementName: nil,
|
|
305
|
+
elementDescription: nil,
|
|
306
|
+
temporalElements: [],
|
|
307
|
+
verticalElements: [],
|
|
308
|
+
elementIdentifiers: [],
|
|
309
|
+
elementScope: nil,
|
|
310
|
+
elementAcquisition: nil,
|
|
311
|
+
elementSrs: {},
|
|
312
|
+
elementGeometry: {}
|
|
313
|
+
}
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def newSRS
|
|
317
|
+
intObj = {
|
|
318
|
+
srsName: nil,
|
|
319
|
+
srsHref: nil,
|
|
320
|
+
sysType: nil
|
|
321
|
+
}
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def newGeometry
|
|
325
|
+
intObj = {
|
|
326
|
+
geoType: nil,
|
|
327
|
+
geometry: {},
|
|
328
|
+
dimension: nil
|
|
329
|
+
}
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def newBoundingBox
|
|
333
|
+
intObj = {
|
|
334
|
+
westLong: nil,
|
|
335
|
+
eastLong: nil,
|
|
336
|
+
southLat: nil,
|
|
337
|
+
northLat: nil
|
|
338
|
+
}
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def newPolygonSet
|
|
342
|
+
intObj = {
|
|
343
|
+
exteriorRing: {},
|
|
344
|
+
exclusionRings: []
|
|
345
|
+
}
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def newTemporalElement
|
|
349
|
+
intObj = {
|
|
350
|
+
date: {},
|
|
351
|
+
timeInstant: {},
|
|
352
|
+
timePeriod: {}
|
|
353
|
+
}
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def newTimeInstant
|
|
357
|
+
intObj = {
|
|
358
|
+
timeID: nil,
|
|
359
|
+
description: nil,
|
|
360
|
+
timePosition: {}
|
|
361
|
+
}
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def newTimePeriod
|
|
365
|
+
intObj = {
|
|
366
|
+
timeID: nil,
|
|
367
|
+
description: nil,
|
|
368
|
+
beginTime: {},
|
|
369
|
+
endTime: {}
|
|
370
|
+
}
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def newVerticalElement
|
|
374
|
+
intObj = {
|
|
375
|
+
minValue: nil,
|
|
376
|
+
maxValue: nil,
|
|
377
|
+
crsURI: nil,
|
|
378
|
+
crsTitle: nil
|
|
379
|
+
}
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
def newLegalConstraint
|
|
383
|
+
intObj = {
|
|
384
|
+
accessCodes: [],
|
|
385
|
+
useCodes: [],
|
|
386
|
+
otherCons: []
|
|
387
|
+
}
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def newSecurityConstraint
|
|
391
|
+
intObj = {
|
|
392
|
+
classCode: nil,
|
|
393
|
+
userNote: nil,
|
|
394
|
+
classSystem: nil,
|
|
395
|
+
handlingDesc: nil
|
|
396
|
+
}
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def newDataUsage
|
|
400
|
+
intObj = {
|
|
401
|
+
specificUsage: nil,
|
|
402
|
+
userLimits: nil,
|
|
403
|
+
userContacts: []
|
|
404
|
+
}
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
def newTaxonSystem
|
|
408
|
+
intObj = {
|
|
409
|
+
taxClassSys: [],
|
|
410
|
+
taxGeneralScope: nil,
|
|
411
|
+
taxObservers: [],
|
|
412
|
+
taxIdProcedures: nil,
|
|
413
|
+
taxVoucher: {},
|
|
414
|
+
taxClasses: []
|
|
415
|
+
}
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
def newTaxonVoucher
|
|
419
|
+
intObj = {
|
|
420
|
+
specimen: nil,
|
|
421
|
+
repository: {}
|
|
422
|
+
}
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def newTaxonClass
|
|
426
|
+
intObj = {
|
|
427
|
+
commonName: nil,
|
|
428
|
+
taxRankName: nil,
|
|
429
|
+
taxRankValue: nil
|
|
430
|
+
}
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def newResolution
|
|
434
|
+
intObj = {
|
|
435
|
+
equivalentScale: nil,
|
|
436
|
+
distance: nil,
|
|
437
|
+
distanceUOM: nil
|
|
438
|
+
}
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
def newDataQuality
|
|
442
|
+
intObj = {
|
|
443
|
+
dataScope: nil,
|
|
444
|
+
dataLineage: {}
|
|
445
|
+
}
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def newLineage
|
|
449
|
+
intObj = {
|
|
450
|
+
statement: nil,
|
|
451
|
+
processSteps: [],
|
|
452
|
+
dataSources: []
|
|
453
|
+
}
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
def newDataProcessStep
|
|
457
|
+
intObj = {
|
|
458
|
+
stepID: nil,
|
|
459
|
+
stepDescription: nil,
|
|
460
|
+
stepRationale: nil,
|
|
461
|
+
stepDateTime: {},
|
|
462
|
+
stepProcessors: []
|
|
463
|
+
}
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
def newDataSource
|
|
467
|
+
intObj = {
|
|
468
|
+
sourceDescription: nil,
|
|
469
|
+
sourceCitation: {},
|
|
470
|
+
sourceSteps: []
|
|
471
|
+
}
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
def newMetadataExtension
|
|
475
|
+
intObj = {
|
|
476
|
+
onLineResource: {},
|
|
477
|
+
extName: nil,
|
|
478
|
+
extShortName: nil,
|
|
479
|
+
extDefinition: nil,
|
|
480
|
+
obligation: nil,
|
|
481
|
+
dataType: nil,
|
|
482
|
+
maxOccurrence: nil,
|
|
483
|
+
parentEntities: [],
|
|
484
|
+
rule: nil,
|
|
485
|
+
rationales: [],
|
|
486
|
+
extSources: []
|
|
487
|
+
}
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
def newAssociatedResource
|
|
491
|
+
intObj = {
|
|
492
|
+
associationType: nil,
|
|
493
|
+
resourceType: nil,
|
|
494
|
+
resourceCitation: {},
|
|
495
|
+
metadataCitation: {}
|
|
496
|
+
}
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# date, dateTime methods
|
|
2
|
+
# for ADIwg readers and writers
|
|
3
|
+
|
|
4
|
+
# History:
|
|
5
|
+
# Stan Smith 2013-09-26 original script
|
|
6
|
+
# Stan Smith 2013-12-06 added support for fractional seconds
|
|
7
|
+
|
|
8
|
+
require 'date'
|
|
9
|
+
|
|
10
|
+
module AdiwgDateTimeFun
|
|
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
|
|
28
|
+
|
|
29
|
+
return nil, 'ERROR'
|
|
30
|
+
end
|
|
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
|
|
44
|
+
|
|
45
|
+
return s
|
|
46
|
+
end
|
|
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
|
|
69
|
+
|
|
70
|
+
return s
|
|
71
|
+
end
|
|
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
|
|
94
|
+
|
|
95
|
+
return s
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Reader - ADIwg JSON V1 to internal data structure
|
|
2
|
+
|
|
3
|
+
# History:
|
|
4
|
+
# Stan Smith 2013-08-09 original script
|
|
5
|
+
# Stan Smith 2013-08-19 split out contacts to module_contacts
|
|
6
|
+
# Stan Smith 2013-08-23 split out metadata to module_metadata
|
|
7
|
+
# Stan Smith 2014-04-23 add json schema version to internal object
|
|
8
|
+
# Stan Smith 2014-06-05 capture an test json version
|
|
9
|
+
# Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
|
|
10
|
+
# Stan Smith 2014-07-08 moved json schema version testing to 'adiwg_1_get_version'
|
|
11
|
+
# Stan Smith 2014-08-18 add json name/version to internal object
|
|
12
|
+
|
|
13
|
+
require 'json'
|
|
14
|
+
require ADIWG::Mdtranslator.reader_module('module_contacts', $response[:readerVersionUsed])
|
|
15
|
+
require ADIWG::Mdtranslator.reader_module('module_metadata', $response[:readerVersionUsed])
|
|
16
|
+
|
|
17
|
+
class AdiwgJsonReader
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def unpack(jsonObj)
|
|
23
|
+
|
|
24
|
+
# instance classes needed in script
|
|
25
|
+
intMetadataClass = InternalMetadata.new
|
|
26
|
+
|
|
27
|
+
# create new internal metadata container for the reader
|
|
28
|
+
intBase = intMetadataClass.newBase
|
|
29
|
+
|
|
30
|
+
# convert the received JSON to a Ruby hash
|
|
31
|
+
hashObj = JSON.parse(jsonObj)
|
|
32
|
+
|
|
33
|
+
# get json schema name and version
|
|
34
|
+
if hashObj.has_key?('version')
|
|
35
|
+
hVersion = hashObj['version']
|
|
36
|
+
unless hVersion.empty?
|
|
37
|
+
if hVersion.has_key?('name')
|
|
38
|
+
s = hVersion['name']
|
|
39
|
+
if !s.nil?
|
|
40
|
+
intBase[:jsonVersion][:name] = s
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
if hVersion.has_key?('version')
|
|
44
|
+
s = hVersion['version']
|
|
45
|
+
if !s.nil?
|
|
46
|
+
intBase[:jsonVersion][:version] = s
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# contact
|
|
53
|
+
# load the array of contacts from the json object
|
|
54
|
+
# ... the contacts array uses a local id to reference the
|
|
55
|
+
# ... contact in the array from elsewhere in the json metadata
|
|
56
|
+
if hashObj.has_key?('contact')
|
|
57
|
+
aContacts = hashObj['contact']
|
|
58
|
+
aContacts.each do |hContact|
|
|
59
|
+
unless hContact.empty?
|
|
60
|
+
intBase[:contacts] << Adiwg_Contact.unpack(hContact)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# add default contacts
|
|
66
|
+
intBase[:contacts].concat(Adiwg_Contact.setDefaultContacts)
|
|
67
|
+
|
|
68
|
+
# metadata
|
|
69
|
+
# load metadata from the hash object
|
|
70
|
+
if hashObj.has_key?('metadata')
|
|
71
|
+
hMetadata = hashObj['metadata']
|
|
72
|
+
intBase[:metadata] = Adiwg_Metadata.unpack(hMetadata)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# return ADIwg internal container
|
|
76
|
+
return intBase
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|