adiwg-mdtranslator 2.1.2 → 2.2.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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +402 -0
  3. data/adiwg-mdtranslator.gemspec +1 -1
  4. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +7 -2
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +196 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +8 -0
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +1 -1
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +80 -26
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +13 -2
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_lineage.rb +58 -0
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_process.rb +101 -0
  12. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +21 -1
  13. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_security.rb +48 -0
  14. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_source.rb +83 -0
  15. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +10 -1
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_allocation.rb +92 -71
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_funding.rb +49 -43
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +113 -90
  19. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +2 -1
  20. data/lib/adiwg/mdtranslator/version.rb +2 -1
  21. data/lib/adiwg/mdtranslator/writers/html/sections/html_allocation.rb +23 -0
  22. data/lib/adiwg/mdtranslator/writers/html/sections/html_funding.rb +9 -0
  23. data/lib/adiwg/mdtranslator/writers/html/sections/html_processStep.rb +37 -0
  24. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processStep.rb +103 -91
  25. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_allocation.rb +7 -1
  26. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_funding.rb +4 -2
  27. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +6 -2
  28. metadata +11 -5
@@ -2,83 +2,104 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-10-30 original script
5
+ # Stan Smith 2017-08-30 refactored for mdJson schema 2.3
6
+ # Stan Smith 2016-10-30 original script
6
7
 
7
- module ADIWG
8
- module Mdtranslator
9
- module Readers
10
- module MdJson
11
-
12
- module Allocation
13
-
14
- def self.unpack(hAlloc, responseObj)
15
-
16
- # return nil object if input is empty
17
- if hAlloc.empty?
18
- responseObj[:readerExecutionMessages] << 'Allocation object is empty'
19
- responseObj[:readerExecutionPass] = false
20
- return nil
21
- end
22
-
23
- # instance classes needed in script
24
- intMetadataClass = InternalMetadata.new
25
- intAlloc = intMetadataClass.newAllocation
26
-
27
- # allocation - amount (required)
28
- if hAlloc.has_key?('amount')
29
- intAlloc[:amount] = hAlloc['amount']
30
- end
31
- if intAlloc[:amount].nil? || intAlloc[:amount] == ''
32
- responseObj[:readerExecutionMessages] << 'Allocation attribute is missing amount'
33
- responseObj[:readerExecutionPass] = false
34
- return nil
35
- end
36
-
37
- # allocation - currency (required)
38
- if hAlloc.has_key?('currency')
39
- intAlloc[:currency] = hAlloc['currency']
40
- end
41
- if intAlloc[:currency].nil? || intAlloc[:currency] == ''
42
- responseObj[:readerExecutionMessages] << 'Allocation attribute is missing currency'
43
- responseObj[:readerExecutionPass] = false
44
- return nil
45
- end
46
-
47
- # allocation - source ID {contactId}
48
- if hAlloc.has_key?('sourceId')
49
- if hAlloc['sourceId'] != ''
50
- intAlloc[:sourceId] = hAlloc['sourceId']
51
- end
52
- end
53
-
54
- # allocation - recipient ID {contactId}
55
- if hAlloc.has_key?('recipientId')
56
- if hAlloc['recipientId'] != ''
57
- intAlloc[:recipientId] = hAlloc['recipientId']
58
- end
59
- end
60
-
61
- # allocation - matching {Boolean}
62
- if hAlloc.has_key?('matching')
63
- if hAlloc['matching'] === true
64
- intAlloc[:matching] = hAlloc['matching']
65
- end
66
- end
8
+ require_relative 'module_onlineResource'
67
9
 
