adiwg-mdtranslator 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +23 -23
  3. data/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb +1 -0
  4. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +110 -0
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_digitalForm.rb +69 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +82 -1
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +72 -0
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +32 -1
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +45 -0
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +50 -0
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +29 -13
  12. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +1 -1
  13. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +125 -1
  14. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_offlineOption.rb +98 -0
  15. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_onlineOption.rb +81 -0
  16. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_orderProcess.rb +79 -0
  17. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_pointVector.rb +102 -0
  18. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_range.rb +50 -0
  19. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_raster.rb +84 -0
  20. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialOrganization.rb +48 -2
  21. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +20 -1
  22. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +87 -0
  23. data/lib/adiwg/mdtranslator/version.rb +2 -1
  24. metadata +15 -3
@@ -0,0 +1,45 @@
1
+ # Reader - fgdc to internal data structure
2
+ # unpack fgdc entity and attribute overview
3
+
4
+ # History:
5
+ # Stan Smith 2017-09-06 original script
6
+
7
+ require 'uuidtools'
8
+ require 'nokogiri'
9
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Readers
14
+ module Fgdc
15
+
16
+ module EntityOverview
17
+
18
+ def self.unpack(xOverview, hResponseObj)
19
+
20
+ # instance classes needed in script
21
+ intMetadataClass = InternalMetadata.new
22
+ hEntity = intMetadataClass.newEntity
23
+ hEntity[:entityId] = UUIDTools::UUID.random_create.to_s
24
+ hEntity[:entityCode] = 'overview'
25
+
26
+ # entity attribute 5.2.1 (eaover) - entity attribute overview
27
+ # -> dataDictionary.entities.entityDefinition
28
+ definition = xOverview.xpath('./eaover').text
29
+ unless definition.empty?
30
+ hEntity[:entityDefinition] = definition
31
+ end
32
+
33
+ # entity attribute 5.2.2 (eadetcit) - entity attribute detail citation []
34
+ # -> not mapped
35
+
36
+ return hEntity
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,50 @@
1
+ # Reader - fgdc to internal data structure
2
+ # unpack fgdc entity enumerated domain
3
+
4
+ # History:
5
+ # Stan Smith 2017-09-06 original script
6
+
7
+ require 'nokogiri'
8
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module Fgdc
14
+
15
+ module Enumerated
16
+
17
+ def self.unpack(xEnumeration, hResponseObj)
18
+
19
+ # instance classes needed in script
20
+ intMetadataClass = InternalMetadata.new
21
+ hItem = intMetadataClass.newDomainItem
22
+
23
+ # entity attribute 5.1.2.4.1.1 (edomv) - enumerated domain value
24
+ # -> dataDictionary.domainItems.itemValue
25
+ value = xEnumeration.xpath('./edomv').text
26
+ unless value.empty?
27
+ hItem[:itemName] = value
28
+ hItem[:itemValue] = value
29
+ end
30
+
31
+ # entity attribute 5.1.2.4.1.2 (edomvd) - enumerated domain value definition
32
+ # -> dataDictionary.domainItems.itemDefinition
33
+ definition = xEnumeration.xpath('./edomvd').text
34
+ unless definition.empty?
35
+ hItem[:itemDefinition] = definition
36
+ end
37
+
38
+ # entity attribute 5.1.2.4.1.3 (edomvds) - enumerated domain value definition source
39
+ # -> not mapped
40
+
41
+ return hItem
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -7,6 +7,7 @@
7
7
  require 'nokogiri'
8
8
  require 'uuidtools'
9
9
  require 'adiwg/mdtranslator/internal/internal_metadata_obj'
10
+ require_relative '../version'
10
11
  require_relative 'module_identification'
11
12
  require_relative 'module_quality'
12
13
  require_relative 'module_spatialOrganization'
@@ -34,14 +35,18 @@ module ADIWG
34
35
 
35
36
  # build basic mdTranslator internal object
36
37
  hMetadata = intMetadataClass.newMetadata
37
- hMetadataInfo = intMetadataClass.newMetadataInfo
38
38
  hResourceInfo = intMetadataClass.newResourceInfo
