16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkDocument.rb', line 16
def self.unpack(hSbJson, hResponseObj)
intMetadataClass = InternalMetadata.new
aLinks = []
if hSbJson.has_key?('webLinks')
hSbJson['webLinks'].each do |hLink|
unless hLink.empty?
type = nil
if hLink.has_key?('type')
type = hLink['type']
end
if type.nil? || type == ''
hResponseObj[:readerExecutionMessages] << 'WebLink type is missing, set to "unknown"'
type = 'unknown'
end
if type != 'browseImage'
hDocument = intMetadataClass.newAdditionalDocumentation
hResType = intMetadataClass.newResourceType
hResType[:type] = type
if hLink.has_key?('typeLabel')
unless hLink['typeLabel'].nil? || hLink['typeLabel'] == ''
hResType[:name] = hLink['typeLabel']
end
end
hCitation = intMetadataClass.newCitation
if hLink.has_key?('title')
hCitation[:title] = hLink['title']
end
if hCitation[:title].nil? || hCitation[:title] == ''
hCitation[:title] = 'Online Resource'
end
hOlRes = intMetadataClass.newOnlineResource
if hLink.has_key?('uri')
hOlRes[:olResURI] = hLink['uri']
end
if hOlRes[:olResURI].nil? || hOlRes[:olResURI] == ''
hResponseObj[:readerExecutionMessages] << 'WebLink URI is missing'
hResponseObj[:readerExecutionMessages] << 'WebLink skipped'
return nil
end
hCitation[:onlineResources] << hOlRes
hDocument[:resourceTypes] << hResType
hDocument[:citation] << hCitation
aLinks << hDocument
end
end
end
return aLinks
end
return nil
end
|