adiwg-mdtranslator 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/adiwg-mdtranslator.gemspec +1 -1
  4. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +552 -500
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +1 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +63 -16
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +7 -16
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +1 -1
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +1 -0
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +7 -1
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +2 -2
  12. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +4 -1
  13. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +4 -3
  14. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +15 -11
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_constraint.rb +134 -134
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb +9 -4
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_distribution.rb +52 -36
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domainItem.rb +65 -51
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataInfo.rb +133 -121
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +1 -1
  21. data/lib/adiwg/mdtranslator/version.rb +4 -1
  22. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_attribute.rb +178 -0
  23. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dataDomain.rb +122 -0
  24. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dictionary.rb +66 -0
  25. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_digitalForm.rb +81 -0
  26. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_distribution.rb +156 -0
  27. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_entityDetail.rb +78 -0
  28. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_entityOverview.rb +48 -0
  29. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_fgdc.rb +41 -4
  30. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_metadataInfo.rb +215 -0
  31. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_offlineOption.rb +86 -0
  32. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_onlineOption.rb +77 -0
  33. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_orderProcess.rb +100 -0
  34. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_timePeriod.rb +9 -7
  35. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_transferInfo.rb +135 -0
  36. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +4 -4
  37. data/lib/adiwg/mdtranslator/writers/html/sections/html_distribution.rb +18 -0
  38. data/lib/adiwg/mdtranslator/writers/html/sections/html_domainItem.rb +18 -3
  39. data/lib/adiwg/mdtranslator/writers/html/sections/html_metadataInfo.rb +20 -0
  40. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +1 -1
  41. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_listedValue.rb +14 -0
  42. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb +21 -2
  43. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distribution.rb +44 -44
  44. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_legalConstraints.rb +67 -66
  45. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_mdIdentifier.rb +53 -54
  46. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +51 -23
  47. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +1 -1
  48. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_distribution.rb +2 -0
  49. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domainItem.rb +4 -0
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadataInfo.rb +2 -0
  51. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_rights.rb +7 -1
  52. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +12 -1
  53. metadata +16 -4
@@ -121,6 +121,7 @@ module ADIWG
121
121
  end
122
122
 
123
123
  # entity attribute 5.1.2.7 (attrvai) - attribute value accuracy information
124
+ # -> not mapped
124
125
 
125
126
  # entity attribute 5.1.2.7.1 (attrva) - attribute value accuracy
126
127
  # -> not mapped
@@ -16,6 +16,30 @@ module ADIWG
16
16
 
17
17
  module Contact
18
18
 
19
+ def self.add_phone(hContact, number, type)
20
+
21
+ # instance classes needed in script
22
+ intMetadataClass = InternalMetadata.new
23
+
24
+ # test if phone number already exists for this contact
25
+ hPhone = intMetadataClass.newPhone
26
+ newPhone = true
27
+ hContact[:phones].each do |hOld|
28
+ if hOld[:phoneNumber] == number
29
+ newPhone = false
30
+ hPhone = hOld
31
+ end
32
+ end
33
+ if newPhone
34
+ hContact[:phones] << hPhone
35
+ end
36
+ hPhone[:phoneNumber] = number
37
+ unless hPhone[:phoneServiceTypes].include?(type)
38
+ hPhone[:phoneServiceTypes] << type
39
+ end
40
+
41
+ end
42
+
19
43
  def self.unpack(xContact, hResponseObj)
20
44
 
21
45
  # instance classes needed in script
@@ -63,10 +87,16 @@ module ADIWG
63
87
  hContact = Fgdc.get_contact_by_id(personId) if contactType == 'person'
64
88
  hContact = Fgdc.get_contact_by_id(orgId) if contactType == 'organization'
65
89
 
90
+ # CAUTION: the contact being processed may have been added previously.
91
+ # check that addresses, phones, emails, org members, hours of service
92
+ # were not previous defined for this contact.
93
+
66
94
  # contact - member of organization
67
95
  if contactType == 'person'
68
96
  unless orgId.nil?
69
- hContact[:memberOfOrgs] << orgId
97
+ unless hContact.include?(orgId)
98
+ hContact[:memberOfOrgs] << orgId
99
+ end
70
100
  end
