adiwg-mdtranslator 2.15.0 → 2.18.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +29 -2
  3. data/Rakefile +9 -12
  4. data/adiwg-mdtranslator.gemspec +2 -2
  5. data/lib/adiwg/mdtranslator/internal/acquisition.json +108 -0
  6. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +278 -18
  7. data/lib/adiwg/mdtranslator/internal/qualityReport.json +64 -0
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +6 -2
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +5 -2
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +11 -1
  11. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +4 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader_messages_eng.yml +15 -0
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_algorithm.rb +65 -0
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_attribute.rb +12 -0
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb +18 -2
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georectifiedRepresentation.rb +9 -0
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georeferenceableRepresentation.rb +9 -0
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gridRepresentation.rb +10 -0
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_mdJson.rb +7 -1
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_nominalResolution.rb +78 -0
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_onlineResource.rb +25 -10
  22. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_party.rb +9 -2
  23. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processReport.rb +66 -0
  24. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +35 -9
  25. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processing.rb +103 -0
  26. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_rangeElementDescription.rb +38 -0
  27. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb +27 -2
  28. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorRepresentation.rb +10 -0
  29. data/lib/adiwg/mdtranslator/version.rb +6 -1
  30. data/lib/adiwg/mdtranslator/writers/html/sections/html_algorithm.rb +48 -0
  31. data/lib/adiwg/mdtranslator/writers/html/sections/html_georectifiedRepresentation.rb +12 -0
  32. data/lib/adiwg/mdtranslator/writers/html/sections/html_georeferenceableRepresentation.rb +13 -0
  33. data/lib/adiwg/mdtranslator/writers/html/sections/html_gridRepresentation.rb +13 -0
  34. data/lib/adiwg/mdtranslator/writers/html/sections/html_nominalResolution.rb +51 -0
  35. data/lib/adiwg/mdtranslator/writers/html/sections/html_onlineResource.rb +14 -0
  36. data/lib/adiwg/mdtranslator/writers/html/sections/html_processReport.rb +47 -0
  37. data/lib/adiwg/mdtranslator/writers/html/sections/html_processStep.rb +35 -8
  38. data/lib/adiwg/mdtranslator/writers/html/sections/html_processing.rb +89 -0
  39. data/lib/adiwg/mdtranslator/writers/html/sections/html_source.rb +27 -2
  40. data/lib/adiwg/mdtranslator/writers/html/sections/html_vectorRepresentation.rb +13 -0
  41. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +20 -15
  42. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +4 -4
  43. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_algorithm.rb +61 -0
  44. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_featureCatalog.rb +53 -0
  45. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_georectified.rb +9 -0
  46. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_georeferenceable.rb +10 -0
  47. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_grid.rb +11 -1
  48. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_identifier.rb +2 -2
  49. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_individual.rb +21 -0
  50. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_leProcessStep.rb +167 -0
  51. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_leSource.rb +150 -0
  52. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_liProcessStep.rb +130 -0
  53. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_liSource.rb +126 -0
  54. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_lineage.rb +5 -4
  55. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_mdMetadata.rb +18 -3
  56. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_nominalResolution.rb +61 -0
  57. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_onlineResource.rb +19 -2
  58. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_organization.rb +23 -0
  59. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_partyIdentifier.rb +92 -0
  60. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processReport.rb +66 -0
  61. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processStep.rb +22 -101
  62. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processing.rb +110 -0
  63. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_rangeElementDescription.rb +45 -0
  64. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_sampleDimension.rb +8 -0
  65. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_source.rb +19 -95
  66. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_vectorRepresentation.rb +9 -0
  67. data/lib/adiwg/mdtranslator/writers/iso19115_1/iso19115_1_writer_messages_eng.yml +11 -0
  68. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_algorithm.rb +61 -0
  69. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_leProcessStep.rb +153 -0
  70. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_leSource.rb +134 -0
  71. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liProcessStep.rb +126 -0
  72. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liSource.rb +114 -0
  73. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineage.rb +13 -11
  74. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_nominalResolution.rb +61 -0
  75. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_onlineResource.rb +26 -20
  76. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processReport.rb +66 -0
  77. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processStep.rb +22 -96
  78. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processing.rb +110 -0
  79. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_source.rb +20 -82
  80. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomy.rb +2 -2
  81. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer_messages_eng.yml +9 -0
  82. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_algorithm.rb +31 -0
  83. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_attribute.rb +1 -0
  84. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_contact.rb +1 -0
  85. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_georectifiedRepresentation.rb +1 -0
  86. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_georeferenceableRepresentation.rb +1 -0
  87. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_gridRepresentation.rb +1 -0
  88. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_nominalResolution.rb +31 -0
  89. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +6 -3
  90. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processReport.rb +31 -0
  91. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +5 -0
  92. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processing.rb +37 -0
  93. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_source.rb +7 -2
  94. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_vectorRepresentation.rb +1 -0
  95. data/lib/adiwg/mdtranslator_cli.rb +1 -1
  96. metadata +45 -12
