Class: Puree::XMLExtractor::Publication
Overview
Publication XML extractor.
Instance Method Summary
collapse
#external_organisations
#associated
Methods inherited from Resource
#created, #get_data?, #locale, #modified, #uuid, #xpath_query
Methods inherited from Base
#xpath_query_for_multi_value, #xpath_query_for_single_value
Constructor Details
Returns a new instance of Publication.
11
12
13
14
|
# File 'lib/puree/xml_extractor/publication.rb', line 11
def initialize(xml:)
@resource_type = :publication
super
end
|
Instance Method Details
#bibliographical_note ⇒ String?
17
18
19
|
# File 'lib/puree/xml_extractor/publication.rb', line 17
def bibliographical_note
xpath_query_for_single_value('/bibliographicalNote')
end
|
#category ⇒ String?
22
23
24
|
# File 'lib/puree/xml_extractor/publication.rb', line 22
def category
xpath_query_for_single_value '/publicationCategory/publicationCategory/term/localizedString'
end
|
#description ⇒ String?
27
28
29
|
# File 'lib/puree/xml_extractor/publication.rb', line 27
def description
xpath_query_for_single_value '/abstract/localizedString'
end
|
#dois ⇒ Array<String>?
32
33
34
|
# File 'lib/puree/xml_extractor/publication.rb', line 32
def dois
xpath_query_for_multi_value '/electronicVersionAssociations/electronicVersionDOIAssociations/electronicVersionDOIAssociation/doi'
end
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/puree/xml_extractor/publication.rb', line 37
def files
xpath_result = xpath_query '/electronicVersionAssociations/electronicVersionFileAssociations/electronicVersionFileAssociation'
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/url').text.strip
document_license = d.xpath('licenseType')
if !document_license.empty?
license = Puree::Model::CopyrightLicense.new
license.name = document_license.xpath('term/localizedString').text.strip
license.url = document_license.xpath('description/localizedString').text.strip
model.license = license if license.data?
end
docs << model
end
docs.uniq { |d| d.url }
end
|
#keywords ⇒ Array<String>
59
60
61
62
63
|
# File 'lib/puree/xml_extractor/publication.rb', line 59
def keywords
xpath_result = xpath_query '/keywordGroups/keywordGroup/keyword/userDefinedKeyword/freeKeyword'
data_arr = xpath_result.map { |i| i.text.strip }
data_arr.uniq
end
|
#language ⇒ String?
66
67
68
|
# File 'lib/puree/xml_extractor/publication.rb', line 66
def language
xpath_query_for_single_value '/language/term/localizedString'
end
|
#links ⇒ Array<String>?
71
72
73
|
# File 'lib/puree/xml_extractor/publication.rb', line 71
def links
xpath_query_for_multi_value '/electronicVersionAssociations/electronicVersionLinkAssociations/electronicVersionLinkAssociation/link'
end
|
76
77
78
79
|
# File 'lib/puree/xml_extractor/publication.rb', line 76
def organisations
xpath_result = xpath_query '/organisations/association/organisation'
Puree::::Shared. xpath_result
end
|
82
83
84
85
|
# File 'lib/puree/xml_extractor/publication.rb', line 82
def owner
xpath_result = xpath_query '/owner'
Puree::::Shared. xpath_result
end
|
93
94
95
|
# File 'lib/puree/xml_extractor/publication.rb', line 93
def persons_external
persons 'external'
end
|
88
89
90
|
# File 'lib/puree/xml_extractor/publication.rb', line 88
def persons_internal
persons 'internal'
end
|
98
99
100
|
# File 'lib/puree/xml_extractor/publication.rb', line 98
def persons_other
persons 'other'
end
|
#publication_place ⇒ String?
103
104
105
106
107
108
|
# File 'lib/puree/xml_extractor/publication.rb', line 103
def publication_place
xpath_result = xpath_query_for_single_value '/associatedPublisher/placeOfPublication'
xpath_result = xpath_query_for_single_value '/associatedPublishers/placeOfPublication' if !xpath_result
xpath_result
end
|
#publisher ⇒ String?
111
112
113
114
115
116
|
# File 'lib/puree/xml_extractor/publication.rb', line 111
def publisher
xpath_result = xpath_query_for_single_value '/associatedPublisher/publisher/name'
xpath_result = xpath_query_for_single_value '/associatedPublishers/publisher/name' if !xpath_result
xpath_result
end
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/puree/xml_extractor/publication.rb', line 119
def statuses
xpath_result = xpath_query '/publicationStatuses/publicationStatus'
data = []
xpath_result.each do |i|
s = Puree::Model::PublicationStatus.new
s.stage = i.xpath('publicationStatus/term/localizedString').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
|
#subtitle ⇒ String?
139
140
141
|
# File 'lib/puree/xml_extractor/publication.rb', line 139
def subtitle
xpath_query_for_single_value '/subtitle'
end
|
#title ⇒ String?
144
145
146
|
# File 'lib/puree/xml_extractor/publication.rb', line 144
def title
xpath_query_for_single_value '/title'
end
|
#translated_subtitle ⇒ String?
149
150
151
|
# File 'lib/puree/xml_extractor/publication.rb', line 149
def translated_subtitle
xpath_query_for_single_value '/translatedSubtitle/localizedString'
end
|
#translated_title ⇒ String?
154
155
156
|
# File 'lib/puree/xml_extractor/publication.rb', line 154
def translated_title
xpath_query_for_single_value '/translatedTitle/localizedString'
end
|
#type ⇒ String?
159
160
161
|
# File 'lib/puree/xml_extractor/publication.rb', line 159
def type
xpath_query_for_single_value '/typeClassification/term/localizedString'
end
|