71
101
  end
72
102
 
@@ -111,7 +141,27 @@ module ADIWG
111
141
  country = xAddress.xpath('./country').text
112
142
  hAddress[:country] = country unless country.empty?
113
143
 
114
- hContact[:addresses] << hAddress
144
+ # test if new address before adding to contact
145
+ saveAddress = true
146
+ hContact[:addresses].each do |hOld|
147
+ isSame = true
148
+ isSame = false unless hAddress[:deliveryPoints].length == hOld[:deliveryPoints].length
149
+ if hAddress[:deliveryPoints].length == hOld[:deliveryPoints].length
150
+ (1..hAddress[:deliveryPoints].length).each do |x|
151
+ isSame = false unless hAddress[:deliveryPoints][x] == hOld[:deliveryPoints][x]
152
+ end
153
+ end
154
+ isSame = false unless hAddress[:city] == hOld[:city]
155
+ isSame = false unless hAddress[:adminArea] == hOld[:adminArea]
156
+ isSame = false unless hAddress[:postalCode] == hOld[:postalCode]
157
+ isSame = false unless hAddress[:country] == hOld[:country]
158
+ if isSame
159
+ saveAddress = false
160
+ break
161
+ end
162
+ end
163
+
164
+ hContact[:addresses] << hAddress if saveAddress
115
165
 
116
166
  end
117
167
  end
@@ -122,10 +172,7 @@ module ADIWG
122
172
  axVoice.each do |xPhone|
123
173
  phone = xPhone.text
124
174
  unless phone.empty?
125
- hPhone = intMetadataClass.newPhone
126
- hPhone[:phoneNumber] = phone
127
- hPhone[:phoneServiceTypes] << 'voice'
128
- hContact[:phones] << hPhone
175
+ add_phone(hContact, phone, 'voice')
129
176
  end
130
177
  end
131
178
  end
@@ -136,10 +183,7 @@ module ADIWG
136
183
  axTDD.each do |xPhone|
137
184
  phone = xPhone.text
138
185
  unless phone.empty?
139
- hPhone = intMetadataClass.newPhone
140
- hPhone[:phoneNumber] = phone
141
- hPhone[:phoneServiceTypes] << 'tty'
142
- hContact[:phones] << hPhone
186
+ add_phone(hContact, phone, 'tty')
143
187
  end
144
188
  end
145
189
  end
@@ -150,10 +194,7 @@ module ADIWG
150
194
  axFax.each do |xPhone|
151
195
  phone = xPhone.text
152
196
  unless phone.empty?
153
- hPhone = intMetadataClass.newPhone
154
- hPhone[:phoneNumber] = phone
155
- hPhone[:phoneServiceTypes] << 'facsimile'
156
- hContact[:phones] << hPhone
197
+ add_phone(hContact, phone, 'facsimile')
157
198
  end
158
199
  end
159
200
  end
@@ -164,14 +205,20 @@ module ADIWG
164
205
  axEmail.each do |xEmail|
165
206
  email = xEmail.text
166
207
  unless email.empty?
167
- hContact[:eMailList] << email
208
+ unless hContact[:eMailList].include?(email)
209
+ hContact[:eMailList] << email
210
+ end
168
211
  end
169
212
  end
170
213
  end
171
214
 
172
215
  # contact 10.9 (hours) - hours of service
173
216
  hours = xContactInfo.xpath('./hours').text
174
- hContact[:hoursOfService] << hours unless hours.empty?
217
+ unless hours.empty?
218
+ unless hContact[:hoursOfService].include?(hours)
219
+ hContact[:hoursOfService] << hours
220
+ end
221
+ end
175
222
 
176
223
  # contact 10.10 (cntinst) - contact instructions
177
224
  instruct = xContactInfo.xpath('./cntinst').text
@@ -18,7 +18,7 @@ module ADIWG
18
18
 
19
19
  module Distribution
20
20
 
21
- def self.unpack(xDistribution, hResourceInfo, hResponseObj)
21
+ def self.unpack(xDistribution, hResponseObj)
22
22
 
23
23
  # instance classes needed in script
24
24
  intMetadataClass = InternalMetadata.new