@@ -2,6 +2,7 @@
2
2
  # unpack fgdc entity and attribute
3
3
 
4
4
  # History:
5
+ # Stan Smith 2019-09-19 add citation title to dictionary name
5
6
  # Stan Smith 2017-08-15 original script
6
7
 
7
8
  require 'nokogiri'
@@ -16,15 +17,17 @@ module ADIWG
16
17
 
17
18
  module EntityAttribute
18
19
 
19
- def self.unpack(xEntity, hResponseObj)
20
+ def self.unpack(xEntity, title, hResponseObj)
20
21
 
21
22
  # instance classes needed in script
22
23
  intMetadataClass = InternalMetadata.new
23
24
  hDictionary = intMetadataClass.newDataDictionary
24
25
  hCitation = intMetadataClass.newCitation
25
- hCitation[:title] = 'FGDC EntityAttribute Section 5'
26
26
  hDictionary[:citation] = hCitation
27
27
 
28
+ # add dictionary title
29
+ hCitation[:title] = 'Data Dictionary for: ' + title
30
+
28
31
  # entity attribute 5.1 (detailed) - entity attribute detailed description
29
32
  axDetail = xEntity.xpath('./detailed')
30
33
  unless axDetail.empty?
@@ -2,6 +2,7 @@
2
2
  # unpack fgdc metadata
3
3
 
4
4
  # History:
5
+ # Stan Smith 2019-09-19 add citation title to dictionary name
5
6
  # Stan Smith 2017-08-10 original script
6
7
 
7
8
  require 'nokogiri'
@@ -48,9 +49,18 @@ module ADIWG
48
49
  @intObj[:schema] = hSchema
49
50
 
50
51
  # metadata (idinfo 1) - identification information (required)
52
+ title = ''
51
53
  xIdInfo = xMetadata.xpath('./idinfo')
52
54
  unless xIdInfo.empty?
53
55
  Identification.unpack(xIdInfo, intObj, hResponseObj)
56
+ xCitation = xIdInfo.xpath('./citation')
57
+ unless xCitation.empty?
58
+ xCiteInfo = xCitation.xpath('./citeinfo')
59
+ unless xCiteInfo.empty?
60
+ title = xCiteInfo.xpath('./title').text
61
+ end
62
+ end
63
+
54
64
  end
55
65
  if xIdInfo.empty?
56
66
  hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: identification information section (idinfo) missing'
@@ -77,7 +87,7 @@ module ADIWG
77
87
  # metadata (eainfo 5) - entity and attribute
78
88
  xEntity = xMetadata.xpath('./eainfo')
79
89
  unless xEntity.empty?
80
- hDictionary = EntityAttribute.unpack(xEntity, hResponseObj)
90
+ hDictionary = EntityAttribute.unpack(xEntity, title, hResponseObj)
81
91
  unless hDictionary.nil?
82
92
  @intObj[:dataDictionaries] << hDictionary
83
93
  end
@@ -43,6 +43,10 @@ module ADIWG
43
43
  return {}