68
- # allocation - comment
69
- if hAlloc.has_key?('comment')
70
- if hAlloc['comment'] != ''
71
- intAlloc[:comment] = hAlloc['comment']
72
- end
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Readers
13
+ module MdJson
14
+
15
+ module Allocation
16
+
17
+ def self.unpack(hAlloc, responseObj)
18
+
19
+ # return nil object if input is empty
20
+ if hAlloc.empty?
21
+ responseObj[:readerExecutionMessages] << 'Allocation object is empty'
22
+ responseObj[:readerExecutionPass] = false
23
+ return nil
24
+ end
25
+
26
+ # instance classes needed in script
27
+ intMetadataClass = InternalMetadata.new
28
+ intAlloc = intMetadataClass.newAllocation
29
+
30
+ # allocation - id
31
+ if hAlloc.has_key?('sourceAllocationId')
32
+ if hAlloc['sourceAllocationId'] != ''
33
+ intAlloc[:id] = hAlloc['sourceAllocationId']
34
+ end
35
+ end
36
+
37
+ # allocation - amount (required)
38
+ if hAlloc.has_key?('amount')
39
+ intAlloc[:amount] = hAlloc['amount']
40
+ end
41
+ if intAlloc[:amount].nil? || intAlloc[:amount] == ''
42
+ responseObj[:readerExecutionMessages] << 'Allocation attribute is missing amount'
43
+ responseObj[:readerExecutionPass] = false
44
+ return nil
45
+ end
46
+
47
+ # allocation - currency (required)
48
+ if hAlloc.has_key?('currency')
49
+ intAlloc[:currency] = hAlloc['currency']
50
+ end
51
+ if intAlloc[:currency].nil? || intAlloc[:currency] == ''
52
+ responseObj[:readerExecutionMessages] << 'Allocation attribute is missing currency'
53
+ responseObj[:readerExecutionPass] = false
54
+ return nil
55
+ end
56
+
57
+ # allocation - source ID {contactId}
58
+ if hAlloc.has_key?('sourceId')
59
+ if hAlloc['sourceId'] != ''
60
+ intAlloc[:sourceId] = hAlloc['sourceId']
61
+ end
62
+ end
63
+
64
+ # allocation - recipient ID {contactId}
65
+ if hAlloc.has_key?('recipientId')
66
+ if hAlloc['recipientId'] != ''
67
+ intAlloc[:recipientId] = hAlloc['recipientId']
68
+ end
69
+ end
70
+
71
+ # allocation - matching {Boolean}
72
+ if hAlloc.has_key?('matching')
73
+ if hAlloc['matching'] === true
74
+ intAlloc[:matching] = hAlloc['matching']
75
+ end
76
+ end
77
+
78
+ # allocation - online resource [] {onlineResource}
79
+ if hAlloc.has_key?('onlineResource')
80
+ aOnlines = hAlloc['onlineResource']
81
+ aOnlines.each do |hOnline|
82
+ hReturn = OnlineResource.unpack(hOnline, responseObj)
83
+ unless hReturn.nil?
84
+ intAlloc[:onlineResources] << hReturn
73
85
  end
86
+ end
87
+ end
74
88
 
75
- return intAlloc
89
+ # allocation - comment
90
+ if hAlloc.has_key?('comment')
91
+ if hAlloc['comment'] != ''
92
+ intAlloc[:comment] = hAlloc['comment']
93
+ end
94
+ end
76
95
 
77
- end
96
+ return intAlloc
78
97
 
79
- end
98
+ end
80
99
 
81
100
  end
82
- end
83
- end
101
+
102
+ end
103
+ end
104
+ end
84
105
  end
@@ -2,66 +2,72 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-10-30 original script
5
+ # Stan Smith 2017-08-30 refactored for mdJson schema 2.3
6
+ # Stan Smith 2016-10-30 original script
6
7
 
7
8
  require_relative 'module_allocation'
8
9
  require_relative 'module_timePeriod'
9
10
 
10
11
  module ADIWG
11
- module Mdtranslator
12
- module Readers
13
- module MdJson
12
+ module Mdtranslator
13
+ module Readers
14
+ module MdJson
14
15
 
15
- module Funding
16
+ module Funding
16
17
 
17
- def self.unpack(hFunding, responseObj)
18
+ def self.unpack(hFunding, responseObj)
18
19
 
19
- # return nil object if input is empty
20
- if hFunding.empty?
21
- responseObj[:readerExecutionMessages] << 'Funding object is empty'
22
- responseObj[:readerExecutionPass] = false
23
- return nil
24
- end
20
+ # return nil object if input is empty
21
+ if hFunding.empty?
22
+ responseObj[:readerExecutionMessages] << 'Funding object is empty'
23
+ responseObj[:readerExecutionPass] = false
24
+ return nil
25
+ end
25
26
 
26
- # instance classes needed in script
27
- intMetadataClass = InternalMetadata.new
28
- intFunding = intMetadataClass.newFunding
27
+ # instance classes needed in script
28
+ intMetadataClass = InternalMetadata.new
29
+ intFunding = intMetadataClass.newFunding
29
30
 
30
- # funding - allocation []
31
- if hFunding.has_key?('allocation')
32
- aItems = hFunding['allocation']
33
- aItems.each do |item|
34
- hReturn = Allocation.unpack(item, responseObj)
35
- unless hReturn.nil?
36
- intFunding[:allocations] << hReturn
37
- end
38
- end
39
- end
31
+ # funding - description
32
+ if hFunding.has_key?('description')
33
+ intFunding[:description] = hFunding['description']
34
+ end
40
35
 