@@ -44,15 +44,10 @@ module ADIWG
44
44
  end
45
45
 
46
46
  # distribution 6.3 (distliab) - distribution liability
47
- # -> resourceInfo.constraints.legal.otherConstraint
48
- constraint = xDistribution.xpath('./distliab').text
49
- unless constraint.empty?
50
- hConstraint = intMetadataClass.newConstraint
51
- hConstraint[:type] = 'legal'
52
- hLegal = intMetadataClass.newLegalConstraint
53
- hLegal[:otherCons] << constraint
54
- hConstraint[:legalConstraint] = hLegal
55
- hResourceInfo[:constraints] << hConstraint
47
+ # -> distribution.liabilityStatement
48
+ liability = xDistribution.xpath('./distliab').text
49
+ unless liability.empty?
50
+ hDistribution[:liabilityStatement] = liability
56
51
  end
57
52
 
58
53
  # distribution 6.4 (stdorder) - standard order process []
@@ -73,14 +68,10 @@ module ADIWG
73
68
  end
74
69
 
75
70
  # distribution 6.6 (techpreq) - technical prerequisites
76
- # -> distribution.description {+=}
71
+ # -> distribution.technicalPrerequisite
77
72
  techPre = xDistribution.xpath('./techpreq').text
78
73
  unless techPre.empty?
79
- if hDistribution[:description].nil?
80
- hDistribution[:description] = techPre
81
- else
82
- hDistribution[:description] += '\n\n Technical Prerequisites: ' + techPre
83
- end
74
+ hDistribution[:technicalPrerequisite] = techPre
84
75
  end
85
76
 
86
77
  # distribution 6.7 (availabl) - available time period {time period}
@@ -22,7 +22,7 @@ module ADIWG
22
22
  intMetadataClass = InternalMetadata.new
23
23
 
24
24
  # entity attribute 5.1.1 (enttype) - definition and description set
25
- # also search for (enttyp); Metavist and USGS fgdc validator use 'enttyp'
25
+ # also search for (enttype); Metavist and USGS fgdc validator use 'enttyp'
26
26
  xEntity = xDetail.xpath('./enttype')
27
27
  if xEntity.empty?
28
28
  xEntity = xDetail.xpath('./enttyp')
@@ -21,6 +21,7 @@ module ADIWG
21
21
  intMetadataClass = InternalMetadata.new
22
22
  hEntity = intMetadataClass.newEntity
23
23
  hEntity[:entityId] = UUIDTools::UUID.random_create.to_s
24
+ hEntity[:entityName] = 'Entity Overview'
24
25
  hEntity[:entityCode] = 'overview'
25
26
 
26
27
  # entity attribute 5.2.1 (eaover) - entity attribute overview
@@ -2,6 +2,7 @@
2
2
  # unpack fgdc entity enumerated domain
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-01-25 add support for enumerated domain value definition source
5
6
  # Stan Smith 2017-09-06 original script
6
7
 
7
8
  require 'uuidtools'
@@ -47,7 +48,12 @@ module ADIWG
47
48
  end
48
49
 
49
50
  # entity attribute 5.1.2.4.1.3 (edomvds) - enumerated domain value definition source
50
- # -> not mapped
51
+ source = xValue.xpath('./edomvds').text
52
+ unless source.empty?
53
+ hCitation = intMetadataClass.newCitation
54
+ hCitation[:title] = source
55
+ hItem[:itemReference] = hCitation
56
+ end
51
57
 
52
58
  hDomain[:domainItems] << hItem
53
59
 
@@ -87,7 +87,7 @@ module ADIWG
87
87
  axDistribution = xMetadata.xpath('./distinfo')
88
88
  unless axDistribution.empty?
89
89
  axDistribution.each do |xDistribution|
90
- hDistribution = Distribution.unpack(xDistribution, hResourceInfo, hResponseObj)
90
+ hDistribution = Distribution.unpack(xDistribution, hResponseObj)
91
91
  unless hDistribution.nil?
92
92
  hMetadata[:distributorInfo] << hDistribution
93
93
  end
@@ -97,7 +97,7 @@ module ADIWG
97
97
  # metadata (metainfo 7) - metadata reference (required)
