puree 1.9.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -12
- data/Gemfile +1 -1
- data/README.md +106 -75
- data/lib/puree/extractor/conference_paper.rb +6 -14
- data/lib/puree/extractor/dataset.rb +5 -41
- data/lib/puree/extractor/doctoral_thesis.rb +5 -6
- data/lib/puree/extractor/event.rb +6 -14
- data/lib/puree/extractor/external_organisation.rb +5 -8
- data/lib/puree/extractor/extractor.rb +19 -0
- data/lib/puree/extractor/journal.rb +5 -9
- data/lib/puree/extractor/journal_article.rb +6 -15
- data/lib/puree/extractor/masters_thesis.rb +5 -6
- data/lib/puree/extractor/organisational_unit.rb +25 -0
- data/lib/puree/extractor/paper.rb +6 -11
- data/lib/puree/extractor/person.rb +4 -53
- data/lib/puree/extractor/project.rb +5 -28
- data/lib/puree/extractor/publisher.rb +5 -12
- data/lib/puree/extractor/research_output.rb +20 -0
- data/lib/puree/extractor/resource.rb +22 -58
- data/lib/puree/extractor/thesis.rb +6 -17
- data/lib/puree/model/conference_paper.rb +1 -1
- data/lib/puree/model/dataset.rb +8 -25
- data/lib/puree/model/event.rb +0 -9
- data/lib/puree/model/external_organisation.rb +1 -1
- data/lib/puree/model/external_organisation_header.rb +2 -19
- data/lib/puree/model/identifier.rb +26 -0
- data/lib/puree/model/journal.rb +1 -1
- data/lib/puree/model/journal_article.rb +1 -4
- data/lib/puree/model/model.rb +43 -0
- data/lib/puree/model/{organisation_header.rb → organisation_header_base.rb} +2 -2
- data/lib/puree/model/{organisation.rb → organisational_unit.rb} +3 -6
- data/lib/puree/model/organisational_unit_header.rb +9 -0
- data/lib/puree/model/paper.rb +10 -1
- data/lib/puree/model/person.rb +3 -9
- data/lib/puree/model/project.rb +7 -14
- data/lib/puree/model/publication_status.rb +1 -1
- data/lib/puree/model/publisher.rb +3 -0
- data/lib/puree/model/publisher_header.rb +9 -0
- data/lib/puree/model/{publication.rb → research_output.rb} +18 -20
- data/lib/puree/model/research_output_scopus_metric.rb +26 -0
- data/lib/puree/model/resource.rb +19 -11
- data/lib/puree/model/thesis.rb +6 -3
- data/lib/puree/rest/activity.rb +24 -0
- data/lib/puree/rest/application.rb +24 -0
- data/lib/puree/rest/base.rb +131 -0
- data/lib/puree/rest/classification_scheme.rb +24 -0
- data/lib/puree/rest/client.rb +105 -0
- data/lib/puree/rest/curricula_vitae.rb +24 -0
- data/lib/puree/rest/dataset.rb +24 -0
- data/lib/puree/rest/equipment.rb +24 -0
- data/lib/puree/rest/event.rb +24 -0
- data/lib/puree/rest/external_organisation.rb +24 -0
- data/lib/puree/rest/external_person.rb +24 -0
- data/lib/puree/rest/impact.rb +24 -0
- data/lib/puree/rest/journal.rb +24 -0
- data/lib/puree/rest/mixins/active_mixin.rb +14 -0
- data/lib/puree/rest/mixins/activity_mixin.rb +14 -0
- data/lib/puree/rest/mixins/application_mixin.rb +15 -0
- data/lib/puree/rest/mixins/award_mixin.rb +15 -0
- data/lib/puree/rest/mixins/dataset_mixin.rb +15 -0
- data/lib/puree/rest/mixins/former_mixin.rb +14 -0
- data/lib/puree/rest/mixins/impact_mixin.rb +15 -0
- data/lib/puree/rest/mixins/person_mixin.rb +15 -0
- data/lib/puree/rest/mixins/press_media_mixin.rb +15 -0
- data/lib/puree/rest/mixins/prize_mixin.rb +15 -0
- data/lib/puree/rest/mixins/project_mixin.rb +15 -0
- data/lib/puree/rest/mixins/research_output_mixin.rb +15 -0
- data/lib/puree/rest/mixins/student_thesis_mixin.rb +15 -0
- data/lib/puree/rest/organisational_unit.rb +51 -0
- data/lib/puree/rest/person.rb +58 -0
- data/lib/puree/rest/press_media.rb +24 -0
- data/lib/puree/rest/prize.rb +24 -0
- data/lib/puree/rest/project.rb +27 -0
- data/lib/puree/rest/publisher.rb +31 -0
- data/lib/puree/rest/research_output.rb +24 -0
- data/lib/puree/rest/rest.rb +30 -0
- data/lib/puree/util/util.rb +3 -0
- data/lib/puree/version.rb +1 -1
- data/lib/puree/xml_extractor/base.rb +6 -6
- data/lib/puree/xml_extractor/collection.rb +112 -19
- data/lib/puree/xml_extractor/conference_paper.rb +9 -2
- data/lib/puree/xml_extractor/dataset.rb +56 -166
- data/lib/puree/xml_extractor/doctoral_thesis.rb +1 -1
- data/lib/puree/xml_extractor/event.rb +16 -19
- data/lib/puree/xml_extractor/external_organisation.rb +14 -5
- data/lib/puree/xml_extractor/journal.rb +18 -8
- data/lib/puree/xml_extractor/journal_article.rb +24 -11
- data/lib/puree/xml_extractor/masters_thesis.rb +1 -1
- data/lib/puree/xml_extractor/mixins/abstract_mixin.rb +17 -0
- data/lib/puree/xml_extractor/mixins/description_mixin.rb +17 -0
- data/lib/puree/xml_extractor/mixins/{external_organisations_mixin.rb → external_organisation_mixin.rb} +2 -2
- data/lib/puree/xml_extractor/mixins/identifier_mixin.rb +25 -0
- data/lib/puree/xml_extractor/mixins/keyword_mixin.rb +21 -0
- data/lib/puree/xml_extractor/mixins/organisational_unit_mixin.rb +18 -0
- data/lib/puree/xml_extractor/mixins/owner_mixin.rb +18 -0
- data/lib/puree/xml_extractor/mixins/peer_reviewed_mixin.rb +1 -1
- data/lib/puree/xml_extractor/mixins/person_mixin.rb +45 -0
- data/lib/puree/xml_extractor/mixins/publisher_mixin.rb +22 -0
- data/lib/puree/xml_extractor/mixins/{associated_mixin.rb → research_output_mixin.rb} +7 -7
- data/lib/puree/xml_extractor/mixins/title_mixin.rb +17 -0
- data/lib/puree/xml_extractor/mixins/type_mixin.rb +17 -0
- data/lib/puree/xml_extractor/mixins/workflow_mixin.rb +17 -0
- data/lib/puree/xml_extractor/organisational_unit.rb +82 -0
- data/lib/puree/xml_extractor/paper.rb +17 -3
- data/lib/puree/xml_extractor/person.rb +30 -35
- data/lib/puree/xml_extractor/project.rb +39 -75
- data/lib/puree/xml_extractor/publisher.rb +15 -6
- data/lib/puree/xml_extractor/research_output.rb +189 -0
- data/lib/puree/xml_extractor/resource.rb +28 -36
- data/lib/puree/xml_extractor/shared.rb +12 -9
- data/lib/puree/xml_extractor/thesis.rb +29 -15
- data/lib/puree/xml_extractor/xml_extractor.rb +43 -0
- data/lib/puree.rb +5 -114
- data/puree.gemspec +1 -1
- data/test/extractor/resource_test.rb +103 -0
- data/test/rest/base_test.rb +45 -0
- data/test/rest/common_test.rb +44 -0
- data/test/test_extractor_helper.rb +1 -0
- data/test/test_helper.rb +17 -0
- data/test/test_rest_helper.rb +82 -0
- data/test/test_xml_extractor_helper.rb +17 -0
- data/test/xml_extractor/xml_extractor_collection_test.rb +120 -0
- data/test/xml_extractor/xml_extractor_conference_paper_test.rb +69 -0
- data/test/xml_extractor/xml_extractor_dataset_test.rb +156 -0
- data/test/xml_extractor/xml_extractor_event_test.rb +58 -0
- data/test/xml_extractor/xml_extractor_external_organisation_test.rb +49 -0
- data/test/xml_extractor/xml_extractor_journal_article_test.rb +66 -0
- data/test/xml_extractor/xml_extractor_journal_test.rb +53 -0
- data/test/xml_extractor/xml_extractor_organisation_test.rb +80 -0
- data/test/xml_extractor/xml_extractor_person_test.rb +88 -0
- data/test/xml_extractor/xml_extractor_project_test.rb +136 -0
- data/test/xml_extractor/xml_extractor_publisher_test.rb +49 -0
- data/test/xml_extractor/xml_extractor_research_output_test.rb +214 -0
- data/test/xml_extractor/xml_extractor_thesis_test.rb +80 -0
- metadata +105 -68
- data/lib/puree/api/api.rb +0 -9
- data/lib/puree/api/authentication.rb +0 -33
- data/lib/puree/api/configuration.rb +0 -43
- data/lib/puree/api/map.rb +0 -80
- data/lib/puree/api/person_request.rb +0 -64
- data/lib/puree/api/request.rb +0 -119
- data/lib/puree/extractor/collection.rb +0 -131
- data/lib/puree/extractor/download.rb +0 -71
- data/lib/puree/extractor/organisation.rb +0 -34
- data/lib/puree/extractor/paper_base.rb +0 -28
- data/lib/puree/extractor/publication.rb +0 -53
- data/lib/puree/extractor/server.rb +0 -56
- data/lib/puree/model/download_header.rb +0 -21
- data/lib/puree/model/paper_base.rb +0 -19
- data/lib/puree/model/server.rb +0 -13
- data/lib/puree/query/funding.rb +0 -54
- data/lib/puree/query/person.rb +0 -121
- data/lib/puree/query/query.rb +0 -6
- data/lib/puree/xml_extractor/download.rb +0 -42
- data/lib/puree/xml_extractor/mixins/workflow_state_mixin.rb +0 -18
- data/lib/puree/xml_extractor/organisation.rb +0 -75
- data/lib/puree/xml_extractor/paper_base.rb +0 -17
- data/lib/puree/xml_extractor/publication.rb +0 -257
- data/lib/puree/xml_extractor/server.rb +0 -32
- data/spec/download_http_spec.rb +0 -31
- data/spec/open_api_dataset_http_spec.rb +0 -15
- data/spec/query/funding_http_spec.rb +0 -29
- data/spec/query/person_http_spec.rb +0 -52
- data/spec/resource/collection_all_http_spec.rb +0 -77
- data/spec/resource/collection_http_spec.rb +0 -65
- data/spec/resource/dataset_http_spec.rb +0 -112
- data/spec/resource/event_http_spec.rb +0 -52
- data/spec/resource/journal_http_spec.rb +0 -36
- data/spec/resource/organisation_http_spec.rb +0 -52
- data/spec/resource/person_http_spec.rb +0 -60
- data/spec/resource/project_http_spec.rb +0 -89
- data/spec/resource/publication_http_spec.rb +0 -126
- data/spec/resource/publisher_http_spec.rb +0 -26
- data/spec/server_http_spec.rb +0 -26
- data/spec/spec_helper.rb +0 -159
@@ -3,11 +3,18 @@ module Puree
|
|
3
3
|
|
4
4
|
# Conference paper XML extractor.
|
5
5
|
#
|
6
|
-
class ConferencePaper < Puree::XMLExtractor::
|
6
|
+
class ConferencePaper < Puree::XMLExtractor::Paper
|
7
7
|
include Puree::XMLExtractor::EventMixin
|
8
8
|
|
9
|
-
def initialize(xml
|
9
|
+
def initialize(xml)
|
10
10
|
super
|
11
|
+
setup_model :conference_paper
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def xpath_root
|
17
|
+
'/contributionToConference'
|
11
18
|
end
|
12
19
|
|
13
20
|
end
|
@@ -5,29 +5,25 @@ module Puree
|
|
5
5
|
# Dataset XML extractor.
|
6
6
|
#
|
7
7
|
class Dataset < Puree::XMLExtractor::Resource
|
8
|
-
include Puree::XMLExtractor::
|
9
|
-
include Puree::XMLExtractor::
|
10
|
-
|
11
|
-
|
8
|
+
include Puree::XMLExtractor::DescriptionMixin
|
9
|
+
include Puree::XMLExtractor::KeywordMixin
|
10
|
+
include Puree::XMLExtractor::OrganisationalUnitMixin
|
11
|
+
include Puree::XMLExtractor::OwnerMixin
|
12
|
+
include Puree::XMLExtractor::PersonMixin
|
13
|
+
include Puree::XMLExtractor::PublisherMixin
|
14
|
+
include Puree::XMLExtractor::ResearchOutputMixin
|
15
|
+
include Puree::XMLExtractor::WorkflowMixin
|
16
|
+
include Puree::XMLExtractor::TitleMixin
|
17
|
+
|
18
|
+
def initialize(xml)
|
12
19
|
super
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# Open access permission
|
17
|
-
# @return [String, nil]
|
18
|
-
def access
|
19
|
-
xpath_query_for_single_value '/openAccessPermission/term/localizedString'
|
20
|
+
setup_model :dataset
|
20
21
|
end
|
21
22
|
|
22
23
|
# Date made available
|
23
24
|
# @return [Time, nil]
|
24
25
|
def available
|
25
|
-
Puree::Util::Date.hash_to_time temporal_date('
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [String, nil]
|
29
|
-
def description
|
30
|
-
xpath_query_for_single_value '/descriptions/classificationDefinedField/value/localizedString'
|
26
|
+
Puree::Util::Date.hash_to_time temporal_date('publicationDate')
|
31
27
|
end
|
32
28
|
|
33
29
|
# Digital Object Identifier
|
@@ -43,9 +39,9 @@ module Puree
|
|
43
39
|
docs = []
|
44
40
|
xpath_result.each do |d|
|
45
41
|
doc = Puree::Model::File.new
|
46
|
-
doc.name = d.xpath('
|
47
|
-
doc.mime = d.xpath('mimeType').text.strip
|
48
|
-
doc.size = d.xpath('size').text.strip.to_i
|
42
|
+
doc.name = d.xpath('title').text.strip
|
43
|
+
# doc.mime = d.xpath('mimeType').text.strip
|
44
|
+
# doc.size = d.xpath('size').text.strip.to_i
|
49
45
|
doc.url = d.xpath('url').text.strip
|
50
46
|
# doc['createdDate'] = d.xpath('createdDate').text.strip
|
51
47
|
# doc['visibleOnPortalDate'] = d.xpath('visibleOnPortalDate').text.strip
|
@@ -53,8 +49,9 @@ module Puree
|
|
53
49
|
document_license = d.xpath('documentLicense')
|
54
50
|
if !document_license.empty?
|
55
51
|
license = Puree::Model::CopyrightLicense.new
|
56
|
-
license.name = document_license.
|
57
|
-
license.
|
52
|
+
license.name = document_license.text.strip
|
53
|
+
# license.name = document_license.xpath('term/localizedString').text.strip
|
54
|
+
# license.url = document_license.xpath('description/localizedString').text.strip
|
58
55
|
doc.license = license if license.data?
|
59
56
|
end
|
60
57
|
docs << doc
|
@@ -64,95 +61,34 @@ module Puree
|
|
64
61
|
|
65
62
|
# @return [Array<String>]
|
66
63
|
def keywords
|
67
|
-
|
68
|
-
data_arr = xpath_result.map { |i| i.text.strip }
|
69
|
-
data_arr.uniq
|
70
|
-
end
|
71
|
-
|
72
|
-
# @return [Array<Puree::Model::LegalCondition>]
|
73
|
-
def legal_conditions
|
74
|
-
xpath_result = xpath_query '/legalConditions/legalCondition'
|
75
|
-
data = []
|
76
|
-
xpath_result.each { |i|
|
77
|
-
model = Puree::Model::LegalCondition.new
|
78
|
-
model.name = i.xpath('typeClassification/term/localizedString').text.strip
|
79
|
-
model.description = i.xpath('description').text.strip
|
80
|
-
data << model
|
81
|
-
}
|
82
|
-
data.uniq { |d| d.name }
|
83
|
-
end
|
84
|
-
|
85
|
-
# @return [Array<Puree::Model::Link>]
|
86
|
-
def links
|
87
|
-
xpath_result = xpath_query '/links/link'
|
88
|
-
data = []
|
89
|
-
xpath_result.each { |i|
|
90
|
-
model = Puree::Model::Link.new
|
91
|
-
model.description = i.xpath('description').text.strip
|
92
|
-
model.url = i.xpath('url').text.strip
|
93
|
-
data << model
|
94
|
-
}
|
95
|
-
data.uniq { |d| d.url }
|
96
|
-
end
|
97
|
-
|
98
|
-
# @return [Array<Puree::Model::OrganisationHeader>]
|
99
|
-
def organisations
|
100
|
-
xpath_result = xpath_query '/organisations/organisation'
|
101
|
-
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
|
102
|
-
end
|
103
|
-
|
104
|
-
# @return [Puree::Model::OrganisationHeader, nil]
|
105
|
-
def owner
|
106
|
-
xpath_result = xpath_query '/managedBy'
|
107
|
-
Puree::XMLExtractor::Shared.organisation_header xpath_result
|
64
|
+
keyword_group 'User-Defined Keywords'
|
108
65
|
end
|
109
66
|
|
110
67
|
# @return [Array<Puree::Model::EndeavourPerson>]
|
111
68
|
def persons_internal
|
112
|
-
persons 'internal'
|
69
|
+
persons 'internal', '/personAssociations/personAssociation'
|
113
70
|
end
|
114
71
|
|
115
72
|
# @return [Array<Puree::Model::EndeavourPerson>]
|
116
73
|
def persons_external
|
117
|
-
persons 'external'
|
74
|
+
persons 'external', '/personAssociations/personAssociation'
|
118
75
|
end
|
119
76
|
|
120
77
|
# @return [Array<Puree::Model::EndeavourPerson>]
|
121
78
|
def persons_other
|
122
|
-
persons 'other'
|
79
|
+
persons 'other', '/personAssociations/personAssociation'
|
123
80
|
end
|
124
81
|
|
125
82
|
# Date of data production
|
126
83
|
# @return [Puree::Model::TemporalRange, nil]
|
127
84
|
def production
|
128
|
-
temporal_range '
|
129
|
-
end
|
130
|
-
|
131
|
-
# @return [Array<Puree::Model::RelatedContentHeader>]
|
132
|
-
def projects
|
133
|
-
associated_type('Research').uniq
|
134
|
-
end
|
135
|
-
|
136
|
-
# @return [Array<Puree::Model::RelatedContentHeader>]
|
137
|
-
def publications
|
138
|
-
data_arr = []
|
139
|
-
associated.each do |i|
|
140
|
-
if i.type != 'Research'
|
141
|
-
data_arr << i
|
142
|
-
end
|
143
|
-
end
|
144
|
-
data_arr
|
145
|
-
end
|
146
|
-
|
147
|
-
# @return [String, nil]
|
148
|
-
def publisher
|
149
|
-
xpath_query_for_single_value '/publisher/name'
|
85
|
+
temporal_range 'dataProductionPeriod/startDate', 'dataProductionPeriod/endDate'
|
150
86
|
end
|
151
87
|
|
152
88
|
# @return [Array<String>]
|
153
89
|
def spatial_places
|
154
90
|
# Data from free-form text box
|
155
|
-
xpath_result = xpath_query '/geographicalCoverage
|
91
|
+
xpath_result = xpath_query '/geographicalCoverage'
|
156
92
|
data = []
|
157
93
|
xpath_result.each do |i|
|
158
94
|
data << i.text.strip
|
@@ -164,78 +100,23 @@ module Puree
|
|
164
100
|
# @return [Puree::Model::SpatialPoint, nil]
|
165
101
|
def spatial_point
|
166
102
|
xpath_result = xpath_query '/geoLocation/point'
|
167
|
-
|
168
|
-
|
169
|
-
arr = xpath_result.text.split(',')
|
170
|
-
point.latitude = arr[0].
|
171
|
-
point.longitude = arr[1].
|
103
|
+
if !xpath_result.empty?
|
104
|
+
point = Puree::Model::SpatialPoint.new
|
105
|
+
arr = xpath_result.text.strip.split(',')
|
106
|
+
point.latitude = arr[0].to_f
|
107
|
+
point.longitude = arr[1].to_f
|
172
108
|
point
|
173
109
|
end
|
174
|
-
nil
|
175
110
|
end
|
176
111
|
|
177
112
|
# Temporal coverage
|
178
113
|
# @return [Puree::Model::TemporalRange, nil]
|
179
114
|
def temporal
|
180
|
-
temporal_range '
|
181
|
-
end
|
182
|
-
|
183
|
-
# @return [String, nil]
|
184
|
-
def title
|
185
|
-
xpath_query_for_single_value '/title/localizedString'
|
115
|
+
temporal_range 'temporalCoveragePeriod/startDate', 'temporalCoveragePeriod/endDate'
|
186
116
|
end
|
187
117
|
|
188
118
|
private
|
189
119
|
|
190
|
-
def associated_type(type)
|
191
|
-
data_arr = []
|
192
|
-
associated.each do |i|
|
193
|
-
if i.type === type
|
194
|
-
related = Puree::Model::RelatedContentHeader.new
|
195
|
-
related.type = i.type
|
196
|
-
related.title = i.title
|
197
|
-
related.uuid = i.uuid
|
198
|
-
data_arr << related
|
199
|
-
end
|
200
|
-
end
|
201
|
-
data_arr.uniq
|
202
|
-
end
|
203
|
-
|
204
|
-
# @return [Array<Endeavour::Person>]
|
205
|
-
def persons(type)
|
206
|
-
xpath_result = xpath_query '/persons/dataSetPersonAssociation'
|
207
|
-
arr = []
|
208
|
-
xpath_result.each do |i|
|
209
|
-
uuid_internal = i.at_xpath('person/@uuid')
|
210
|
-
uuid_external = i.at_xpath('externalPerson/@uuid')
|
211
|
-
if uuid_internal
|
212
|
-
person_type = 'internal'
|
213
|
-
uuid = uuid_internal.text.strip
|
214
|
-
elsif uuid_external
|
215
|
-
person_type = 'external'
|
216
|
-
uuid = uuid_external.text.strip
|
217
|
-
else
|
218
|
-
person_type = 'other'
|
219
|
-
uuid = ''
|
220
|
-
end
|
221
|
-
if person_type === type
|
222
|
-
person = Puree::Model::EndeavourPerson.new
|
223
|
-
person.uuid = uuid
|
224
|
-
|
225
|
-
name = Puree::Model::PersonName.new
|
226
|
-
name.first = i.xpath('name/firstName').text.strip
|
227
|
-
name.last = i.xpath('name/lastName').text.strip
|
228
|
-
person.name = name
|
229
|
-
|
230
|
-
role_uri = i.xpath('personRole/uri').text.strip
|
231
|
-
person.role = roles[role_uri]
|
232
|
-
|
233
|
-
arr << person if person.data?
|
234
|
-
end
|
235
|
-
end
|
236
|
-
arr.uniq { |d| d.uuid }
|
237
|
-
end
|
238
|
-
|
239
120
|
# Temporal range
|
240
121
|
# @return [Puree::Model::TemporalRange, nil]
|
241
122
|
def temporal_range(start_path, end_path)
|
@@ -262,22 +143,31 @@ module Puree
|
|
262
143
|
Puree::Util::Date.normalise o
|
263
144
|
end
|
264
145
|
|
265
|
-
def
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
146
|
+
def xpath_root
|
147
|
+
'/dataSet'
|
148
|
+
end
|
149
|
+
|
150
|
+
def combine_metadata
|
151
|
+
super
|
152
|
+
@model.available = available
|
153
|
+
@model.description = description
|
154
|
+
@model.doi = doi
|
155
|
+
@model.files = files
|
156
|
+
@model.keywords = keywords
|
157
|
+
@model.organisational_units = organisational_units
|
158
|
+
@model.owner = owner
|
159
|
+
@model.persons_internal = persons_internal
|
160
|
+
@model.persons_external = persons_external
|
161
|
+
@model.persons_other = persons_other
|
162
|
+
@model.production = production
|
163
|
+
@model.research_outputs = research_outputs
|
164
|
+
@model.publisher = publisher
|
165
|
+
@model.spatial_places = spatial_places
|
166
|
+
@model.spatial_point = spatial_point
|
167
|
+
@model.temporal = temporal
|
168
|
+
@model.title = title
|
169
|
+
@model.workflow = workflow
|
170
|
+
@model
|
281
171
|
end
|
282
172
|
|
283
173
|
end
|
@@ -5,10 +5,12 @@ module Puree
|
|
5
5
|
# Event XML extractor.
|
6
6
|
#
|
7
7
|
class Event < Puree::XMLExtractor::Resource
|
8
|
+
include Puree::XMLExtractor::TitleMixin
|
9
|
+
include Puree::XMLExtractor::TypeMixin
|
8
10
|
|
9
|
-
def initialize(xml
|
11
|
+
def initialize(xml)
|
10
12
|
super
|
11
|
-
|
13
|
+
setup_model :event
|
12
14
|
end
|
13
15
|
|
14
16
|
# @return [String, nil]
|
@@ -16,14 +18,9 @@ module Puree
|
|
16
18
|
xpath_query_for_single_value '/city'
|
17
19
|
end
|
18
20
|
|
19
|
-
# @return [String, nil]
|
20
|
-
def country
|
21
|
-
xpath_query_for_single_value '/country/term/localizedString'
|
22
|
-
end
|
23
|
-
|
24
21
|
# @return [Puree::Model::TemporalRange, nil]
|
25
22
|
def date
|
26
|
-
xpath_result = xpath_query '/
|
23
|
+
xpath_result = xpath_query '/period'
|
27
24
|
range_start_str = xpath_result.xpath('startDate').text.strip
|
28
25
|
range_end_str = xpath_result.xpath('endDate').text.strip
|
29
26
|
if !range_start_str.empty?
|
@@ -41,20 +38,20 @@ module Puree
|
|
41
38
|
xpath_query_for_single_value '/description'
|
42
39
|
end
|
43
40
|
|
44
|
-
|
45
|
-
def location
|
46
|
-
xpath_query_for_single_value '/location'
|
47
|
-
end
|
41
|
+
private
|
48
42
|
|
49
|
-
|
50
|
-
|
51
|
-
xpath_query_for_single_value '/title/localizedString'
|
43
|
+
def xpath_root
|
44
|
+
'/event'
|
52
45
|
end
|
53
46
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
47
|
+
def combine_metadata
|
48
|
+
super
|
49
|
+
@model.city = city
|
50
|
+
@model.date = date
|
51
|
+
@model.title = title
|
52
|
+
@model.type = type
|
53
|
+
@model
|
54
|
+
end
|
58
55
|
|
59
56
|
end
|
60
57
|
|
@@ -5,10 +5,11 @@ module Puree
|
|
5
5
|
# External organisation XML extractor.
|
6
6
|
#
|
7
7
|
class ExternalOrganisation < Puree::XMLExtractor::Resource
|
8
|
+
include Puree::XMLExtractor::TypeMixin
|
8
9
|
|
9
|
-
def initialize(xml
|
10
|
+
def initialize(xml)
|
10
11
|
super
|
11
|
-
|
12
|
+
setup_model :external_organisation
|
12
13
|
end
|
13
14
|
|
14
15
|
# @return [String, nil]
|
@@ -16,9 +17,17 @@ module Puree
|
|
16
17
|
xpath_query_for_single_value '/name'
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
|
22
|
+
def xpath_root
|
23
|
+
'/externalOrganisation'
|
24
|
+
end
|
25
|
+
|
26
|
+
def combine_metadata
|
27
|
+
super
|
28
|
+
@model.name = name
|
29
|
+
@model.type = type
|
30
|
+
@model
|
22
31
|
end
|
23
32
|
|
24
33
|
end
|
@@ -5,25 +5,35 @@ module Puree
|
|
5
5
|
# Journal XML extractor.
|
6
6
|
#
|
7
7
|
class Journal < Puree::XMLExtractor::Resource
|
8
|
+
include Puree::XMLExtractor::PublisherMixin
|
8
9
|
|
9
|
-
def initialize(xml
|
10
|
+
def initialize(xml)
|
10
11
|
super
|
11
|
-
|
12
|
+
setup_model :journal
|
12
13
|
end
|
13
14
|
|
14
15
|
# @return [String, nil]
|
15
16
|
def issn
|
16
|
-
xpath_query_for_single_value '/issns/issn
|
17
|
+
xpath_query_for_single_value '/issns/issn'
|
17
18
|
end
|
18
19
|
|
19
20
|
# @return [String, nil]
|
20
|
-
def
|
21
|
-
xpath_query_for_single_value '/
|
21
|
+
def title
|
22
|
+
xpath_query_for_single_value '/titles/title'
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
private
|
26
|
+
|
27
|
+
def combine_metadata
|
28
|
+
super
|
29
|
+
@model.issn = issn
|
30
|
+
@model.publisher = publisher
|
31
|
+
@model.title = title
|
32
|
+
@model
|
33
|
+
end
|
34
|
+
|
35
|
+
def xpath_root
|
36
|
+
'/journal'
|
27
37
|
end
|
28
38
|
|
29
39
|
end
|
@@ -3,18 +3,14 @@ module Puree
|
|
3
3
|
|
4
4
|
# Journal article XML extractor.
|
5
5
|
#
|
6
|
-
class JournalArticle < Puree::XMLExtractor::
|
6
|
+
class JournalArticle < Puree::XMLExtractor::ResearchOutput
|
7
7
|
include Puree::XMLExtractor::PagesMixin
|
8
8
|
include Puree::XMLExtractor::PageRangeMixin
|
9
9
|
include Puree::XMLExtractor::PeerReviewedMixin
|
10
10
|
|
11
|
-
def initialize(xml
|
11
|
+
def initialize(xml)
|
12
12
|
super
|
13
|
-
|
14
|
-
|
15
|
-
# @return [Fixnum, nil]
|
16
|
-
def article_number
|
17
|
-
xpath_query_for_single_value('/articleNumber')
|
13
|
+
setup_model :journal_article
|
18
14
|
end
|
19
15
|
|
20
16
|
# @return [Fixnum, nil]
|
@@ -25,16 +21,15 @@ module Puree
|
|
25
21
|
|
26
22
|
# @return [Puree::Model::JournalHeader, nil]
|
27
23
|
def journal
|
28
|
-
xpath_result = xpath_query '/
|
24
|
+
xpath_result = xpath_query '/journalAssociation'
|
29
25
|
if !xpath_result.empty?
|
30
26
|
header = Puree::Model::JournalHeader.new
|
31
27
|
header.title = xpath_result.xpath('title').text.strip
|
32
28
|
journal = xpath_result.xpath('journal')
|
33
|
-
header.type = journal.xpath('
|
29
|
+
header.type = journal.xpath('type').text.strip
|
34
30
|
header.uuid = journal.attr('uuid').text.strip
|
35
|
-
|
31
|
+
header
|
36
32
|
end
|
37
|
-
nil
|
38
33
|
end
|
39
34
|
|
40
35
|
# @return [Fixnum, nil]
|
@@ -43,6 +38,24 @@ module Puree
|
|
43
38
|
xpath_result ? xpath_result.to_i : nil
|
44
39
|
end
|
45
40
|
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def xpath_root
|
45
|
+
'/contributionToJournal'
|
46
|
+
end
|
47
|
+
|
48
|
+
def combine_metadata
|
49
|
+
super
|
50
|
+
@model.issue = issue
|
51
|
+
@model.journal = journal
|
52
|
+
@model.pages = pages
|
53
|
+
@model.page_range = page_range
|
54
|
+
@model.peer_reviewed = peer_reviewed
|
55
|
+
@model.volume = volume
|
56
|
+
@model
|
57
|
+
end
|
58
|
+
|
46
59
|
end
|
47
60
|
end
|
48
61
|
end
|
@@ -4,11 +4,11 @@ module Puree
|
|
4
4
|
|
5
5
|
# External organisations extractor mixin.
|
6
6
|
#
|
7
|
-
module
|
7
|
+
module ExternalOrganisationMixin
|
8
8
|
|
9
9
|
# @return [Array<Puree::Model::ExternalOrganisationHeader>]
|
10
10
|
def external_organisations
|
11
|
-
xpath_result = xpath_query '/
|
11
|
+
xpath_result = xpath_query '/externalOrganisations/externalOrganisation'
|
12
12
|
Puree::XMLExtractor::Shared.external_organisation_multi_header xpath_result
|
13
13
|
end
|
14
14
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Identifier mixin.
|
6
|
+
#
|
7
|
+
module IdentifierMixin
|
8
|
+
|
9
|
+
# @return [Array<Model::Identifier>]
|
10
|
+
def identifiers
|
11
|
+
xpath_result = xpath_query '/ids/id'
|
12
|
+
data = []
|
13
|
+
xpath_result.each do |d|
|
14
|
+
identifier = Puree::Model::Identifier.new
|
15
|
+
identifier.id = d.text.strip
|
16
|
+
identifier.type = d.attr('type').strip
|
17
|
+
data << identifier
|
18
|
+
end
|
19
|
+
data.uniq { |d| d.id }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Keyword mixin.
|
6
|
+
#
|
7
|
+
module KeywordMixin
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# @return [Array<String>]
|
12
|
+
def keyword_group(logical_name)
|
13
|
+
xpath_result = xpath_query "/keywordGroups/keywordGroup[@logicalName='#{logical_name}']/keywords/keyword"
|
14
|
+
data_arr = xpath_result.map { |i| i.text.strip }
|
15
|
+
data_arr.uniq
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Organisational unit mixin.
|
6
|
+
#
|
7
|
+
module OrganisationalUnitMixin
|
8
|
+
|
9
|
+
# @return [Array<Puree::Model::OrganisationalUnitHeader>]
|
10
|
+
def organisational_units
|
11
|
+
xpath_result = xpath_query '/organisationalUnits/organisationalUnit'
|
12
|
+
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|