39
- hMetadata[:metadataInfo] = hMetadataInfo
40
39
  hMetadata[:resourceInfo] = hResourceInfo
41
40
  intObj[:metadata] = hMetadata
42
41
 
43
42
  xMetadata = xDoc.xpath('./metadata')
44
43
 
44
+ # schema
45
+ hSchema = intMetadataClass.newSchema
46
+ hSchema[:name] = 'fgdc'
47
+ hSchema[:version] = ADIWG::Mdtranslator::Readers::Fgdc::VERSION
48
+ @intObj[:schema] = hSchema
49
+
45
50
  # metadata (idinfo 1) - identification information (required)
46
51
  xIdInfo = xMetadata.xpath('./idinfo')
47
52
  unless xIdInfo.empty?
@@ -60,31 +65,42 @@ module ADIWG
60
65
  # metadata (spdoinfo 3) - spatial data organization
61
66
  xSpatialOrg = xMetadata.xpath('./spdoinfo')
62
67
  unless xSpatialOrg.empty?
63
- SpatialOrganization.unpack(xSpatialOrg, hResponseObj)
68
+ SpatialOrganization.unpack(xSpatialOrg, hResourceInfo, hResponseObj)
64
69
  end
65
70
 
66
71
  # metadata (spref 4) - spatial reference
67
- xSpatialRef = xMetadata.xpath('./spref')
68
- unless xSpatialRef.empty?
69
- SpatialReference.unpack(xSpatialRef, hResponseObj)
70
- end
72
+ # xSpatialRef = xMetadata.xpath('./spref')
73
+ # unless xSpatialRef.empty?
74
+ # SpatialReference.unpack(xSpatialRef, hResponseObj)
75
+ # end
71
76
 
72
77
  # metadata (eainfo 5) - entity and attribute
73
78
  xEntity = xMetadata.xpath('./eainfo')
74
79
  unless xEntity.empty?
75
- EntityAttribute.unpack(xEntity, hResponseObj)
80
+ hDictionary = EntityAttribute.unpack(xEntity, hResponseObj)
81
+ unless hDictionary.nil?
82
+ @intObj[:dataDictionaries] << hDictionary
83
+ end
76
84
  end
77
85
 
78
- # metadata (distinfo 6) - distribution information
79
- xDistribution = xMetadata.xpath('./distinfo')
80
- unless xDistribution.empty?
81
- Distribution.unpack(xDistribution, hResponseObj)
86
+ # metadata (distinfo 6) - distribution information []
87
+ axDistribution = xMetadata.xpath('./distinfo')
88
+ unless axDistribution.empty?
89
+ axDistribution.each do |xDistribution|
90
+ hDistribution = Distribution.unpack(xDistribution, hResourceInfo, hResponseObj)
91
+ unless hDistribution.nil?
92
+ hMetadata[:distributorInfo] << hDistribution
93
+ end
94
+ end
82
95
  end
83
96
 
84
97
  # metadata (metainfo 7) - metadata reference (required)
85
98
  xMetaInfo = xMetadata.xpath('./metainfo')
86
99
  unless xMetaInfo.empty?
87
- MetadataInformation.unpack(xMetaInfo, hResponseObj)
100
+ hMetadataInfo = MetadataInformation.unpack(xMetaInfo, hResourceInfo, hResponseObj)
101
+ unless hMetadataInfo.nil?
102
+ hMetadata[:metadataInfo] = hMetadataInfo
103
+ end
88
104
  end
89
105
  if xMetaInfo.empty?
90
106
  hResponseObj[:readerExecutionMessages] << 'FGDC is missing metadata information section (metainfo)'
@@ -131,7 +131,7 @@ module ADIWG
131
131
  hResourceInfo[:constraints] << hConstraint
132
132
  end
133
133
 
134
- # identification information 1.9 (ptcontac) - point of contact
134
+ # identification information 1.9 (ptcontac) - point of contact {contact}
135
135
  xContact = xIdInfo.xpath('./ptcontac')
136
136
  unless xContact.empty?
137
137
  hResponsibility = Contact.unpack(xContact, hResponseObj)
@@ -6,6 +6,8 @@
6
6
 
7
7
  require 'nokogiri'