41
- # funding - timePeriod
42
- if hFunding.has_key?('timePeriod')
43
- hObject = hFunding['timePeriod']
44
- unless hObject.empty?
45
- hReturn = TimePeriod.unpack(hObject, responseObj)
46
- unless hReturn.nil?
47
- intFunding[:timePeriod] = hReturn
48
- end
49
- end
36
+ # funding - timePeriod
37
+ if hFunding.has_key?('timePeriod')
38
+ hObject = hFunding['timePeriod']
39
+ unless hObject.empty?
40
+ hReturn = TimePeriod.unpack(hObject, responseObj)
41
+ unless hReturn.nil?
42
+ intFunding[:timePeriod] = hReturn
50
43
  end
44
+ end
45
+ end
51
46
 
52
- if intFunding[:allocations].empty? && intFunding[:timePeriod].empty?
53
- responseObj[:readerExecutionMessages] << 'Funding must have either an allocation or timePeriod'
54
- responseObj[:readerExecutionPass] = false
55
- return nil
47
+ # funding - allocation []
48
+ if hFunding.has_key?('allocation')
49
+ aItems = hFunding['allocation']
50
+ aItems.each do |item|
51
+ hReturn = Allocation.unpack(item, responseObj)
52
+ unless hReturn.nil?
53
+ intFunding[:allocations] << hReturn
56
54
  end
55
+ end
56
+ end
57
57
 
58
- return intFunding
58
+ if intFunding[:allocations].empty? && intFunding[:timePeriod].empty?
59
+ responseObj[:readerExecutionMessages] << 'Funding must have either an allocation or timePeriod'
60
+ responseObj[:readerExecutionPass] = false
61
+ return nil
62
+ end
59
63
 
60
- end
64
+ return intFunding
61
65
 
62
- end
66
+ end
63
67
 
64
68
  end
65
- end
66
- end
69
+
70
+ end
71
+ end
72
+ end
67
73
  end
@@ -2,10 +2,11 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-10-15 refactored for mdJson 2.0
6
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
7
- # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
8
- # Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
5
+ # Stan Smith 2017-08-30 added support for process step sources
6
+ # Stan Smith 2016-10-15 refactored for mdJson 2.0
7
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
8
+ # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
9
+ # Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
9
10
  # Stan Smith 2013-11-26 original script
10
11
 
11
12
  require_relative 'module_timePeriod'
@@ -14,100 +15,122 @@ require_relative 'module_citation'
14
15
  require_relative 'module_scope'
15
16
 
16
17
  module ADIWG
17
- module Mdtranslator
18
- module Readers
19
- module MdJson
20
-
21
- module ProcessStep
22
-
23
- def self.unpack(hProcStep, responseObj)
24
-
25
- # return nil object if input is empty
26
- if hProcStep.empty?
27
- responseObj[:readerExecutionMessages] << 'Process Step object is empty'
28
- responseObj[:readerExecutionPass] = false
29
- return nil
30
- end
31
-
32
- # instance classes needed in script
33
- intMetadataClass = InternalMetadata.new
34
- intProcStep = intMetadataClass.newProcessStep
35
-
36
- # process step - step ID
37
- if hProcStep.has_key?('stepId')
38
- if hProcStep['stepId'] != ''
39
- intProcStep[:stepId] = hProcStep['stepId']
40
- end
41
- end
42
-
43
- # process step - description - required
44
- if hProcStep.has_key?('description')
45
- intProcStep[:description] = hProcStep['description']
18
+ module Mdtranslator
19
+ module Readers
20
+ module MdJson
21
+
22
+ module ProcessStep
23
+
24
+ def self.unpack(hProcStep, responseObj)
25
+
26
+ # return nil object if input is empty
27
+ if hProcStep.empty?
28
+ responseObj[:readerExecutionMessages] << 'Process Step object is empty'
29
+ responseObj[:readerExecutionPass] = false
30
+ return nil
31
+ end
32
+
33
+ # instance classes needed in script
34
+ intMetadataClass = InternalMetadata.new
35
+ intProcStep = intMetadataClass.newProcessStep
36
+
37
+ # process step - step ID
38
+ if hProcStep.has_key?('stepId')
39
+ if hProcStep['stepId'] != ''
40
+ intProcStep[:stepId] = hProcStep['stepId']
41
+ end
42
+ end
43
+
44
+ # process step - description - required
45
+ if hProcStep.has_key?('description')
46
+ intProcStep[:description] = hProcStep['description']
47
+ end
48
+ if intProcStep[:description].nil? || intProcStep[:description] == ''
49
+ responseObj[:readerExecutionMessages] << 'Process Step attribute description is missing'
50
+ responseObj[:readerExecutionPass] = false
51
+ return nil
52
+ end
53
+
54
+ # process step - rationale
55
+ if hProcStep.has_key?('rationale')
56
+ if hProcStep['rationale'] != ''
57
+ intProcStep[:rationale] = hProcStep['rationale']
58
+ end
59
+ end
60
+
61
+ # process step - time period
62
+ if hProcStep.has_key?('timePeriod')
63
+ hObject = hProcStep['timePeriod']
64
+ unless hObject.empty?
65
+ hReturn = TimePeriod.unpack(hObject, responseObj)
66
+ unless hReturn.nil?
67
+ intProcStep[:timePeriod] = hReturn
46
68
  end
