adiwg-mdtranslator 2.0.0rc2 → 2.0.0rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,14 +2,14 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-10-23 refactored for mdJson 2.0
6
- # Stan Smith 2015-08-24 added return if input hash is empty
7
- # Stan Smith 2015-07-14 refactored to remove global namespace constants
8
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
9
- # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
10
- # Stan Smith 2014-08-21 removed extra level of encapsulation "citation" under "thesaurus"
11
- # Stan Smith 2014-08-21 removed thesaurus link; replaced by onlineResource to citation
12
- # Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
5
+ # Stan Smith 2016-10-23 refactored for mdJson 2.0
6
+ # Stan Smith 2015-08-24 added return if input hash is empty
7
+ # Stan Smith 2015-07-14 refactored to remove global namespace constants
8
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
9
+ # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
10
+ # Stan Smith 2014-08-21 removed extra level of encapsulation "citation" under "thesaurus"
11
+ # Stan Smith 2014-08-21 removed thesaurus link; replaced by onlineResource to citation
12
+ # Stan Smith 2014-07-03 resolve require statements using Mdtranslator.reader_module
13
13
  # Stan Smith 2013-11-27 modified to process single keyword collection
14
14
  # Stan Smith 2013-09-18 original script
15
15
 
@@ -17,67 +17,80 @@ require_relative 'module_citation'
17
17
  require_relative 'module_keywordObject'
18
18
 
19
19
  module ADIWG
20
- module Mdtranslator
21
- module Readers
22
- module MdJson
20
+ module Mdtranslator
21
+ module Readers
22
+ module MdJson
23
23
 
24
- module Keyword
24
+ module Keyword
25
25
 
26
- def self.unpack(hKeyword, responseObj)
26
+ def self.unpack(hKeyword, responseObj)
27
27
 
28
- # return nil object if input is empty
29
- if hKeyword.empty?
30
- responseObj[:readerExecutionMessages] << 'Keyword is empty'
31
- responseObj[:readerExecutionPass] = false
32
- return nil
33
- end
28
+ # return nil object if input is empty
29
+ if hKeyword.empty?
30
+ responseObj[:readerExecutionMessages] << 'Keyword is empty'
31
+ responseObj[:readerExecutionPass] = false
32
+ return nil
33
+ end
34
34
 
35
- # instance classes needed in script
36
- intMetadataClass = InternalMetadata.new
37
- intKeyword = intMetadataClass.newKeyword
35
+ # instance classes needed in script
36
+ intMetadataClass = InternalMetadata.new
37
+ intKeyword = intMetadataClass.newKeyword
38
38
 
39
- # keyword - keyword [] (required)
40
- if hKeyword.has_key?('keyword')
41
- hKeyword['keyword'].each do |hItem|
42
- unless hItem.empty?
43
- hReturn = KeywordObject.unpack(hItem, responseObj)
44
- unless hReturn.nil?
45
- intKeyword[:keywords] << hReturn
46
- end
47
- end
48
- end
49
- end
50
- if intKeyword[:keywords].empty?
51
- responseObj[:readerExecutionMessages] << 'Keyword is missing keywords'
52
- responseObj[:readerExecutionPass] = false
53
- return nil
39
+ # keyword - keyword [] (required)
40
+ if hKeyword.has_key?('keyword')
41
+ hKeyword['keyword'].each do |hItem|
42
+ unless hItem.empty?
43
+ hReturn = KeywordObject.unpack(hItem, responseObj)
44
+ unless hReturn.nil?
45
+ intKeyword[:keywords] << hReturn
46
+ end
54
47
  end
48
+ end
49
+ end
50
+ if intKeyword[:keywords].empty?
51
+ responseObj[:readerExecutionMessages] << 'Keyword is missing keywords'
52
+ responseObj[:readerExecutionPass] = false
53
+ return nil
54
+ end
55
55
 
56
- # keyword - keyType
57
- if hKeyword.has_key?('keywordType')
58
- if hKeyword['keywordType'] != ''
59
- intKeyword[:keywordType] = hKeyword['keywordType']
60
- end
61
- end
56
+ # keyword - keyType
57
+ if hKeyword.has_key?('keywordType')
58
+ if hKeyword['keywordType'] != ''
59
+ intKeyword[:keywordType] = hKeyword['keywordType']
60
+ end
61
+ end
62
62
 
63
- # keyword - thesaurus {citation}
64
- if hKeyword.has_key?('thesaurus')
65
- hObject = hKeyword['thesaurus']
66
- unless hObject.empty?
67
- hReturn = Citation.unpack(hObject, responseObj)
68
- unless hReturn.nil?
69
- intKeyword[:thesaurus] = hReturn
70
- end
71
- end
63
+ # keyword - thesaurus {citation}
64
+ if hKeyword.has_key?('thesaurus')
65
+ hObject = hKeyword['thesaurus']
66
+ unless hObject.empty?
67
+ hReturn = Citation.unpack(hObject, responseObj)
68
+ unless hReturn.nil?
69
+ intKeyword[:thesaurus] = hReturn
72
70
  end
71
+ end
72
+ end
73
73
 
74
- return intKeyword
74
+ # if keywordType is 'isoTopicCategory'
75
+ # resourceInfo.topicCategory [] << keyword
76
+ topicArray = []
77
+ if hKeyword.has_key?('keywordType')
78
+ if hKeyword['keywordType'] == 'isoTopicCategory'
79
+ hKeyword['keyword'].each do |hItem|
80
+ unless hItem.empty?
81
+ topicArray << hItem['keyword']
82
+ end
83
+ end
84
+ end
85
+ end
75
86
 
76
- end
87
+ return intKeyword, topicArray
77
88
 
78
- end
89
+ end
79
90
 
80
91
  end
81
- end
82
- end
92
+
93
+ end
94
+ end
95
+ end
83
96
  end