98
98
  xMetaInfo = xMetadata.xpath('./metainfo')
99
99
  unless xMetaInfo.empty?
100
- hMetadataInfo = MetadataInformation.unpack(xMetaInfo, hResourceInfo, hResponseObj)
100
+ hMetadataInfo = MetadataInformation.unpack(xMetaInfo, hResponseObj)
101
101
  unless hMetadataInfo.nil?
102
102
  hMetadata[:metadataInfo] = hMetadataInfo
103
103
  end
@@ -121,7 +121,10 @@ module ADIWG
121
121
  # identification information bio (taxonomy) - taxonomic information
122
122
  xTaxonomy = xIdInfo.xpath('./taxonomy')
123
123
  unless xTaxonomy.empty?
124
- Taxonomy.unpack(xTaxonomy, hResourceInfo, hResponseObj)
124
+ hTaxonomy = Taxonomy.unpack(xTaxonomy, hResourceInfo, hResponseObj)
125
+ unless hTaxonomy.nil?
126
+ hResourceInfo[:taxonomy] = hTaxonomy
127
+ end
125
128
  end
126
129
 
127
130
  # identification information 1.7 (accconst) - access constraints
@@ -2,6 +2,7 @@
2
2
  # unpack fgdc metadata information
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-01-27 move constraints to metadataConstraints
5
6
  # Stan Smith 2017-08-15 original script
6
7
 
7
8
  require 'nokogiri'
@@ -16,7 +17,7 @@ module ADIWG
16
17
 
17
18
  module MetadataInformation
18
19
 
19
- def self.unpack(xMetaInfo, hResourceInfo, hResponseObj)
20
+ def self.unpack(xMetaInfo, hResponseObj)
20
21
 
21
22
  # instance classes needed in script
22
23
  intMetadataClass = InternalMetadata.new
@@ -92,7 +93,7 @@ module ADIWG
92
93
  hConstraint = intMetadataClass.newConstraint
93
94
  hConstraint[:type] = 'legal'
94
95
  hConstraint[:legalConstraint] = hLegal
95
- hResourceInfo[:constraints] << hConstraint
96
+ hMetadataInfo[:metadataConstraints] << hConstraint
96
97
  end
97
98
 
98
99
  # metadata information 7.10 (metsi) - metadata security information
@@ -127,7 +128,7 @@ module ADIWG
127
128
  hConstraint = intMetadataClass.newConstraint
128
129
  hConstraint[:type] = 'security'
129
130
  hConstraint[:securityConstraint] = hSecurity
130
- hResourceInfo[:constraints] << hConstraint
131
+ hMetadataInfo[:metadataConstraints] << hConstraint
131
132
  end
132
133
 
133
134
  end
@@ -21,25 +21,29 @@ module ADIWG
21
21
  intMetadataClass = InternalMetadata.new
22
22
  hFormat = intMetadataClass.newResourceFormat
23
23
  hSpecification = intMetadataClass.newCitation
24
+ hIdentifier = intMetadataClass.newIdentifier
25
+ hSpecification[:identifiers] << hIdentifier
24
26
  hFormat[:formatSpecification] = hSpecification
25
27
  hTransfer[:distributionFormats] << hFormat
26
28
 
27
29
  # distribution 6.4.2.1.1 (formname) - format name
28
- # -> distribution.distributor.transferOption.distributionFormat.formatSpecification.title
29
- title = xTranInfo.xpath('./formname').text
30
- unless title.empty?
31
- hSpecification[:title] = title
30
+ # -> transferOption.distributionFormat.formatSpecification.title
31
+ # -> transferOption.distributionFormat.formatSpecification.identifier[].identifier
32
+ formName = xTranInfo.xpath('./formname').text
33
+ unless formName.empty?
34
+ hSpecification[:title] = formName
35
+ hSpecification[:identifiers][0][:identifier] = formName
32
36
  end
33
37
 
34
38
  # distribution 6.4.2.1.2 (formvern) - format version number
35
- # -> distribution.distributor.transferOption.distributionFormat.formatSpecification.edition
39
+ # -> transferOption.distributionFormat.formatSpecification.edition
36
40
  version = xTranInfo.xpath('./formvern').text