8
8
  require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+ require_relative 'module_date'
10
+ require_relative 'module_contact'
9
11
 
10
12
  module ADIWG
11
13
  module Mdtranslator
@@ -14,9 +16,131 @@ module ADIWG
14
16
 
15
17
  module MetadataInformation
16
18
 
17
- def self.unpack(xMetaInfo, hResponseObj)
19
+ def self.unpack(xMetaInfo, hResourceInfo, hResponseObj)
18
20
 
21
+ # instance classes needed in script
22
+ intMetadataClass = InternalMetadata.new
23
+ hMetadataInfo = intMetadataClass.newMetadataInfo
24
+ hLegal = intMetadataClass.newLegalConstraint
19
25
 
26
+ # metadata information 7.1 (metd) - metadata date
27
+ # -> metadataInfo.metadataDates.date{type=creation}
28
+ date = xMetaInfo.xpath('./metd').text
29
+ unless date.empty?
30
+ hDate = Date.unpack(date, '', 'creation', hResponseObj)
31
+ unless hDate.nil?
32
+ hMetadataInfo[:metadataDates] << hDate
33
+ end
34
+ end
35
+
36
+ # metadata information 7.2 (metrd) - metadata review date
37
+ # -> metadataInfo.metadataDates.date{type=review}
38
+ date = xMetaInfo.xpath('./metrd').text
39
+ unless date.empty?
40
+ hDate = Date.unpack(date, '', 'review', hResponseObj)
41
+ unless hDate.nil?
42
+ hMetadataInfo[:metadataDates] << hDate
43
+ end
44
+ end
45
+
46
+ # metadata information 7.3 (metfrd) - metadata future review date
47
+ # -> metadataInfo.metadataDates.date{type=nextReview}
48
+ date = xMetaInfo.xpath('./metfrd').text
49
+ unless date.empty?
50
+ hDate = Date.unpack(date, '', 'nextReview', hResponseObj)
51
+ unless hDate.nil?
52
+ hMetadataInfo[:metadataDates] << hDate
53
+ end
54
+ end
55
+
56
+ # metadata information 7.4 (metc) - metadata contact
57
+ # -> metadataInfo.metadataContacts.responsibility{roleType=pointOfContact}
58
+ xContact = xMetaInfo.xpath('./metc')
59
+ unless xContact.empty?
60
+ hResponsibility = Contact.unpack(xContact, hResponseObj)
61
+ unless hResponsibility.nil?
62
+ hResponsibility[:roleName] = 'pointOfContact'
63
+ hMetadataInfo[:metadataContacts] << hResponsibility
64
+ end
65
+ end
66
+
67
+ # metadata information 7.5 (metstdn) - metadata standard name
68
+ # -> set by writer
69
+
70
+ # metadata information 7.6 (metstdv) - metadata standard version
71
+ # -> set by writer
72
+
73
+ # metadata information 7.7 (mettc) - metadata time convention
74
+ # -> read by date/time modules
75
+
76
+ # metadata information 7.8 (metac) - metadata access constraint
77
+ # -> resourceInfo.constraints.legalConstraint.accessCodes
78
+ accessCode = xMetaInfo.xpath('metac').text
79
+ unless accessCode.empty?
80
+ hLegal[:accessCodes] << accessCode
81
+ end
82
+
83
+ # metadata information 7.9 (metuc) - metadata use constraint
84
+ # -> resourceInfo.constraints.legalConstraint.useCodes
85
+ useCode = xMetaInfo.xpath('metuc').text
86
+ unless useCode.empty?
87
+ hLegal[:useCodes] << useCode
88
+ end
89
+
90
+ legal = accessCode + useCode
91
+ if legal != ''
92
+ hConstraint = intMetadataClass.newConstraint
93
+ hConstraint[:type] = 'legal'
94
+ hConstraint[:legalConstraint] = hLegal
95
+ hResourceInfo[:constraints] << hConstraint
96
+ end
97
+
98
+ # metadata information 7.10 (metsi) - metadata security information
99
+ xSecurity = xMetaInfo.xpath('./metsi')
100
+ unless xSecurity.empty?
101
+
102
+ hSecurity = intMetadataClass.newSecurityConstraint
103
+
104
+ # metadata information 7.10.1 (metscs) - metadata security classification system
105
+ # -> resourceInfo.constraints.securityConstraint.classificationSystem
106
+ system = xSecurity.xpath('./metscs').text
107
+ unless system.empty?
108
+ hSecurity[:classSystem] = system
109
+ end
110
+
111
+ # metadata information 7.10.2 (metsc) - metadata security classification
112
+ # -> resourceInfo.constraints.securityConstraint.classification
113
+ classCode = xSecurity.xpath('./metsc').text
114
+ unless classCode.empty?
115
+ hSecurity[:classCode] = classCode
116
+ end
117
+
118
+ # metadata information 7.10.3 (metshd) - metadata security handling description
119
+ # -> resourceInfo.constraints.securityConstraint.handlingDescription
120
+ handling = xSecurity.xpath('./metshd').text
121
+ unless handling.empty?
122
+ hSecurity[:handling] = handling
123
+ end
124
+
125
+ security = system + classCode + handling
126
+ if security != ''
127
+ hConstraint = intMetadataClass.newConstraint
128
+ hConstraint[:type] = 'security'
129
+ hConstraint[:securityConstraint] = hSecurity
130
+ hResourceInfo[:constraints] << hConstraint
131
+ end
132
+
133
+ end
134
+
135
+ # metadata information 7.11 (metextns) - metadata extension []
136
+
137
+ # metadata information 7.11.1 (onlink) - online linkage []
138
+ # -> set by writer, reader assumes NBII biological extension is present
139
+
140
+ # metadata information 7.11.2 (metprof) - profile name
141
+ # -> set by writer, reader assumes NBII biological extension is present
142
+
143
+ return hMetadataInfo
20
144
 