47
- if intProcStep[:description].nil? || intProcStep[:description] == ''
48
- responseObj[:readerExecutionMessages] << 'Process Step attribute description is missing'
49
- responseObj[:readerExecutionPass] = false
50
- return nil
69
+ end
70
+ end
71
+
72
+ # process step - step processors [responsible party]
73
+ if hProcStep.has_key?('processor')
74
+ aProc = hProcStep['processor']
75
+ aProc.each do |item|
76
+ hParty = ResponsibleParty.unpack(item, responseObj)
77
+ unless hParty.nil?
78
+ intProcStep[:processors] << hParty
51
79
  end
52
-
53
- # process step - rationale
54
- if hProcStep.has_key?('rationale')
55
- if hProcStep['rationale'] != ''
56
- intProcStep[:rationale] = hProcStep['rationale']
57
- end
58
- end
59
-
60
- # process step - time period
61
- if hProcStep.has_key?('timePeriod')
62
- hObject = hProcStep['timePeriod']
63
- unless hObject.empty?
64
- hReturn = TimePeriod.unpack(hObject, responseObj)
65
- unless hReturn.nil?
66
- intProcStep[:timePeriod] = hReturn
67
- end
68
- end
80
+ end
81
+ end
82
+
83
+ # process step - reference [citation]
84
+ if hProcStep.has_key?('reference')
85
+ aReference = hProcStep['reference']
86
+ aReference.each do |item|
87
+ hReference = Citation.unpack(item, responseObj)
88
+ unless hReference.nil?
89
+ intProcStep[:references] << hReference
69
90
  end
70
-
71
- # process step - step processors [responsible party]
72
- if hProcStep.has_key?('processor')
73
- aProc = hProcStep['processor']
74
- aProc.each do |item|
75
- hParty = ResponsibleParty.unpack(item, responseObj)
76
- unless hParty.nil?
77
- intProcStep[:processors] << hParty
78
- end
79
- end
91
+ end
92
+ end
93
+
94
+ # process step - step sources [source]
95
+ if hProcStep.has_key?('stepSource')
96
+ aSources = hProcStep['stepSource']
97
+ aSources.each do |item|
98
+ hSource = Source.unpack(item, responseObj)
99
+ unless hSource.nil?
100
+ intProcStep[:stepSources] << hSource
80
101
  end
81
-
82
- # process step - reference [citation]
83
- if hProcStep.has_key?('reference')
84
- aReference = hProcStep['reference']
85
- aReference.each do |item|
86
- hReference = Citation.unpack(item, responseObj)
87
- unless hReference.nil?
88
- intProcStep[:references] << hReference
89
- end
90
- end
102
+ end
103
+ end
104
+
105
+ # process step - step products [source]
106
+ if hProcStep.has_key?('stepProduct')
107
+ aSources = hProcStep['stepProduct']
108
+ aSources.each do |item|
109
+ hSource = Source.unpack(item, responseObj)
110
+ unless hSource.nil?
111
+ intProcStep[:stepProducts] << hSource
91
112
  end