37
41
  unless version.empty?
38
42
  hSpecification[:edition] = version
39
43
  end
40
44
 
41
45
  # distribution 6.4.2.1.3 (formverd) - format version date
42
- # -> distribution.distributor.transferOption.distributionFormat.formatSpecification.date(version)
46
+ # -> transferOption.distributionFormat.formatSpecification.date(version)
43
47
  date = xTranInfo.xpath('./formverd').text
44
48
  unless date.empty?
45
49
  hDate = Date.unpack(date, '', 'revision', hResponseObj)
@@ -49,31 +53,31 @@ module ADIWG
49
53
  end
50
54
 
51
55
  # distribution 6.4.2.1.4 (formspec) - format specification
52
- # -> distribution.distributor.transferOption.distributionFormat.formatSpecification.otherCitationDetails
56
+ # -> transferOption.distributionFormat.formatSpecification.title
53
57
  specification = xTranInfo.xpath('./formspec').text
54
58
  unless specification.empty?
55
- hSpecification[:otherDetails] << specification
59
+ hSpecification[:title] = specification
56
60
  end
57
61
 
58
62
  # distribution bio (asciistr) - ASCII file specification
59
63
  # -> not mapped; cannot reliably merge with entity-attribute definition
60
64
 
61
65
  # distribution 6.4.2.1.5 (formcont) - format information content
62
- # -> distribution.distributor.transferOption.distributionFormat.formatSpecification.otherCitationDetails
66
+ # -> transferOption.distributionFormat.formatSpecification.otherCitationDetails
63
67
  specification = xTranInfo.xpath('./formcont').text
64
68
  unless specification.empty?
65
69
  hSpecification[:otherDetails] << specification
66
70
  end
67
71
 
68
72
  # distribution 6.4.2.1.6 (filedec) - file decompression technique
69
- # -> distribution.distributor.transferOption.distributionFormat.compressionMethod
73
+ # -> transferOption.distributionFormat.compressionMethod
70
74
  compress = xTranInfo.xpath('./filedec').text
71
75
  unless compress.empty?
72
76
  hFormat[:compressionMethod] = compress
73
77
  end
74
78
 
75
79
  # distribution 6.4.2.1.7 (transize) - file transfer size in MB
76
- # -> distribution.distributor.transferOption.transferSize
80
+ # -> transferOption.transferSize
77
81
  size = xTranInfo.xpath('./transize').text
78
82
  unless size.empty?
79
83
  hTransfer[:transferSize] = size.to_i
@@ -13,151 +13,151 @@ require_relative 'module_legalConstraint'
13
13
  require_relative 'module_securityConstraint'
14
14
 
15
15
  module ADIWG
16
- module Mdtranslator
17
- module Readers
18
- module MdJson
19
-
20
- module Constraint
21
-
22
- def self.unpack(hConstraint, responseObj)
23
-
24
-
25
- # return nil object if input is empty
26
- if hConstraint.empty?
27
- responseObj[:readerExecutionMessages] << 'Constraint object is empty'
28
- responseObj[:readerExecutionPass] = false
29
- return nil
16
+ module Mdtranslator
17
+ module Readers
18
+ module MdJson
19
+
20
+ module Constraint
21
+
22
+ def self.unpack(hConstraint, responseObj)
23
+
24
+
25
+ # return nil object if input is empty
26
+ if hConstraint.empty?
27
+ responseObj[:readerExecutionMessages] << 'Constraint object is empty'
28
+ responseObj[:readerExecutionPass] = false
29
+ return nil
30
+ end
31
+
32
+ # instance classes needed in script
33
+ intMetadataClass = InternalMetadata.new
34
+ intConstraint = intMetadataClass.newConstraint
35
+
36
+ # constraint - type (required)
37
+ type = nil
38
+ if hConstraint.has_key?('type')
39
+ if hConstraint['type'] != ''
40
+ type = hConstraint['type']
41
+ if %w{ use legal security }.one? {|word| word == type}
42
+ intConstraint[:type] = hConstraint['type']
43
+ else
44
+ responseObj[:readerExecutionMessages] << 'Constraint type must be use, legal, or security'
45
+ responseObj[:readerExecutionPass] = false
46
+ return nil
30
47
  end