44
44
  end
45
45
 
46
+ if hMdJson.is_a?(Array)
47
+ hMdJson = hMdJson.first
48
+ end
49
+
46
50
  # file must contain an mdJson object
47
51
  if hMdJson.empty?
48
52
  hResponseObj[:readerStructureMessages] << 'ERROR: mdJson reader: object is empty'
@@ -390,3 +390,18 @@ messageList:
390
390
  - {id: 942, message: "voucher repository is missing"}
391
391
 
392
392
  - {id: 950, message: "local projection object is empty"}
393
+
394
+ - {id: 960, message: "nominal resolution object is empty"}
395
+ - {id: 961, message: "nominal resolution object is missing required elements"}
396
+ - {id: 962, message: "nominal resolution cannot be both scanning and ground resolutions"}
397
+
398
+ - {id: 970, message: "algorithm object is empty"}
399
+ - {id: 971, message: "algorithm citation is missing"}
400
+ - {id: 972, message: "algorithm description is missing"}
401
+
402
+ - {id: 980, message: "process step report object is empty"}
403
+ - {id: 981, message: "process step report name is missing"}
404
+
405
+ - {id: 990, message: "processing object is empty"}
406
+ - {id: 991, message: "processing identifier is missing"}
407
+
@@ -0,0 +1,65 @@
1
+ # unpack algorithm
2
+ # Reader - ADIwg JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2019-09-23 original script
6
+
7
+ require_relative 'module_citation'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module MdJson
13
+
14
+ module Algorithm
15
+
16
+ def self.unpack(hAlgorithm, responseObj, inContext = nil)
17
+
18
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
19
+
20
+ # return nil object if input is empty
21
+ if hAlgorithm.empty?
22
+ @MessagePath.issueWarning(970, responseObj, inContext)
23
+ return nil
24
+ end
25
+
26
+ # instance classes needed in script
27
+ intMetadataClass = InternalMetadata.new
28
+ intAlgorithm = intMetadataClass.newAlgorithm
29
+
30
+ outContext = 'algorithm'
31
+ outContext = inContext + ' > ' + outContext unless inContext.nil?
32
+
33
+ # algorithm - citation (required)
34
+ if hAlgorithm.has_key?('citation')
35
+ unless hAlgorithm['citation'].empty?
36
+ hReturn = Citation.unpack(hAlgorithm['citation'], responseObj, outContext)
37
+ unless hReturn.nil?
38
+ intAlgorithm[:citation] = hReturn
39
+ end
40
+ end
41
+ end
42
+ if intAlgorithm[:citation].empty?
43
+ @MessagePath.issueWarning(971, responseObj, inContext)
44
+ end
45
+
46
+ # algorithm - description (required)
47
+ if hAlgorithm.has_key?('description')
48
+ unless hAlgorithm['description'] == ''
49
+ intAlgorithm[:description] = hAlgorithm['description']
50
+ end
51
+ end
52
+ if intAlgorithm[:description].nil?
53
+ @MessagePath.issueWarning(972, responseObj, inContext)
54
+ end
55
+
56
+ return intAlgorithm
57
+
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+ end
@@ -6,6 +6,8 @@
6
6
  # Stan Smith 2016-10-18 original script
7
7
 
8
8
  require_relative 'module_identifier'
9
+ require_relative 'module_rangeElementDescription'
10
+
9
11
 
10
12
  module ADIWG
11
13
  module Mdtranslator
@@ -101,6 +103,16 @@ module ADIWG
101
103
  end
102
104
  end
103
105
 
106
+ if hAttribute.has_key?('rangeElementDescriptions')
107
+ unless hAttribute['rangeElementDescriptions'].nil?
108
+ intAttGroup[:rangeElementDescriptions] = []
109
+
110
+ hAttribute['rangeElementDescriptions'].each do |item|
111
+ intAttGroup[:rangeElementDescriptions] << RangeElementDescription.unpack(item, responseObj, outContext)
112
+ end
113
+ end
114
+ end
115
+
104
116
  # attribute group - offset
