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
data/lib/puree/query/person.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Query
|
4
|
-
|
5
|
-
# For querying information about a person.
|
6
|
-
#
|
7
|
-
class Person
|
8
|
-
|
9
|
-
def initialize(config)
|
10
|
-
@url = config[:url]
|
11
|
-
@headers = {}
|
12
|
-
basic_auth username: config[:username],
|
13
|
-
password: config[:password]
|
14
|
-
@config = config
|
15
|
-
end
|
16
|
-
|
17
|
-
# Count of publications available for a person.
|
18
|
-
#
|
19
|
-
# @param uuid [String] person UUID.
|
20
|
-
# @return [Fixnum]
|
21
|
-
def publication_count(uuid:)
|
22
|
-
params = {}
|
23
|
-
params['associatedPersonUuids.uuid'] = uuid
|
24
|
-
params['rendering'] = :system
|
25
|
-
params['window.size'] = 0
|
26
|
-
headers
|
27
|
-
response = @req.get(build_publication_url, params: params)
|
28
|
-
doc = make_doc response.body
|
29
|
-
extract_publication_count doc
|
30
|
-
end
|
31
|
-
|
32
|
-
# Publications for a person.
|
33
|
-
#
|
34
|
-
# @param uuid [String] person UUID.
|
35
|
-
# @param limit [Fixnum]
|
36
|
-
# @param offset [Fixnum]
|
37
|
-
# @param published_start [String] using format YYYY-MM-DD
|
38
|
-
# @param published_end [String] using format YYYY-MM-DD
|
39
|
-
# @return [Array<Puree::Model::Publication>]
|
40
|
-
def publications(uuid:, limit:, offset: 0, published_start: nil, published_end: nil)
|
41
|
-
uuids = publication_uuids(uuid: uuid,
|
42
|
-
limit: limit,
|
43
|
-
offset: offset,
|
44
|
-
published_start: published_start,
|
45
|
-
published_end: published_end)
|
46
|
-
publications = []
|
47
|
-
uuids.each do |uuid|
|
48
|
-
publication_extractor = Puree::Extractor::Publication.new @config
|
49
|
-
publication = publication_extractor.find uuid: uuid
|
50
|
-
publications << publication if publication
|
51
|
-
end
|
52
|
-
publications
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def publication_uuids(uuid:, limit:, offset: 0, published_start: nil, published_end: nil)
|
59
|
-
params = {}
|
60
|
-
params['associatedPersonUuids.uuid'] = uuid
|
61
|
-
params['rendering'] = :system
|
62
|
-
params['window.size'] = limit.to_s
|
63
|
-
params['window.offset'] = offset if limit > 0
|
64
|
-
params['publicationDate.fromDate'] = published_start if published_start
|
65
|
-
params['publicationDate.toDate'] = published_end if published_end
|
66
|
-
headers
|
67
|
-
response = @req.get(build_publication_url, params: params)
|
68
|
-
doc = make_doc response.body
|
69
|
-
extract_publication_uuids doc
|
70
|
-
end
|
71
|
-
|
72
|
-
def make_doc(xml)
|
73
|
-
doc = Nokogiri::XML xml
|
74
|
-
doc.remove_namespaces!
|
75
|
-
doc
|
76
|
-
end
|
77
|
-
|
78
|
-
def extract_publication_count(doc)
|
79
|
-
doc.xpath('/GetPublicationResponse/count').text.strip.to_i
|
80
|
-
end
|
81
|
-
|
82
|
-
def extract_publication_uuids(doc)
|
83
|
-
records = doc.xpath('/GetPublicationResponse/result/renderedItem')
|
84
|
-
uuids = []
|
85
|
-
records.each do |record|
|
86
|
-
uuid = extract_publication_uuid record
|
87
|
-
uuids << uuid
|
88
|
-
end
|
89
|
-
uuids
|
90
|
-
end
|
91
|
-
|
92
|
-
def extract_publication_uuid(doc)
|
93
|
-
doc.xpath('@renderedContentUUID').text.strip
|
94
|
-
end
|
95
|
-
|
96
|
-
def build_publication_url
|
97
|
-
"#{@url}/publication.current"
|
98
|
-
end
|
99
|
-
|
100
|
-
# Provide credentials if necessary
|
101
|
-
#
|
102
|
-
# @param username [String]
|
103
|
-
# @param password [String]
|
104
|
-
def basic_auth(username:, password:)
|
105
|
-
auth = Base64::strict_encode64("#{username}:#{password}")
|
106
|
-
@headers['Authorization'] = 'Basic ' + auth
|
107
|
-
end
|
108
|
-
|
109
|
-
def headers
|
110
|
-
@headers['Accept'] = 'application/xml'
|
111
|
-
@req = HTTP.headers accept: @headers['Accept']
|
112
|
-
if @headers['Authorization']
|
113
|
-
@req = @req.auth @headers['Authorization']
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
data/lib/puree/query/query.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module XMLExtractor
|
4
|
-
|
5
|
-
# Download XML extractor.
|
6
|
-
#
|
7
|
-
class Download < Puree::XMLExtractor::Base
|
8
|
-
|
9
|
-
def initialize(xml:)
|
10
|
-
@resource_type = :download
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
# Statistic
|
15
|
-
#
|
16
|
-
# @return [Array<Puree::Model::DownloadHeader>]
|
17
|
-
def statistics
|
18
|
-
path = "#{service_response_name}/downloadCount"
|
19
|
-
xpath_result = @doc.xpath(path)
|
20
|
-
data_arr = []
|
21
|
-
xpath_result.each { |i|
|
22
|
-
model = Puree::Model::DownloadHeader.new
|
23
|
-
model.uuid = i.attr('uuid').strip
|
24
|
-
model.count = i.attr('downloads').strip.to_i
|
25
|
-
data_arr << model
|
26
|
-
}
|
27
|
-
data_arr.uniq { |d| d.uuid }
|
28
|
-
end
|
29
|
-
|
30
|
-
# Is there any data after get?
|
31
|
-
#
|
32
|
-
# @return [Boolean]
|
33
|
-
def get_data?
|
34
|
-
# TO DO Inefficient!
|
35
|
-
statistics.size ? true : false
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module XMLExtractor
|
4
|
-
|
5
|
-
# Workflow state extractor mixin.
|
6
|
-
#
|
7
|
-
module WorkflowStateMixin
|
8
|
-
|
9
|
-
# Workflow state
|
10
|
-
# @return [String, nil]
|
11
|
-
def workflow_state
|
12
|
-
xpath_query_for_single_value '/startedWorkflows/startedWorkflow/state'
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module XMLExtractor
|
4
|
-
|
5
|
-
# Organisation XML extractor.
|
6
|
-
#
|
7
|
-
class Organisation < Puree::XMLExtractor::Resource
|
8
|
-
|
9
|
-
def initialize(xml:)
|
10
|
-
super
|
11
|
-
@resource_type = :organisation
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [Array<Puree::Model::Address>]
|
15
|
-
def address
|
16
|
-
xpath_result = xpath_query '/addresses/classifiedAddress'
|
17
|
-
data = []
|
18
|
-
xpath_result.each do |d|
|
19
|
-
a = Puree::Model::Address.new
|
20
|
-
street = d.xpath('street').text.strip
|
21
|
-
a.street = street unless street.empty?
|
22
|
-
building = d.xpath('building').text.strip
|
23
|
-
a.building = building unless building.empty?
|
24
|
-
postcode = d.xpath('postalCode').text.strip
|
25
|
-
a.postcode = postcode unless building.empty?
|
26
|
-
city = d.xpath('city').text.strip
|
27
|
-
a.city = city unless city.empty?
|
28
|
-
country = d.xpath('country/term/localizedString').text.strip
|
29
|
-
a.country = country unless country.empty?
|
30
|
-
data << a
|
31
|
-
end
|
32
|
-
data.uniq { |d| d.street }
|
33
|
-
end
|
34
|
-
|
35
|
-
# @return [Array<String>]
|
36
|
-
def email_addresses
|
37
|
-
xpath_query_for_multi_value '/emails/classificationDefinedStringFieldExtension/value'
|
38
|
-
end
|
39
|
-
|
40
|
-
# @return [String, nil]
|
41
|
-
def name
|
42
|
-
xpath_query_for_single_value '/name/localizedString'
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [Array<Puree::Model::OrganisationHeader>]
|
46
|
-
def organisations
|
47
|
-
xpath_result = xpath_query '/organisations/organisation'
|
48
|
-
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
|
49
|
-
end
|
50
|
-
|
51
|
-
# @return [Puree::Model::OrganisationHeader, nil]
|
52
|
-
def parent
|
53
|
-
organisations.first unless organisations.empty?
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return [Array<String>]
|
57
|
-
def phone_numbers
|
58
|
-
xpath_query_for_multi_value '/phoneNumbers/classificationDefinedStringFieldExtension/value'
|
59
|
-
end
|
60
|
-
|
61
|
-
# @return [String, nil]
|
62
|
-
def type
|
63
|
-
xpath_query_for_single_value '/typeClassification/term/localizedString'
|
64
|
-
end
|
65
|
-
|
66
|
-
# @return [Array<String>]
|
67
|
-
def urls
|
68
|
-
xpath_query_for_multi_value '/webAddresses/classificationDefinedFieldExtension/value/localizedString'
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
module XMLExtractor
|
3
|
-
|
4
|
-
# Paper base XML extractor.
|
5
|
-
#
|
6
|
-
class PaperBase < Puree::XMLExtractor::Publication
|
7
|
-
include Puree::XMLExtractor::PagesMixin
|
8
|
-
include Puree::XMLExtractor::PageRangeMixin
|
9
|
-
include Puree::XMLExtractor::PeerReviewedMixin
|
10
|
-
|
11
|
-
def initialize(xml:)
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,257 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module XMLExtractor
|
4
|
-
|
5
|
-
# Publication XML extractor.
|
6
|
-
#
|
7
|
-
class Publication < Puree::XMLExtractor::Resource
|
8
|
-
include Puree::XMLExtractor::AssociatedMixin
|
9
|
-
include Puree::XMLExtractor::ExternalOrganisationsMixin
|
10
|
-
include Puree::XMLExtractor::WorkflowStateMixin
|
11
|
-
|
12
|
-
def initialize(xml:)
|
13
|
-
@resource_type = :publication
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
# @return [String, nil]
|
18
|
-
def bibliographical_note
|
19
|
-
xpath_query_for_single_value('/bibliographicalNote')
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [String, nil]
|
23
|
-
def category
|
24
|
-
xpath_query_for_single_value '/publicationCategory/publicationCategory/term/localizedString'
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [String, nil]
|
28
|
-
def description
|
29
|
-
xpath_query_for_single_value '/abstract/localizedString'
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [String, nil]
|
33
|
-
def doi
|
34
|
-
multiple_dois = dois
|
35
|
-
multiple_dois.empty? ? nil : multiple_dois.first
|
36
|
-
end
|
37
|
-
|
38
|
-
# @deprecated Please use {#doi} instead
|
39
|
-
# @return [Array<String>, nil]
|
40
|
-
def dois
|
41
|
-
xpath_query_for_multi_value '/electronicVersionAssociations/electronicVersionDOIAssociations/electronicVersionDOIAssociation/doi'
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Array<Puree::Model::File>]
|
45
|
-
def files
|
46
|
-
xpath_result = xpath_query '/electronicVersionAssociations/electronicVersionFileAssociations/electronicVersionFileAssociation'
|
47
|
-
docs = []
|
48
|
-
xpath_result.each do |d|
|
49
|
-
model = Puree::Model::File.new
|
50
|
-
model.name = d.xpath('file/fileName').text.strip
|
51
|
-
model.mime = d.xpath('file/mimeType').text.strip
|
52
|
-
model.size = d.xpath('file/size').text.strip.to_i
|
53
|
-
model.url = d.xpath('file/url').text.strip
|
54
|
-
document_license = d.xpath('licenseType')
|
55
|
-
if !document_license.empty?
|
56
|
-
license = Puree::Model::CopyrightLicense.new
|
57
|
-
license.name = document_license.xpath('term/localizedString').text.strip
|
58
|
-
license.url = document_license.xpath('description/localizedString').text.strip
|
59
|
-
model.license = license if license.data?
|
60
|
-
end
|
61
|
-
docs << model
|
62
|
-
end
|
63
|
-
docs.uniq { |d| d.url }
|
64
|
-
end
|
65
|
-
|
66
|
-
# @return [Array<String>]
|
67
|
-
def keywords
|
68
|
-
xpath_result = xpath_query '/keywordGroups/keywordGroup/keyword/userDefinedKeyword/freeKeyword'
|
69
|
-
data_arr = xpath_result.map { |i| i.text.strip }
|
70
|
-
data_arr.uniq
|
71
|
-
end
|
72
|
-
|
73
|
-
# @return [String, nil]
|
74
|
-
def language
|
75
|
-
xpath_query_for_single_value '/language/term/localizedString'
|
76
|
-
end
|
77
|
-
|
78
|
-
# @return [Array<String>, nil]
|
79
|
-
def links
|
80
|
-
xpath_query_for_multi_value '/electronicVersionAssociations/electronicVersionLinkAssociations/electronicVersionLinkAssociation/link'
|
81
|
-
end
|
82
|
-
|
83
|
-
# @return [Array<Puree::Model::OrganisationHeader>]
|
84
|
-
def organisations
|
85
|
-
xpath_result = xpath_query '/organisations/association/organisation'
|
86
|
-
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
|
87
|
-
end
|
88
|
-
|
89
|
-
# @return [Puree::Model::OrganisationHeader, nil]
|
90
|
-
def owner
|
91
|
-
xpath_result = xpath_query '/owner'
|
92
|
-
Puree::XMLExtractor::Shared.organisation_header xpath_result
|
93
|
-
end
|
94
|
-
|
95
|
-
# @return [Array<Puree::Model::EndeavourPerson>]
|
96
|
-
def persons_internal
|
97
|
-
persons 'internal'
|
98
|
-
end
|
99
|
-
|
100
|
-
# @return [Array<Puree::Model::EndeavourPerson>]
|
101
|
-
def persons_external
|
102
|
-
persons 'external'
|
103
|
-
end
|
104
|
-
|
105
|
-
# @return [Array<Puree::Model::EndeavourPerson>]
|
106
|
-
def persons_other
|
107
|
-
persons 'other'
|
108
|
-
end
|
109
|
-
|
110
|
-
# @return [String, nil]
|
111
|
-
def publication_place
|
112
|
-
# handles variations in path
|
113
|
-
xpath_result = xpath_query_for_single_value '/associatedPublisher/placeOfPublication'
|
114
|
-
xpath_result = xpath_query_for_single_value '/associatedPublishers/placeOfPublication' if !xpath_result
|
115
|
-
xpath_result
|
116
|
-
end
|
117
|
-
|
118
|
-
# @return [String, nil]
|
119
|
-
def publisher
|
120
|
-
# handles variations in path
|
121
|
-
xpath_result = xpath_query_for_single_value '/associatedPublisher/publisher/name'
|
122
|
-
xpath_result = xpath_query_for_single_value '/associatedPublishers/publisher/name' if !xpath_result
|
123
|
-
xpath_result
|
124
|
-
end
|
125
|
-
|
126
|
-
# @return [String, nil]
|
127
|
-
def scopus_id
|
128
|
-
xpath_result = xpath_query '/external/secondarySource'
|
129
|
-
return if xpath_result.empty?
|
130
|
-
source = xpath_result.xpath('@source')
|
131
|
-
if source && source.text.strip === 'Scopus'
|
132
|
-
return xpath_result.xpath('@source_id').text.strip
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
# @return [Array<Puree::Model::PublicationStatus>]
|
137
|
-
def statuses
|
138
|
-
xpath_result = xpath_query '/publicationStatuses/publicationStatus'
|
139
|
-
data = []
|
140
|
-
xpath_result.each do |i|
|
141
|
-
s = Puree::Model::PublicationStatus.new
|
142
|
-
s.stage = i.xpath('publicationStatus/term/localizedString').text.strip
|
143
|
-
|
144
|
-
ymd = {}
|
145
|
-
ymd['year'] = i.xpath('publicationDate/year').text.strip
|
146
|
-
ymd['month'] = i.xpath('publicationDate/month').text.strip
|
147
|
-
ymd['day'] = i.xpath('publicationDate/day').text.strip
|
148
|
-
|
149
|
-
s.date = Puree::Util::Date.hash_to_time ymd
|
150
|
-
|
151
|
-
data << s
|
152
|
-
end
|
153
|
-
data.uniq { |d| d.stage }
|
154
|
-
end
|
155
|
-
|
156
|
-
# @return [String, nil]
|
157
|
-
def subtitle
|
158
|
-
xpath_query_for_single_value '/subtitle'
|
159
|
-
end
|
160
|
-
|
161
|
-
# @return [String, nil]
|
162
|
-
def title
|
163
|
-
xpath_query_for_single_value '/title'
|
164
|
-
end
|
165
|
-
|
166
|
-
# @return [String, nil]
|
167
|
-
def translated_subtitle
|
168
|
-
xpath_query_for_single_value '/translatedSubtitle/localizedString'
|
169
|
-
end
|
170
|
-
|
171
|
-
# @return [String, nil]
|
172
|
-
def translated_title
|
173
|
-
xpath_query_for_single_value '/translatedTitle/localizedString'
|
174
|
-
end
|
175
|
-
|
176
|
-
# @return [String, nil]
|
177
|
-
def type
|
178
|
-
xpath_query_for_single_value '/typeClassification/term/localizedString'
|
179
|
-
end
|
180
|
-
|
181
|
-
private
|
182
|
-
|
183
|
-
# @return [Array<Endeavour::Person>]
|
184
|
-
def persons(type)
|
185
|
-
xpath_result = xpath_query '/persons/personAssociation'
|
186
|
-
arr = []
|
187
|
-
xpath_result.each do |i|
|
188
|
-
uuid_internal = i.at_xpath('person/@uuid')
|
189
|
-
uuid_external = i.at_xpath('externalPerson/@uuid')
|
190
|
-
if uuid_internal
|
191
|
-
person_type = 'internal'
|
192
|
-
uuid = uuid_internal.text.strip
|
193
|
-
elsif uuid_external
|
194
|
-
person_type = 'external'
|
195
|
-
uuid = uuid_external.text.strip
|
196
|
-
else
|
197
|
-
person_type = 'other'
|
198
|
-
uuid = ''
|
199
|
-
end
|
200
|
-
if person_type === type
|
201
|
-
person = Puree::Model::EndeavourPerson.new
|
202
|
-
person.uuid = uuid
|
203
|
-
|
204
|
-
name = Puree::Model::PersonName.new
|
205
|
-
name.first = i.xpath('name/firstName').text.strip
|
206
|
-
name.last = i.xpath('name/lastName').text.strip
|
207
|
-
person.name = name
|
208
|
-
|
209
|
-
role_uri = i.xpath('personRole/uri').text.strip
|
210
|
-
person.role = roles[role_uri]
|
211
|
-
|
212
|
-
arr << person if person.data?
|
213
|
-
end
|
214
|
-
end
|
215
|
-
arr.uniq { |d| d.uuid }
|
216
|
-
end
|
217
|
-
|
218
|
-
def roles
|
219
|
-
{
|
220
|
-
# Should build using '/dk/atira/pure/researchoutput/roles/' as prefix, with parameter
|
221
|
-
|
222
|
-
## Article
|
223
|
-
'/dk/atira/pure/researchoutput/roles/contributiontojournal/author' => 'Author',
|
224
|
-
'/dk/atira/pure/researchoutput/roles/contributiontojournal/illustrator' => 'Illustrator',
|
225
|
-
'/dk/atira/pure/researchoutput/roles/contributiontojournal/editor' => 'Editor',
|
226
|
-
'/dk/atira/pure/researchoutput/roles/contributiontojournal/translator' => 'Translator',
|
227
|
-
'/dk/atira/pure/researchoutput/roles/contributiontojournal/publisher' => 'Publisher',
|
228
|
-
'/dk/atira/pure/researchoutput/roles/contributiontojournal/guesteditor' => 'Guest Editor',
|
229
|
-
|
230
|
-
## Chapter
|
231
|
-
# Author
|
232
|
-
# Illustrator
|
233
|
-
# Editor
|
234
|
-
# Translator # # @return [Fixnum, nil]
|
235
|
-
# def pages
|
236
|
-
# xpath_result = xpath_query_for_single_value('/numberOfPages')
|
237
|
-
# xpath_result ? xpath_result.to_i : nil
|
238
|
-
# end
|
239
|
-
# Publisher
|
240
|
-
|
241
|
-
# ... many, many more research output types ...
|
242
|
-
|
243
|
-
# Examples of others
|
244
|
-
'/dk/atira/pure/researchoutput/roles/bookanthology/author' => 'Author',
|
245
|
-
'/dk/atira/pure/researchoutput/roles/othercontribution/author' => 'Author',
|
246
|
-
'/dk/atira/pure/researchoutput/roles/thesis/author' => 'Author',
|
247
|
-
'/dk/atira/pure/researchoutput/roles/workingpaper/author' => 'Author',
|
248
|
-
'/dk/atira/pure/researchoutput/roles/internalexternal/thesis/supervisor' => 'Supervisor',
|
249
|
-
'/dk/atira/pure/researchoutput/roles/nontextual/artist' => 'Artist'
|
250
|
-
}
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
end
|
256
|
-
|
257
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module XMLExtractor
|
4
|
-
|
5
|
-
# Server XML extractor.
|
6
|
-
#
|
7
|
-
class Server < Puree::XMLExtractor::Base
|
8
|
-
|
9
|
-
def initialize(xml:)
|
10
|
-
@resource_type = :server
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [String]
|
15
|
-
def version
|
16
|
-
path = "#{service_response_name}/baseVersion"
|
17
|
-
@doc.xpath(path).text.strip
|
18
|
-
end
|
19
|
-
|
20
|
-
# Is there any data after get?
|
21
|
-
#
|
22
|
-
# @return [Boolean]
|
23
|
-
def get_data?
|
24
|
-
# n.b. arbitrary element existence check
|
25
|
-
version.empty? ? false : true
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/spec/download_http_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Download' do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
it '#new' do
|
10
|
-
p = Puree::Extractor::Download.new config
|
11
|
-
expect(p).to be_a Puree::Extractor::Download
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'data retrieval' do
|
15
|
-
before(:all) do
|
16
|
-
@p = Puree::Extractor::Download.new config
|
17
|
-
@metadata = @p.find resource: :dataset,
|
18
|
-
limit: 10
|
19
|
-
end
|
20
|
-
|
21
|
-
it '#find' do
|
22
|
-
expect(@metadata).to all( be_a Puree::Model::DownloadHeader )
|
23
|
-
end
|
24
|
-
|
25
|
-
it '#find' do
|
26
|
-
expect(@metadata).not_to be_empty
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Funding' do
|
4
|
-
|
5
|
-
it '#new' do
|
6
|
-
q = Puree::Query::Funding.new config
|
7
|
-
expect(q).to be_a Puree::Query::Funding
|
8
|
-
end
|
9
|
-
|
10
|
-
describe 'project data retrieval' do
|
11
|
-
before(:all) do
|
12
|
-
request :project
|
13
|
-
@project_uuid = @p.uuid
|
14
|
-
@q = Puree::Query::Funding.new config
|
15
|
-
end
|
16
|
-
|
17
|
-
it '#project_funders' do
|
18
|
-
funders = @q.project_funders uuid: @project_uuid
|
19
|
-
expect(funders).to all( be_a Puree::Model::ExternalOrganisation )
|
20
|
-
end
|
21
|
-
|
22
|
-
it '#publication_funders' do
|
23
|
-
funders = @q.publication_funders uuid: @project_uuid
|
24
|
-
expect(funders).to all( be_a Puree::Model::ExternalOrganisation )
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|