92
-
93
- # process step - scope {scope}
94
- if hProcStep.has_key?('scope')
95
- hObject = hProcStep['scope']
96
- unless hObject.empty?
97
- hReturn = Scope.unpack(hObject, responseObj)
98
- unless hReturn.nil?
99
- intProcStep[:scope] = hReturn
100
- end
101
- end
113
+ end
114
+ end
115
+
116
+ # process step - scope {scope}
117
+ if hProcStep.has_key?('scope')
118
+ hObject = hProcStep['scope']
119
+ unless hObject.empty?
120
+ hReturn = Scope.unpack(hObject, responseObj)
121
+ unless hReturn.nil?
122
+ intProcStep[:scope] = hReturn
102
123
  end
124
+ end
125
+ end
103
126
 
104
- return intProcStep
127
+ return intProcStep
105
128
 
106
- end
107
-
108
- end
129
+ end
109
130
 
110
131
  end
111
- end
112
- end
132
+
133
+ end
134
+ end
135
+ end
113
136
  end
@@ -6,6 +6,7 @@
6
6
  # Josh Bradley original script
7
7
 
8
8
  require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+ require_relative '../version'
9
10
  require_relative 'module_titles'
10
11
  require_relative 'module_id'
11
12
  require_relative 'module_body'
@@ -52,7 +53,7 @@ module ADIWG
52
53
 
53
54
  # schema
54
55
  hSchema[:name] = 'sbJson'
55
- hSchema[:version] = '0.0.0'
56
+ hSchema[:version] = ADIWG::Mdtranslator::Readers::SbJson::VERSION
56
57
 
57
58
  # titles / alternateTitles
58
59
  Title.unpack(hSbJson, hCitation, hResponseObj)
@@ -1,6 +1,7 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.2.0 2017-08-31 refactor for schema changes to Lineage and Funding
4
5
  # 2.1.2 2017-08-24 remove schema version from sbJson
5
6
  # 2.1.0 2017-08-10 revisions to sbJson reader
6
7
  # 2.0.0 2017-06-28 added sbJson reader
@@ -23,7 +24,7 @@
23
24
  module ADIWG
24
25
  module Mdtranslator
25
26
  # current mdtranslator version
26
- VERSION = "2.1.2"
27
+ VERSION = "2.2.0"
27
28
  end
28
29
  end
29
30
 
@@ -2,8 +2,11 @@
2
2
  # allocation
3
3
 
4
4
  # History:
5
+ # Stan Smith 2017-08-31 refactored for mdJson 2.3 schema update
5
6
  # Stan Smith 2017-04-04 original script
6
7
 
8
+ require_relative 'html_onlineResource'
9
+
7
10
  module ADIWG
8
11
  module Mdtranslator
9
12
  module Writers
@@ -17,6 +20,16 @@ module ADIWG
17
20
 
18
21
  def writeHtml(hAllocation)
19
22
 
23
+ # classes used
24
+ onlineClass = Html_OnlineResource.new(@html)
25
+
26
+ # allocation - id
27
+ unless hAllocation[:id].nil?
28
+ @html.em('Source Allocation ID: ')
29
+ @html.text!(hAllocation[:id])
30
+ @html.br
31
+ end
32
+
20
33
  # allocation - amount
21
34
  unless hAllocation[:amount].nil?
22
35
  @html.em('Amount: ')
@@ -54,6 +67,16 @@ module ADIWG
54
67
  @html.br
55
68
  end
56
69
 
70
+ # allocation - online resource []
71
+ hAllocation[:onlineResources].each do |hOnline|
72
+ @html.details do
73
+ @html.summary('Online Resource', {'class' => 'h5'})
74
+ @html.section(:class => 'block') do
75
+ onlineClass.writeHtml(hOnline)
76
+ end
77
+ end
78
+ end
79
+
57
80
  # allocation - comment
58
81
  unless hAllocation[:comment].nil?
59
82
  @html.em('Comment: ')
@@ -2,6 +2,7 @@
2
2
  # funding
3
3
 
4
4
  # History:
5
+ # Stan Smith 2017-08-31 refactored for mdJson 2.3 schema update
5
6
  # Stan Smith 2017-04-04 original script
6
7
 
7
8
  require_relative 'html_allocation'
@@ -24,6 +25,14 @@ module ADIWG
24
25
  allocationClass = Html_Allocation.new(@html)
25
26
  temporalClass = Html_TemporalExtent.new(@html)
26
27
 
28
+ # funding - description
29
+ unless hFunding[:description].nil?
30
+ @html.em('Description:')
31
+ @html.section(:class => 'block') do
32
+ @html.text!(hFunding[:description])
33
+ end
34
+ end
35
+
27
36
  # funding - timePeriod {timePeriod}
28
37
  unless hFunding[:timePeriod].empty?
29
38
  temporalObj = {}