105
117
  if hAttribute.has_key?('offset')
106
118
  unless hAttribute['offset'] == ''
@@ -9,6 +9,7 @@ require_relative 'module_onlineResource'
9
9
  require_relative 'module_phone'
10
10
  require_relative 'module_address'
11
11
  require_relative 'module_graphic'
12
+ require_relative 'module_identifier'
12
13
 
13
14
  module ADIWG
14
15
  module Mdtranslator
@@ -35,13 +36,28 @@ module ADIWG
35
36
 
36
37
  # contact - contact id (required)
37
38
  if hContact.has_key?('contactId')
38
- intContact[:contactId] = hContact['contactId']
39
- outContext = 'contact ID ' + hContact['contactId']
39
+ if hContact['contactId'].is_a?(Hash)
40
+ outContext = 'contact ID ' + hContact['contactId']['identifier']
41
+ intContact[:contactId] = hContact['contactId'].transform_keys(&:to_sym)
42
+ elsif hContact['contactId'].is_a?(String)
43
+ outContext = 'contact ID ' + hContact['contactId']
44
+ intContact[:contactId] = hContact['contactId']
45
+ end
40
46
  end
41
47
  if intContact[:contactId].nil? || intContact[:contactId] == ''
42
48
  @MessagePath.issueError(101, responseObj)
43
49
  end
44
50
 
51
+ if hContact.has_key?('externalIdentifiers')
52
+ aItems = hContact['externalIdentifiers']
53
+ aItems.each do |item|
54
+ hReturn = Identifier.unpack(item, responseObj, outContext)
55
+ unless hReturn.nil?
56
+ intContact[:externalIdentifiers] << hReturn
57
+ end
58
+ end
59
+ end
60
+
45
61
  # contact - is organization (required)
46
62
  if hContact.has_key?('isOrganization')
47
63
  if hContact['isOrganization'] === true
@@ -104,6 +104,15 @@ module ADIWG
104
104
  end
105
105
  end
106
106
 
107
+ if hGeoRec.has_key?('scope')
108
+ hGeoRec['scope'].each do |item|
109
+ scope = Scope.unpack(item, responseObj, inContext)
110
+ unless scope.nil?
111
+ intGeoRec[:scope] << scope
112
+ end
113
+ end
114
+ end
115
+
107
116
  return intGeoRec
108
117
 
109
118
  end
@@ -88,6 +88,15 @@ module ADIWG
88
88
  end
89
89
  end
90
90
 
91
+ if hGeoRef.has_key?('scope')
92
+ hGeoRef['scope'].each do |item|
93
+ scope = Scope.unpack(item, responseObj, inContext)
94
+ unless scope.nil?
95
+ intGeoRef[:scope] << scope
96
+ end
97
+ end
98
+ end
99
+
91
100
  return intGeoRef
92
101
 
93
102
  end
@@ -6,6 +6,7 @@
6
6
  # Stan Smith 2016-10-19 original script
7
7
 
8
8
  require_relative 'module_dimension'
9
+ require_relative 'module_scope'
9
10
 
10
11
  module ADIWG
11
12
  module Mdtranslator
@@ -71,6 +72,15 @@ module ADIWG
71
72
  end
72
73
  end
73
74
 
75
+ if hGrid.has_key?('scope')
76
+ hGrid['scope'].each do |item|
77
+ scope = Scope.unpack(item, responseObj, outContext)
78
+ unless scope.nil?
79
+ intGrid[:scope] << scope
80
+ end
81
+ end
82
+ end
83
+
74
84
  return intGrid
75
85
 
76
86
  end
@@ -123,7 +123,13 @@ module ADIWG
123
123
  contactType = nil
124
124
  contactName = nil
125
125
  @contacts.each_with_index do |contact, i|
126
- if contact[:contactId] == contactId
126
+ if contact[:contactId] == contactId ||
127
+ (
128
+ contact[:contactId].is_a?(Hash) &&
129
+ contactId.is_a?(Hash) &&
130
+ contact[:contactId][:identifier] == contactId['identifier']
131
+ )
132
+
127
133
  contactIndex = i