31
-
32
- # instance classes needed in script
33
- intMetadataClass = InternalMetadata.new
34
- intConstraint = intMetadataClass.newConstraint
35
-
36
- # constraint - type (required)
37
- type = nil
38
- if hConstraint.has_key?('type')
39
- if hConstraint['type'] != ''
40
- type = hConstraint['type']
41
- if %w{ use legal security }.one? { |word| word == type }
42
- intConstraint[:type] = hConstraint['type']
43
- else
44
- responseObj[:readerExecutionMessages] << 'Constraint type must be use, legal, or security'
45
- responseObj[:readerExecutionPass] = false
46
- return nil
47
- end
48
- end
48
+ end
49
+ end
50
+ if intConstraint[:type].nil? || intConstraint[:type] == ''
51
+ responseObj[:readerExecutionMessages] << 'Constraint type declaration is missing'
52
+ responseObj[:readerExecutionPass] = false
53
+ return nil
54
+ end
55
+
56
+ # constraint - use limitation [] (required if type='use')
57
+ if hConstraint.has_key?('useLimitation')
58
+ hConstraint['useLimitation'].each do |item|
59
+ if item != ''
60
+ intConstraint[:useLimitation] << item
49
61
  end
50
- if intConstraint[:type].nil? || intConstraint[:type] == ''
51
- responseObj[:readerExecutionMessages] << 'Constraint type declaration is missing'
52
- responseObj[:readerExecutionPass] = false
53
- return nil
62
+ end
63
+ end
64
+
65
+ # constraint - scope
66
+ if hConstraint.has_key?('scope')
67
+ hObject = hConstraint['scope']
68
+ unless hObject.empty?
69
+ hReturn = Scope.unpack(hObject, responseObj)
70
+ unless hReturn.nil?
71
+ intConstraint[:scope] = hReturn
54
72
  end
55
-
56
- # constraint - use limitation [] (required if type='use')
57
- if hConstraint.has_key?('useLimitation')
58
- hConstraint['useLimitation'].each do |item|
59
- if item != ''
60
- intConstraint[:useLimitation] << item
61
- end
62
- end
73
+ end
74
+ end
75
+
76
+ # constraint - graphic [graphic]
77
+ if hConstraint.has_key?('graphic')
78
+ aGraphic = hConstraint['graphic']
79
+ aGraphic.each do |item|
80
+ hGraphic = Graphic.unpack(item, responseObj)
81
+ unless hGraphic.nil?
82
+ intConstraint[:graphic] << hGraphic
63
83
  end
64
-
65
- # constraint - scope
66
- if hConstraint.has_key?('scope')
67
- hObject = hConstraint['scope']
68
- unless hObject.empty?
69
- hReturn = Scope.unpack(hObject, responseObj)
70
- unless hReturn.nil?
71
- intConstraint[:scope] = hReturn
72
- end
73
- end
84
+ end
85
+ end
86
+
87
+ # constraint - reference [citation]
88
+ if hConstraint.has_key?('reference')
89
+ aReference = hConstraint['reference']
90
+ aReference.each do |item|
91
+ hReference = Citation.unpack(item, responseObj)
92
+ unless hReference.nil?
93
+ intConstraint[:reference] << hReference
74
94
  end
75
-
76
- # constraint - graphic [graphic]
77
- if hConstraint.has_key?('graphic')
78
- aGraphic = hConstraint['graphic']
79
- aGraphic.each do |item|
80
- hGraphic = Graphic.unpack(item, responseObj)
81
- unless hGraphic.nil?
82
- intConstraint[:graphic] << hGraphic
83
- end
84
- end
95
+ end
96
+ end
97
+
98
+ # constraint - releasability
99
+ if hConstraint.has_key?('releasability')
100
+ hObject = hConstraint['releasability']
101
+ unless hObject.empty?
102
+ hReturn = Releasability.unpack(hObject, responseObj)
103
+ unless hReturn.nil?
104
+ intConstraint[:releasability] = hReturn
85
105
  end
