Class: Puree::XMLExtractor::ResearchOutput
Overview
Research output XML extractor.
Instance Method Summary
collapse
Methods included from TypeMixin
#type
#workflow
#research_outputs
#projects
Methods included from OwnerMixin
#owner
#organisational_units
#description
Methods inherited from Resource
#created_at, #created_by, #id, #model, #modified_at, #modified_by, #previous_uuids, #uuid
Methods inherited from Base
#xpath_query_for_multi_value, #xpath_query_for_single_value
Constructor Details
Returns a new instance of ResearchOutput.
18
19
20
21
|
# File 'lib/puree/xml_extractor/research_output.rb', line 18
def initialize(xml)
super
setup_model :research_output
end
|
Instance Method Details
#bibliographical_note ⇒ String?
24
25
26
|
# File 'lib/puree/xml_extractor/research_output.rb', line 24
def bibliographical_note
xpath_query_for_single_value '/bibliographicalNote/text'
end
|
#category ⇒ String?
29
30
31
|
# File 'lib/puree/xml_extractor/research_output.rb', line 29
def category
xpath_query_for_single_value '/category/term/text'
end
|
#doi ⇒ Puree::Model::DOI?
Digital Object Identifier (first one, if many)
35
36
37
38
|
# File 'lib/puree/xml_extractor/research_output.rb', line 35
def doi
multiple_dois = dois
multiple_dois.empty? ? nil : multiple_dois.first
end
|
#dois ⇒ Array<String>
Digital Object Identifiers
42
43
44
|
# File 'lib/puree/xml_extractor/research_output.rb', line 42
def dois
xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionDoiAssociation"]/doi'
end
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/puree/xml_extractor/research_output.rb', line 47
def files
xpath_result = xpath_query '/electronicVersions/electronicVersion[@type="wsElectronicVersionFileAssociation"]'
docs = []
xpath_result.each do |d|
model = Puree::Model::File.new
model.name = d.xpath('file/fileName').text.strip
model.mime = d.xpath('file/mimeType').text.strip
model.size = d.xpath('file/size').text.strip.to_i
model.url = d.xpath('file/fileURL').text.strip
docs << model
end
docs.uniq { |d| d.url }
end
|
#keywords ⇒ Array<String>
69
70
71
|
# File 'lib/puree/xml_extractor/research_output.rb', line 69
def keywords
keyword_group 'keywordContainers'
end
|
#language ⇒ String?
74
75
76
|
# File 'lib/puree/xml_extractor/research_output.rb', line 74
def language
xpath_query_for_single_value '/language/term/text'
end
|
#links ⇒ Array<String>?
79
80
81
|
# File 'lib/puree/xml_extractor/research_output.rb', line 79
def links
xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionLinkAssociation"]/link'
end
|
#open_access_permission ⇒ String?
84
85
86
|
# File 'lib/puree/xml_extractor/research_output.rb', line 84
def open_access_permission
xpath_query_for_single_value '/openAccessPermission/term/text'
end
|
94
95
96
|
# File 'lib/puree/xml_extractor/research_output.rb', line 94
def persons_external
persons 'external', '/personAssociations/personAssociation'
end
|
89
90
91
|
# File 'lib/puree/xml_extractor/research_output.rb', line 89
def persons_internal
persons 'internal', '/personAssociations/personAssociation'
end
|
99
100
101
|
# File 'lib/puree/xml_extractor/research_output.rb', line 99
def persons_other
persons 'other', '/personAssociations/personAssociation'
end
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/puree/xml_extractor/research_output.rb', line 104
def publication_statuses
xpath_result = xpath_query '/publicationStatuses/publicationStatus'
data = []
xpath_result.each do |i|
s = Puree::Model::PublicationStatus.new
s.stage = i.xpath('publicationStatus/term/text').text.strip
ymd = {}
ymd['year'] = i.xpath('publicationDate/year').text.strip
ymd['month'] = i.xpath('publicationDate/month').text.strip
ymd['day'] = i.xpath('publicationDate/day').text.strip
s.date = Puree::Util::Date.hash_to_time ymd
data << s
end
data.uniq { |d| d.stage }
end
|
#scopus_citations_count ⇒ Integer?
124
125
126
127
|
# File 'lib/puree/xml_extractor/research_output.rb', line 124
def scopus_citations_count
xpath_result = xpath_query_for_single_value '/totalScopusCitations'
xpath_result ? xpath_result.to_i : nil
end
|
#scopus_id ⇒ String?
130
131
132
133
134
135
136
|
# File 'lib/puree/xml_extractor/research_output.rb', line 130
def scopus_id
external_identifiers.each do |i|
if i.type.downcase === 'scopus'
return i.id
end
end
end
|
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/puree/xml_extractor/research_output.rb', line 139
def scopus_metrics
xpath_result = xpath_query '/scopusMetrics/scopusMetric'
data = []
xpath_result.each do |i|
s = Puree::Model::ResearchOutputScopusMetric.new
s.value = i.xpath('value').text.strip.to_i
s.year = i.xpath('year').text.strip.to_i
data << s
end
data
end
|
#subtitle ⇒ String?
152
153
154
|
# File 'lib/puree/xml_extractor/research_output.rb', line 152
def subtitle
xpath_query_for_single_value '/subTitle'
end
|
#title ⇒ String?
157
158
159
|
# File 'lib/puree/xml_extractor/research_output.rb', line 157
def title
xpath_query_for_single_value '/title'
end
|
#translated_subtitle ⇒ String?
162
163
164
|
# File 'lib/puree/xml_extractor/research_output.rb', line 162
def translated_subtitle
xpath_query_for_single_value '/translatedSubTitle/text'
end
|
#translated_title ⇒ String?
167
168
169
|
# File 'lib/puree/xml_extractor/research_output.rb', line 167
def translated_title
xpath_query_for_single_value '/translatedTitle/text'
end
|