128
134
  if contact[:isOrganization]
129
135
  contactType = 'organization'
@@ -0,0 +1,78 @@
1
+ # unpack nominal resolution
2
+ # Reader - ADIwg JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2019-09-22 original script
6
+
7
+ require_relative 'module_measure'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module MdJson
13
+
14
+ module NominalResolution
15
+
16
+ def self.unpack(hResolution, responseObj, inContext = nil)
17
+
18
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
19
+
20
+ # return nil object if input is empty
21
+ if hResolution.empty?
22
+ @MessagePath.issueWarning(960, responseObj, inContext)
23
+ return nil
24
+ end
25
+
26
+ # instance classes needed in script
27
+ intMetadataClass = InternalMetadata.new
28
+ intResolution = intMetadataClass.newNominalResolution
29
+
30
+ outContext = 'nominal resolution'
31
+ outContext = inContext + ' > ' + outContext unless inContext.nil?
32
+
33
+ haveRequired = 0
34
+
35
+ # nominal resolution - scanning resolution (required if)
36
+ if hResolution.has_key?('scanningResolution')
37
+ hMeasure = hResolution['scanningResolution']
38
+ unless hMeasure.empty?
39
+ hMeasure['type'] = 'distance'
40
+ hReturn = Measure.unpack(hMeasure, responseObj, outContext)
41
+ unless hReturn.nil?
42
+ intResolution[:scanningResolution] = hReturn
43
+ haveRequired += 1
44
+ end
45
+ end
46
+ end
47
+
48
+ # nominal resolution - ground resolution (required if)
49
+ if hResolution.has_key?('groundResolution')
50
+ hMeasure = hResolution['groundResolution']
51
+ unless hMeasure.empty?
52
+ hMeasure['type'] = 'distance'
53
+ hReturn = Measure.unpack(hMeasure, responseObj, outContext)
54
+ unless hReturn.nil?
55
+ intResolution[:groundResolution] = hReturn
56
+ haveRequired += 1
57
+ end
58
+ end
59
+ end
60
+
61
+ unless haveRequired > 0
62
+ @MessagePath.issueError(961, responseObj, inContext)
63
+ end
64
+
65
+ if haveRequired == 2
66
+ @MessagePath.issueError(962, responseObj, inContext)
67
+ end
68
+
69
+ return intResolution
70
+
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
77
+ end
78
+ end
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON V1 to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-09-18 add applicationProfile and protocolRequest
5
6
  # Stan Smith 2018-06-22 refactored error and warning messaging
6
7
  # Stan Smith 2016-10-03 original script
7
8
  # Stan Smith 2015-07-14 refactored to remove global namespace constants
@@ -42,34 +43,48 @@ module ADIWG
42
43
  @MessagePath.issueError(601, responseObj, inContext)
43
44
  end
44
45
 
45
- # resource - web link protocol
46
- if hOnlineRes.has_key?('protocol')
47
- unless hOnlineRes['protocol'] == ''
48
- intOLRes[:olResProtocol] = hOnlineRes['protocol']
49
- end
50
- end
51
-
52
- # resource - web link name
46
+ # resource - name
53
47
  if hOnlineRes.has_key?('name')
54
48
  unless hOnlineRes['name'] == ''
55
49
  intOLRes[:olResName] = hOnlineRes['name']
56
50
  end
57
51
  end
58
52
 
59
- # resource - web link description
53
+ # resource - description
60
54
  if hOnlineRes.has_key?('description')
61
55
  unless hOnlineRes['description'] == ''
62
56
  intOLRes[:olResDesc] = hOnlineRes['description']
63
57
  end
64
58
  end
65
59
 
66
- # resource - web link function
60
+ # resource - unction
67
61
  if hOnlineRes.has_key?('function')
68
62
  unless hOnlineRes['function'] == ''
69
63
  intOLRes[:olResFunction] = hOnlineRes['function']
