Class: Puree::XMLExtractor::ResearchOutput
Overview
Research output XML extractor.
Instance Method Summary
collapse
Methods included from TypeMixin
#type
Methods included from TitleMixin
#title
#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
19
20
21
22
|
# File 'lib/puree/xml_extractor/research_output.rb', line 19
def initialize(xml)
super
setup_model :research_output
end
|
Instance Method Details
#bibliographical_note ⇒ String?
25
26
27
|
# File 'lib/puree/xml_extractor/research_output.rb', line 25
def bibliographical_note
xpath_query_for_single_value('/bibliographicalNote')
end
|
#category ⇒ String?
30
31
32
|
# File 'lib/puree/xml_extractor/research_output.rb', line 30
def category
xpath_query_for_single_value '/category'
end
|
#doi ⇒ Puree::Model::DOI?
Digital Object Identifier (first one, if many)
36
37
38
39
|
# File 'lib/puree/xml_extractor/research_output.rb', line 36
def doi
multiple_dois = dois
multiple_dois.empty? ? nil : multiple_dois.first
end
|
#dois ⇒ Array<String>
Digital Object Identifiers
43
44
45
|
# File 'lib/puree/xml_extractor/research_output.rb', line 43
def dois
xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionDoiAssociation"]/doi'
end
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/puree/xml_extractor/research_output.rb', line 48
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>
70
71
72
|
# File 'lib/puree/xml_extractor/research_output.rb', line 70
def keywords
keyword_group 'keywordContainers'
end
|
#language ⇒ String?
75
76
77
|
# File 'lib/puree/xml_extractor/research_output.rb', line 75
def language
xpath_query_for_single_value '/language'
end
|
#links ⇒ Array<String>?
80
81
82
|
# File 'lib/puree/xml_extractor/research_output.rb', line 80
def links
xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionLinkAssociation"]/link'
end
|
#open_access_permission ⇒ String?
85
86
87
|
# File 'lib/puree/xml_extractor/research_output.rb', line 85
def open_access_permission
xpath_query_for_single_value '/openAccessPermission'
end
|
95
96
97
|
# File 'lib/puree/xml_extractor/research_output.rb', line 95
def persons_external
persons 'external', '/personAssociations/personAssociation'
end
|
90
91
92
|
# File 'lib/puree/xml_extractor/research_output.rb', line 90
def persons_internal
persons 'internal', '/personAssociations/personAssociation'
end
|
100
101
102
|
# File 'lib/puree/xml_extractor/research_output.rb', line 100
def persons_other
persons 'other', '/personAssociations/personAssociation'
end
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/puree/xml_extractor/research_output.rb', line 105
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').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?
125
126
127
128
|
# File 'lib/puree/xml_extractor/research_output.rb', line 125
def scopus_citations_count
xpath_result = xpath_query_for_single_value '/totalScopusCitations'
xpath_result ? xpath_result.to_i : nil
end
|
#scopus_id ⇒ String?
131
132
133
134
135
136
137
|
# File 'lib/puree/xml_extractor/research_output.rb', line 131
def scopus_id
external_identifiers.each do |i|
if i.type.downcase === 'scopus'
return i.id
end
end
end
|
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/puree/xml_extractor/research_output.rb', line 140
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?
153
154
155
|
# File 'lib/puree/xml_extractor/research_output.rb', line 153
def subtitle
xpath_query_for_single_value '/subTitle'
end
|
#translated_subtitle ⇒ String?
158
159
160
|
# File 'lib/puree/xml_extractor/research_output.rb', line 158
def translated_subtitle
xpath_query_for_single_value '/translatedSubTitle'
end
|
#translated_title ⇒ String?
163
164
165
|
# File 'lib/puree/xml_extractor/research_output.rb', line 163
def translated_title
xpath_query_for_single_value '/translatedTitle'
end
|