21
145
  end
22
146
 
@@ -0,0 +1,98 @@
1
+ # Reader - fgdc to internal data structure
2
+ # unpack fgdc distribution digital offline transfer
3
+
4
+ # History:
5
+ # Stan Smith 2017-09-09 original script
6
+
7
+ require 'nokogiri'
8
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+ require_relative 'module_date'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Readers
14
+ module Fgdc
15
+
16
+ module OfflineOption
17
+
18
+ def self.unpack(xOffline, hResponseObj)
19
+
20
+ # instance classes needed in script
21
+ intMetadataClass = InternalMetadata.new
22
+ hOffline = intMetadataClass.newMedium
23
+ aDensity = []
24
+ aOfflines = []
25
+
26
+ # distribution 6.4.2.2.2.1 (offmedia) - offline media
27
+ # -> distribution.distributor.offlineOption.mediumSpecification.title
28
+ title = xOffline.xpath('./offmedia').text
29
+ unless title.empty?
30
+ hSpecification = intMetadataClass.newCitation
31
+ hSpecification[:title] = title
32
+ hOffline[:mediumSpecification] = hSpecification
33
+ end
34
+
35
+ # distribution 6.4.2.2.2.2 (reccap) - recording capacity
36
+ xCapacity = xOffline.xpath('./reccap')
37
+ unless xCapacity.empty?
38
+
39
+ # distribution 6.4.2.2.2.2.1 (recden) - recording density []
40
+ # -> distribution.distributor.offlineOption.density
41
+ axDensity = xCapacity.xpath('./recden')
42
+ unless axDensity.empty?
43
+ axDensity.each do |xDensity|
44
+ density = xDensity.text
45
+ unless density.empty?
46
+ aDensity << density.to_i
47
+ end
48
+ end
49
+ end
50
+
51
+ # distribution 6.4.2.2.2.2.2 (recdenu) - recording density units
52
+ # -> distribution.distributor.offlineOption.units
53
+ units = xCapacity.xpath('./recdenu').text
54
+ unless units.empty?
55
+ hOffline[:units] = units
56
+ end
57
+
58
+ end
59
+
60
+ # distribution 6.4.2.2.2.3 (recfmt) - recording format []
61
+ # -> distribution.distributor.offlineOption.mediumFormat
62
+ axFormat = xOffline.xpath('./recfmt')
63
+ unless axFormat.empty?
64
+ axFormat.each do |xFormat|
65
+ format = xFormat.text
66
+ unless format.empty?
67
+ hOffline[:mediumFormat] << format
68
+ end
69
+ end
70
+ end
71
+
72
+ # distribution 6.4.2.2.2.4 (compat) - compatibility information
73
+ # -> distribution.distributor.offlineOption.note
74
+ note = xOffline.xpath('./compat').text
75
+ unless note.empty?
76
+ hOffline[:note] = note
77
+ end
78
+
79
+ # create an offline object for each density
80
+ if aDensity.empty?
81
+ aOfflines << hOffline
82
+ else
83
+ aDensity.each do |density|
84
+ hClone = hOffline.clone
85
+ hClone[:density] = density
86
+ aOfflines << hClone
87
+ end
88
+ end
89
+
90
+ return aOfflines
91
+
92
+ end
93
+ end
94
+
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,81 @@
1
+ # Reader - fgdc to internal data structure
2
+ # unpack fgdc distribution digital online transfer
3
+
4
+ # History:
5
+ # Stan Smith 2017-09-09 original script
6
+
7
+ require 'nokogiri'
8
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+ require_relative 'module_date'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Readers
14
+ module Fgdc
15
+
16
+ module OnlineOption
17
+
18
+ def self.unpack(xOnline, hResponseObj)
19
+
20
+ # instance classes needed in script
21
+ intMetadataClass = InternalMetadata.new
22
+ aOnlines = []
23
+
24
+ # distribution 6.4.2.2.1.2 (accinstr) - access instructions
25
+ # -> distribution.distributor.onlineOption.protocol
26
+ protocol = xOnline.xpath('./accinstr').text
27
+
28
+ # distribution 6.4.2.2.1.3 (oncomp) - online computer and operating system
29
+ # -> distribution.distributor.onlineOption.description
30
+ description = xOnline.xpath('./oncomp').text
31
+
32
+ # distribution 6.4.2.2.1.1 (computer) - computer contact information []
33
+ axComputers = xOnline.xpath('./computer')
34
+ unless axComputers.empty?
35
+ axComputers.each do |xComputer|
36
+
37
+ # distribution 6.4.2.2.1.1.1 (networka) - network address
38
+ xNetwork = xComputer.xpath('./networka')
39
+ unless xNetwork.empty?
40
+
41
+ # distribution 6.4.2.2.1.1.1.1 (networkr) - network resource name []
42
+ # -> distribution.distributor.onlineOption.uri
43
+ axURI = xNetwork.xpath('./networkr')
44
+ unless axURI.empty?
45
+ axURI.each do |network|
46
+ uri = network.text
47
+ unless uri.empty?
48
+ hOnlineRes = intMetadataClass.newOnlineResource
49
+ hOnlineRes[:olResURI] = uri
50
+ hOnlineRes[:olResProtocol] = protocol unless protocol.empty?
51
+ hOnlineRes[:olResDesc] = description unless description.empty?
52
+ aOnlines << hOnlineRes
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+ # dialup section is deprecated and will not be supported in ADIwg toolkit
60
+ # distribution 6.4.2.2.1.1.2 (dialinst) - dialup instructions
61
+ # distribution 6.4.2.2.1.1.2.1 (lowbps) - lowest bits per second
62
+ # distribution 6.4.2.2.1.1.2.2 (highbps) - highest bits per second
63
+ # distribution 6.4.2.2.1.1.2.3 (numdata) - number of data bits per character {7|8}
64
+ # distribution 6.4.2.2.1.1.2.4 (numstop) - number of stop bits per exchange {1|2}
65
+ # distribution 6.4.2.2.1.1.2.5 (parity) - parity {none | odd | even | mark | space}
66
+ # distribution 6.4.2.2.1.1.2.6 (compress) - compression support
67
+ # distribution 6.4.2.2.1.1.2.7 (dialtel) - dialup telephone
68
+ # distribution 6.4.2.2.1.1.2.8 (dialfile) - dialup file name []
69
+
70
+ end
71
+ end
72
+
73
+ return aOnlines
74
+
75
+ end
76
+ end
77
+
78
+ end
79
+ end
80
+ end
81
+ end