70
64
  end
71
65
  end
72
66
 
67
+ # resource - application profile
68
+ if hOnlineRes.has_key?('applicationProfile')
69
+ unless hOnlineRes['applicationProfile'] == ''
70
+ intOLRes[:olResApplicationProfile] = hOnlineRes['applicationProfile']
71
+ end
72
+ end
73
+
74
+ # resource - protocol
75
+ if hOnlineRes.has_key?('protocol')
76
+ unless hOnlineRes['protocol'] == ''
77
+ intOLRes[:olResProtocol] = hOnlineRes['protocol']
78
+ end
79
+ end
80
+
81
+ # resource - protocol request
82
+ if hOnlineRes.has_key?('protocolRequest')
83
+ unless hOnlineRes['protocolRequest'] == ''
84
+ intOLRes[:olResProtocolRequest] = hOnlineRes['protocolRequest']
85
+ end
86
+ end
87
+
73
88
  return intOLRes
74
89
  end
75
90
 
@@ -30,11 +30,18 @@ module ADIWG
30
30
  # load party with contact index, contact type, and name
31
31
  # return nil if contact ID does not exist in contact array
32
32
  if hParty.has_key?('contactId')
33
- intParty[:contactId] = hParty['contactId']
33
+ if hParty['contactId'].is_a?(Hash)
34
+ intParty[:contactId] = hParty['contactId'].transform_keys(&:to_sym)
35
+ context = hParty['contactId']['identifier']
36
+ elsif hParty['contactId'].is_a?(String)
37
+ intParty[:contactId] = hParty['contactId']
38
+ context = hParty['contactId']
39
+ end
40
+
34
41
  unless intParty[:contactId].nil? || intParty[:contactId] == ''
35
42
  hContact = @MessagePath.findContact(hParty['contactId'])
36
43
  if hContact[0].nil?
37
- outContext = 'contact ID ' + intParty[:contactId]
44
+ outContext = 'contact ID ' + context
38
45
  outContext = inContext + ' > ' + outContext unless inContext.nil?
39
46
  @MessagePath.issueError(622, responseObj, outContext)
40
47
  else
@@ -0,0 +1,66 @@
1
+ # unpack process step report
2
+ # Reader - ADIwg JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2019-09-23 original script
6
+
7
+ require_relative 'module_citation'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Readers
12
+ module MdJson
13
+
14
+ module ProcessStepReport
15
+
16
+ def self.unpack(hReport, responseObj, inContext = nil)
17
+
18
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
19
+
20
+ # return nil object if input is empty
21
+ if hReport.empty?
22
+ @MessagePath.issueWarning(980, responseObj, inContext)
23
+ return nil
24
+ end
25
+
26
+ # instance classes needed in script
27
+ intMetadataClass = InternalMetadata.new
28
+ intProcessReport = intMetadataClass.newProcessStepReport
29
+
30
+ outContext = 'process step report'
31
+ outContext = inContext + ' > ' + outContext unless inContext.nil?
32
+
33
+ # process step report - name (required)
34
+ if hReport.has_key?('name')
35
+ unless hReport['name'] == ''
36
+ intProcessReport[:name] = hReport['name']
37
+ end
38
+ end
39
+ if intProcessReport[:name].nil?
40
+ @MessagePath.issueWarning(981, responseObj, inContext)
41
+ end
42
+
43
+ # process step report - description
44
+ if hReport.has_key?('description')
45
+ unless hReport['description'] == ''
46
+ intProcessReport[:description] = hReport['description']
47
+ end
48
+ end
49
+
50
+ # process step report - file type
51
+ if hReport.has_key?('fileType')
52
+ unless hReport['fileType'] == ''
53
+ intProcessReport[:fileType] = hReport['fileType']
54
+ end
55
+ end
56
+
57
+ return intProcessReport
58
+
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+ end
65
+ end
66
+ end
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2019-09-23 add LE_Source elements
5
6
  # Stan Smith 2018-06-22 refactored error and warning messaging
