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.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/adiwg-mdtranslator.gemspec +31 -30
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +945 -945
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_keyword.rb +70 -57
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +338 -336
- data/lib/adiwg/mdtranslator/version.rb +8 -9
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +40 -118
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +79 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb +54 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb +24 -17
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +57 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +13 -9
- metadata +7 -32
@@ -2,14 +2,14 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
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
|
-
|
21
|
-
|
22
|
-
|
20
|
+
module Mdtranslator
|
21
|
+
module Readers
|
22
|
+
module MdJson
|
23
23
|
|
24
|
-
|
24
|
+
module Keyword
|
25
25
|
|
26
|
-
|
26
|
+
def self.unpack(hKeyword, responseObj)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
35
|
+
# instance classes needed in script
|
36
|
+
intMetadataClass = InternalMetadata.new
|
37
|
+
intKeyword = intMetadataClass.newKeyword
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
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
|
-
|
87
|
+
return intKeyword, topicArray
|
77
88
|
|
78
|
-
|
89
|
+
end
|
79
90
|
|
80
91
|
end
|
81
|
-
|
82
|
-
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
83
96
|
end
|