puree 1.9.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -12
  3. data/Gemfile +1 -1
  4. data/README.md +106 -75
  5. data/lib/puree/extractor/conference_paper.rb +6 -14
  6. data/lib/puree/extractor/dataset.rb +5 -41
  7. data/lib/puree/extractor/doctoral_thesis.rb +5 -6
  8. data/lib/puree/extractor/event.rb +6 -14
  9. data/lib/puree/extractor/external_organisation.rb +5 -8
  10. data/lib/puree/extractor/extractor.rb +19 -0
  11. data/lib/puree/extractor/journal.rb +5 -9
  12. data/lib/puree/extractor/journal_article.rb +6 -15
  13. data/lib/puree/extractor/masters_thesis.rb +5 -6
  14. data/lib/puree/extractor/organisational_unit.rb +25 -0
  15. data/lib/puree/extractor/paper.rb +6 -11
  16. data/lib/puree/extractor/person.rb +4 -53
  17. data/lib/puree/extractor/project.rb +5 -28
  18. data/lib/puree/extractor/publisher.rb +5 -12
  19. data/lib/puree/extractor/research_output.rb +20 -0
  20. data/lib/puree/extractor/resource.rb +22 -58
  21. data/lib/puree/extractor/thesis.rb +6 -17
  22. data/lib/puree/model/conference_paper.rb +1 -1
  23. data/lib/puree/model/dataset.rb +8 -25
  24. data/lib/puree/model/event.rb +0 -9
  25. data/lib/puree/model/external_organisation.rb +1 -1
  26. data/lib/puree/model/external_organisation_header.rb +2 -19
  27. data/lib/puree/model/identifier.rb +26 -0
  28. data/lib/puree/model/journal.rb +1 -1
  29. data/lib/puree/model/journal_article.rb +1 -4
  30. data/lib/puree/model/model.rb +43 -0
  31. data/lib/puree/model/{organisation_header.rb → organisation_header_base.rb} +2 -2
  32. data/lib/puree/model/{organisation.rb → organisational_unit.rb} +3 -6
  33. data/lib/puree/model/organisational_unit_header.rb +9 -0
  34. data/lib/puree/model/paper.rb +10 -1
  35. data/lib/puree/model/person.rb +3 -9
  36. data/lib/puree/model/project.rb +7 -14
  37. data/lib/puree/model/publication_status.rb +1 -1
  38. data/lib/puree/model/publisher.rb +3 -0
  39. data/lib/puree/model/publisher_header.rb +9 -0
  40. data/lib/puree/model/{publication.rb → research_output.rb} +18 -20
  41. data/lib/puree/model/research_output_scopus_metric.rb +26 -0
  42. data/lib/puree/model/resource.rb +19 -11
  43. data/lib/puree/model/thesis.rb +6 -3
  44. data/lib/puree/rest/activity.rb +24 -0
  45. data/lib/puree/rest/application.rb +24 -0
  46. data/lib/puree/rest/base.rb +131 -0
  47. data/lib/puree/rest/classification_scheme.rb +24 -0
  48. data/lib/puree/rest/client.rb +105 -0
  49. data/lib/puree/rest/curricula_vitae.rb +24 -0
  50. data/lib/puree/rest/dataset.rb +24 -0
  51. data/lib/puree/rest/equipment.rb +24 -0
  52. data/lib/puree/rest/event.rb +24 -0
  53. data/lib/puree/rest/external_organisation.rb +24 -0
  54. data/lib/puree/rest/external_person.rb +24 -0
  55. data/lib/puree/rest/impact.rb +24 -0
  56. data/lib/puree/rest/journal.rb +24 -0
  57. data/lib/puree/rest/mixins/active_mixin.rb +14 -0
  58. data/lib/puree/rest/mixins/activity_mixin.rb +14 -0
  59. data/lib/puree/rest/mixins/application_mixin.rb +15 -0
  60. data/lib/puree/rest/mixins/award_mixin.rb +15 -0
  61. data/lib/puree/rest/mixins/dataset_mixin.rb +15 -0
  62. data/lib/puree/rest/mixins/former_mixin.rb +14 -0
  63. data/lib/puree/rest/mixins/impact_mixin.rb +15 -0
  64. data/lib/puree/rest/mixins/person_mixin.rb +15 -0
  65. data/lib/puree/rest/mixins/press_media_mixin.rb +15 -0
  66. data/lib/puree/rest/mixins/prize_mixin.rb +15 -0
  67. data/lib/puree/rest/mixins/project_mixin.rb +15 -0
  68. data/lib/puree/rest/mixins/research_output_mixin.rb +15 -0
  69. data/lib/puree/rest/mixins/student_thesis_mixin.rb +15 -0
  70. data/lib/puree/rest/organisational_unit.rb +51 -0
  71. data/lib/puree/rest/person.rb +58 -0
  72. data/lib/puree/rest/press_media.rb +24 -0
  73. data/lib/puree/rest/prize.rb +24 -0
  74. data/lib/puree/rest/project.rb +27 -0
  75. data/lib/puree/rest/publisher.rb +31 -0
  76. data/lib/puree/rest/research_output.rb +24 -0
  77. data/lib/puree/rest/rest.rb +30 -0
  78. data/lib/puree/util/util.rb +3 -0
  79. data/lib/puree/version.rb +1 -1
  80. data/lib/puree/xml_extractor/base.rb +6 -6
  81. data/lib/puree/xml_extractor/collection.rb +112 -19
  82. data/lib/puree/xml_extractor/conference_paper.rb +9 -2
  83. data/lib/puree/xml_extractor/dataset.rb +56 -166
  84. data/lib/puree/xml_extractor/doctoral_thesis.rb +1 -1
  85. data/lib/puree/xml_extractor/event.rb +16 -19
  86. data/lib/puree/xml_extractor/external_organisation.rb +14 -5
  87. data/lib/puree/xml_extractor/journal.rb +18 -8
  88. data/lib/puree/xml_extractor/journal_article.rb +24 -11
  89. data/lib/puree/xml_extractor/masters_thesis.rb +1 -1
  90. data/lib/puree/xml_extractor/mixins/abstract_mixin.rb +17 -0
  91. data/lib/puree/xml_extractor/mixins/description_mixin.rb +17 -0
  92. data/lib/puree/xml_extractor/mixins/{external_organisations_mixin.rb → external_organisation_mixin.rb} +2 -2
  93. data/lib/puree/xml_extractor/mixins/identifier_mixin.rb +25 -0
  94. data/lib/puree/xml_extractor/mixins/keyword_mixin.rb +21 -0
  95. data/lib/puree/xml_extractor/mixins/organisational_unit_mixin.rb +18 -0
  96. data/lib/puree/xml_extractor/mixins/owner_mixin.rb +18 -0
  97. data/lib/puree/xml_extractor/mixins/peer_reviewed_mixin.rb +1 -1
  98. data/lib/puree/xml_extractor/mixins/person_mixin.rb +45 -0
  99. data/lib/puree/xml_extractor/mixins/publisher_mixin.rb +22 -0
  100. data/lib/puree/xml_extractor/mixins/{associated_mixin.rb → research_output_mixin.rb} +7 -7
  101. data/lib/puree/xml_extractor/mixins/title_mixin.rb +17 -0
  102. data/lib/puree/xml_extractor/mixins/type_mixin.rb +17 -0
  103. data/lib/puree/xml_extractor/mixins/workflow_mixin.rb +17 -0
  104. data/lib/puree/xml_extractor/organisational_unit.rb +82 -0
  105. data/lib/puree/xml_extractor/paper.rb +17 -3
  106. data/lib/puree/xml_extractor/person.rb +30 -35
  107. data/lib/puree/xml_extractor/project.rb +39 -75
  108. data/lib/puree/xml_extractor/publisher.rb +15 -6
  109. data/lib/puree/xml_extractor/research_output.rb +189 -0
  110. data/lib/puree/xml_extractor/resource.rb +28 -36
  111. data/lib/puree/xml_extractor/shared.rb +12 -9
  112. data/lib/puree/xml_extractor/thesis.rb +29 -15
  113. data/lib/puree/xml_extractor/xml_extractor.rb +43 -0
  114. data/lib/puree.rb +5 -114
  115. data/puree.gemspec +1 -1
  116. data/test/extractor/resource_test.rb +103 -0
  117. data/test/rest/base_test.rb +45 -0
  118. data/test/rest/common_test.rb +44 -0
  119. data/test/test_extractor_helper.rb +1 -0
  120. data/test/test_helper.rb +17 -0
  121. data/test/test_rest_helper.rb +82 -0
  122. data/test/test_xml_extractor_helper.rb +17 -0
  123. data/test/xml_extractor/xml_extractor_collection_test.rb +120 -0
  124. data/test/xml_extractor/xml_extractor_conference_paper_test.rb +69 -0
  125. data/test/xml_extractor/xml_extractor_dataset_test.rb +156 -0
  126. data/test/xml_extractor/xml_extractor_event_test.rb +58 -0
  127. data/test/xml_extractor/xml_extractor_external_organisation_test.rb +49 -0
  128. data/test/xml_extractor/xml_extractor_journal_article_test.rb +66 -0
  129. data/test/xml_extractor/xml_extractor_journal_test.rb +53 -0
  130. data/test/xml_extractor/xml_extractor_organisation_test.rb +80 -0
  131. data/test/xml_extractor/xml_extractor_person_test.rb +88 -0
  132. data/test/xml_extractor/xml_extractor_project_test.rb +136 -0
  133. data/test/xml_extractor/xml_extractor_publisher_test.rb +49 -0
  134. data/test/xml_extractor/xml_extractor_research_output_test.rb +214 -0
  135. data/test/xml_extractor/xml_extractor_thesis_test.rb +80 -0
  136. metadata +105 -68
  137. data/lib/puree/api/api.rb +0 -9
  138. data/lib/puree/api/authentication.rb +0 -33
  139. data/lib/puree/api/configuration.rb +0 -43
  140. data/lib/puree/api/map.rb +0 -80
  141. data/lib/puree/api/person_request.rb +0 -64
  142. data/lib/puree/api/request.rb +0 -119
  143. data/lib/puree/extractor/collection.rb +0 -131
  144. data/lib/puree/extractor/download.rb +0 -71
  145. data/lib/puree/extractor/organisation.rb +0 -34
  146. data/lib/puree/extractor/paper_base.rb +0 -28
  147. data/lib/puree/extractor/publication.rb +0 -53
  148. data/lib/puree/extractor/server.rb +0 -56
  149. data/lib/puree/model/download_header.rb +0 -21
  150. data/lib/puree/model/paper_base.rb +0 -19
  151. data/lib/puree/model/server.rb +0 -13
  152. data/lib/puree/query/funding.rb +0 -54
  153. data/lib/puree/query/person.rb +0 -121
  154. data/lib/puree/query/query.rb +0 -6
  155. data/lib/puree/xml_extractor/download.rb +0 -42
  156. data/lib/puree/xml_extractor/mixins/workflow_state_mixin.rb +0 -18
  157. data/lib/puree/xml_extractor/organisation.rb +0 -75
  158. data/lib/puree/xml_extractor/paper_base.rb +0 -17
  159. data/lib/puree/xml_extractor/publication.rb +0 -257
  160. data/lib/puree/xml_extractor/server.rb +0 -32
  161. data/spec/download_http_spec.rb +0 -31
  162. data/spec/open_api_dataset_http_spec.rb +0 -15
  163. data/spec/query/funding_http_spec.rb +0 -29
  164. data/spec/query/person_http_spec.rb +0 -52
  165. data/spec/resource/collection_all_http_spec.rb +0 -77
  166. data/spec/resource/collection_http_spec.rb +0 -65
  167. data/spec/resource/dataset_http_spec.rb +0 -112
  168. data/spec/resource/event_http_spec.rb +0 -52
  169. data/spec/resource/journal_http_spec.rb +0 -36
  170. data/spec/resource/organisation_http_spec.rb +0 -52
  171. data/spec/resource/person_http_spec.rb +0 -60
  172. data/spec/resource/project_http_spec.rb +0 -89
  173. data/spec/resource/publication_http_spec.rb +0 -126
  174. data/spec/resource/publisher_http_spec.rb +0 -26
  175. data/spec/server_http_spec.rb +0 -26
  176. 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::PaperBase
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::AssociatedMixin
9
- include Puree::XMLExtractor::WorkflowStateMixin
10
-
11
- def initialize(xml:)
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
- @resource_type = :dataset
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('dateMadeAvailable')
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('fileName').text.strip
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.xpath('term/localizedString').text.strip
57
- license.url = document_license.xpath('description/localizedString').text.strip
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
- xpath_result = xpath_query '/keywordGroups/keywordGroup/keyword/userDefinedKeyword/freeKeyword'
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 'dateOfDataProduction', 'endDateOfDataProduction'
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/localizedString'
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
- point = Puree::Model::SpatialPoint.new
168
- if !xpath_result[0].nil?
169
- arr = xpath_result.text.split(',')
170
- point.latitude = arr[0].strip.to_f
171
- point.longitude = arr[1].strip.to_f
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 'temporalCoverageStartDate', 'temporalCoverageEndDate'
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 roles
266
- {
267
- '/dk/atira/pure/dataset/roles/dataset/contributor' => 'Contributor',
268
- '/dk/atira/pure/dataset/roles/dataset/creator' => 'Creator',
269
- '/dk/atira/pure/dataset/roles/dataset/datacollector' => 'Data Collector',
270
- '/dk/atira/pure/dataset/roles/dataset/datamanager' => 'Data Manager',
271
- '/dk/atira/pure/dataset/roles/dataset/distributor' => 'Distributor',
272
- '/dk/atira/pure/dataset/roles/dataset/editor' => 'Editor',
273
- '/dk/atira/pure/dataset/roles/dataset/funder' => 'Funder',
274
- '/dk/atira/pure/dataset/roles/dataset/owner' => 'Owner',
275
- '/dk/atira/pure/dataset/roles/dataset/other' => 'Other',
276
- '/dk/atira/pure/dataset/roles/dataset/producer' => 'Producer',
277
- '/dk/atira/pure/dataset/roles/dataset/rightsholder' => 'Rights Holder',
278
- '/dk/atira/pure/dataset/roles/dataset/sponsor' => 'Sponsor',
279
- '/dk/atira/pure/dataset/roles/dataset/supervisor' => 'Supervisor'
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,7 +5,7 @@ module Puree
5
5
  #
6
6
  class DoctoralThesis < Puree::XMLExtractor::Thesis
7
7
 
8
- def initialize(xml:)
8
+ def initialize(xml)
9
9
  super
10
10
  end
11
11
 
@@ -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
- @resource_type = :event
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 '/dateRange'
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
- # @return [String, nil]
45
- def location
46
- xpath_query_for_single_value '/location'
47
- end
41
+ private
48
42
 
49
- # @return [String, nil]
50
- def title
51
- xpath_query_for_single_value '/title/localizedString'
43
+ def xpath_root
44
+ '/event'
52
45
  end
53
46
 
54
- # @return [String, nil]
55
- def type
56
- xpath_query_for_single_value '//typeClassification/term/localizedString'
57
- end
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
- @resource_type = :external_organisation
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
- # @return [String, nil]
20
- def type
21
- xpath_query_for_single_value '/typeClassification/uri'
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
- @resource_type = :journal
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/string'
17
+ xpath_query_for_single_value '/issns/issn'
17
18
  end
18
19
 
19
20
  # @return [String, nil]
20
- def publisher
21
- xpath_query_for_single_value '/publisher/name'
21
+ def title
22
+ xpath_query_for_single_value '/titles/title'
22
23
  end
23
24
 
24
- # @return [String, nil]
25
- def title
26
- xpath_query_for_single_value '/titles/title/string'
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::Publication
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
- end
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 '/journal'
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('typeClassification/term/localizedString').text.strip
29
+ header.type = journal.xpath('type').text.strip
34
30
  header.uuid = journal.attr('uuid').text.strip
35
- return header
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
@@ -5,7 +5,7 @@ module Puree
5
5
  #
6
6
  class MastersThesis < Puree::XMLExtractor::Thesis
7
7
 
8
- def initialize(xml:)
8
+ def initialize(xml)
9
9
  super
10
10
  end
11
11
 
@@ -0,0 +1,17 @@
1
+ module Puree
2
+
3
+ module XMLExtractor
4
+
5
+ # Abstract mixin.
6
+ #
7
+ module AbstractMixin
8
+
9
+ # @return [String, nil]
10
+ def description
11
+ xpath_query_for_single_value '/abstract'
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Puree
2
+
3
+ module XMLExtractor
4
+
5
+ # Description mixin.
6
+ #
7
+ module DescriptionMixin
8
+
9
+ # @return [String, nil]
10
+ def description
11
+ xpath_query_for_single_value '/description'
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -4,11 +4,11 @@ module Puree
4
4
 
5
5
  # External organisations extractor mixin.
6
6
  #
7
- module ExternalOrganisationsMixin
7
+ module ExternalOrganisationMixin
8
8
 
9
9
  # @return [Array<Puree::Model::ExternalOrganisationHeader>]
10
10
  def external_organisations
11
- xpath_result = xpath_query '/associatedExternalOrganisations/externalOrganisation'
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