6
7
  # Stan Smith 2017-08-30 added support for process step sources
7
8
  # Stan Smith 2016-10-15 refactored for mdJson 2.0
@@ -14,6 +15,9 @@ require_relative 'module_timePeriod'
14
15
  require_relative 'module_responsibleParty'
15
16
  require_relative 'module_citation'
16
17
  require_relative 'module_scope'
18
+ require_relative 'module_source'
19
+ require_relative 'module_processing'
20
+ require_relative 'module_processReport'
17
21
 
18
22
  module ADIWG
19
23
  module Mdtranslator
@@ -48,9 +52,11 @@ module ADIWG
48
52
 
49
53
  # process step - description - (required)
50
54
  if hProcStep.has_key?('description')
51
- intProcStep[:description] = hProcStep['description']
55
+ unless hProcStep['description'] == ''
56
+ intProcStep[:description] = hProcStep['description']
57
+ end
52
58
  end
53
- if intProcStep[:description].nil? || intProcStep[:description] == ''
59
+ if intProcStep[:description].nil?
54
60
  @MessagePath.issueError(641, responseObj, inContext)
55
61
  end
56
62
 
@@ -63,16 +69,15 @@ module ADIWG
63
69
 
64
70
  # process step - time period
65
71
  if hProcStep.has_key?('timePeriod')
66
- hObject = hProcStep['timePeriod']
67
- unless hObject.empty?
68
- hReturn = TimePeriod.unpack(hObject, responseObj, outContext)
72
+ unless hProcStep['timePeriod'].empty?
73
+ hReturn = TimePeriod.unpack(hProcStep['timePeriod'], responseObj, outContext)
69
74
  unless hReturn.nil?
70
75
  intProcStep[:timePeriod] = hReturn
71
76
  end
72
77
  end
73
78
  end
74
79
 
75
- # process step - step processors [responsible party]
80
+ # process step - step processors [] {responsibility}
76
81
  if hProcStep.has_key?('processor')
77
82
  aProc = hProcStep['processor']
78
83
  aProc.each do |item|
@@ -83,7 +88,7 @@ module ADIWG
83
88
  end
84
89
  end
85
90
 
86
- # process step - reference [citation]
91
+ # process step - reference [] {citation}
87
92
  if hProcStep.has_key?('reference')
88
93
  aReference = hProcStep['reference']
89
94
  aReference.each do |item|
@@ -94,7 +99,7 @@ module ADIWG
94
99
  end
95
100
  end
96
101
 
97
- # process step - step sources [source]
102
+ # process step - step sources [] {source}
98
103
  if hProcStep.has_key?('stepSource')
99
104
  aSources = hProcStep['stepSource']
100
105
  aSources.each do |item|
@@ -105,7 +110,7 @@ module ADIWG
105
110
  end
106
111
  end
107
112
 
108
- # process step - step products [source]
113
+ # process step LE 'output' - step products [] {source}
109
114
  if hProcStep.has_key?('stepProduct')
110
115
  aSources = hProcStep['stepProduct']
111
116
  aSources.each do |item|
@@ -127,6 +132,27 @@ module ADIWG
127
132
  end
128
133
  end
129
134
 
135
+ # process step LE - processing information {processing}
136
+ if hProcStep.has_key?('processingInformation')
137
+ unless hProcStep['processingInformation'].empty?
138
+ hReturn = Processing.unpack(hProcStep['processingInformation'], responseObj, outContext)
139
+ unless hReturn.nil?
140
+ intProcStep[:processingInformation] = hReturn
141
+ end
142
+ end
143
+ end
144
+
145
+ # process step LE - report [] {processReport}
146
+ if hProcStep.has_key?('report')
147
+ aReports = hProcStep['report']
148
+ aReports.each do |item|
149
+ hReport = ProcessStepReport.unpack(item, responseObj, outContext)
150
+ unless hReport.nil?
151
+ intProcStep[:reports] << hReport
152
+ end
153
+ end
154
+ end
155
+
130
156
  return intProcStep
131
157
 
132
158
  end