86
-
87
- # constraint - reference [citation]
88
- if hConstraint.has_key?('reference')
89
- aReference = hConstraint['reference']
90
- aReference.each do |item|
91
- hReference = Citation.unpack(item, responseObj)
92
- unless hReference.nil?
93
- intConstraint[:reference] << hReference
94
- end
95
- end
106
+ end
107
+ end
108
+
109
+ # constraint - responsible party []
110
+ if hConstraint.has_key?('responsibleParty')
111
+ aRParty = hConstraint['responsibleParty']
112
+ aRParty.each do |item|
113
+ hParty = ResponsibleParty.unpack(item, responseObj)
114
+ unless hParty.nil?
115
+ intConstraint[:responsibleParty] << hParty
96
116
  end
97
-
98
- # constraint - releasability
99
- if hConstraint.has_key?('releasability')
100
- hObject = hConstraint['releasability']
101
- unless hObject.empty?
102
- hReturn = Releasability.unpack(hObject, responseObj)
103
- unless hReturn.nil?
104
- intConstraint[:releasability] = hReturn
105
- end
106
- end
107
- end
108
-
109
- # constraint - responsible party []
110
- if hConstraint.has_key?('responsibleParty')
111
- aRParty = hConstraint['responsibleParty']
112
- aRParty.each do |item|
113
- hParty = ResponsibleParty.unpack(item, responseObj)
114
- unless hParty.nil?
115
- intConstraint[:responsibleParty] << hParty
116
- end
117
- end
118
- end
119
-
120
- if type == 'legal'
121
- if hConstraint.has_key?('legal')
122
- hObject = hConstraint['legal']
123
- unless hObject.empty?
124
- hReturn = LegalConstraint.unpack(hObject, responseObj)
125
- unless hReturn.nil?
126
- intConstraint[:legalConstraint] = hReturn
127
- end
128
- end
129
- end
130
- if intConstraint[:legalConstraint].empty?
131
- responseObj[:readerExecutionMessages] << 'Legal Constraint object is missing or empty'
132
- responseObj[:readerExecutionPass] = false
133
- return nil
134
- end
117
+ end
118
+ end
119
+
120
+ if type == 'legal'
121
+ if hConstraint.has_key?('legal')
122
+ hObject = hConstraint['legal']
123
+ unless hObject.empty?
124
+ hReturn = LegalConstraint.unpack(hObject, responseObj)
125
+ unless hReturn.nil?
126
+ intConstraint[:legalConstraint] = hReturn
127
+ end
135
128
  end
136
-
137
- if type == 'security'
138
- if hConstraint.has_key?('security')
139
- hObject = hConstraint['security']
140
- unless hObject.empty?
141
- hReturn = SecurityConstraint.unpack(hObject, responseObj)
142
- unless hReturn.nil?
143
- intConstraint[:securityConstraint] = hReturn
144
- end
145
- end
146
- end
147
- if intConstraint[:securityConstraint].empty?
148
- responseObj[:readerExecutionMessages] << 'Security Constraint object is missing or empty'
149
- responseObj[:readerExecutionPass] = false
150
- return nil
151
- end
129
+ end
130
+ if intConstraint[:legalConstraint].empty?
131
+ responseObj[:readerExecutionMessages] << 'Legal Constraint object is missing or empty'
132
+ responseObj[:readerExecutionPass] = false
133
+ return nil
134
+ end
135
+ end
136
+
137
+ if type == 'security'
138
+ if hConstraint.has_key?('security')
139
+ hObject = hConstraint['security']
140
+ unless hObject.empty?
141
+ hReturn = SecurityConstraint.unpack(hObject, responseObj)
142
+ unless hReturn.nil?
143
+ intConstraint[:securityConstraint] = hReturn
144
+ end
152
145
  end
146
+ end
147
+ if intConstraint[:securityConstraint].empty?
148
+ responseObj[:readerExecutionMessages] << 'Security Constraint object is missing or empty'
149
+ responseObj[:readerExecutionPass] = false
150
+ return nil
151
+ end
152
+ end
153
153
 
154
- return intConstraint
154
+ return intConstraint
155
155
 
156
- end
157
-
158
- end
156
+ end
159
157
 
160
158
  end
161
- end
162
- end
159
+
160
+ end
161
+ end
162
+ end
163
163
  end