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/api/request.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module API
|
4
|
-
|
5
|
-
# Handles requests to Pure.
|
6
|
-
#
|
7
|
-
class Request
|
8
|
-
|
9
|
-
def initialize(url:)
|
10
|
-
@url = url
|
11
|
-
@api_map = Puree::API::Map.new
|
12
|
-
@headers = {}
|
13
|
-
end
|
14
|
-
|
15
|
-
# Provide credentials if necessary
|
16
|
-
#
|
17
|
-
# @param username [String]
|
18
|
-
# @param password [String]
|
19
|
-
def basic_auth(username:, password:)
|
20
|
-
auth = Base64::strict_encode64("#{username}:#{password}")
|
21
|
-
@headers['Authorization'] = 'Basic ' + auth
|
22
|
-
end
|
23
|
-
|
24
|
-
# Perform a GET request to Pure
|
25
|
-
#
|
26
|
-
# @param uuid [String]
|
27
|
-
# @param id [String]
|
28
|
-
# @param params [Hash]
|
29
|
-
# @param rendering [String]
|
30
|
-
# @param latest_api [Boolean]
|
31
|
-
# @param resource_type [String]
|
32
|
-
# @param limit [Fixnum]
|
33
|
-
# @param offset [Fixnum]
|
34
|
-
# @param created_start [String]
|
35
|
-
# @param created_end [String]
|
36
|
-
# @param modified_start [String]
|
37
|
-
# @param modified_end [String]
|
38
|
-
# @param content_type [String]
|
39
|
-
# @return [HTTP::Response]
|
40
|
-
def get(uuid: nil,
|
41
|
-
id: nil,
|
42
|
-
params: {},
|
43
|
-
rendering: :xml_long,
|
44
|
-
latest_api: true,
|
45
|
-
resource_type:,
|
46
|
-
limit: 20,
|
47
|
-
offset: 0,
|
48
|
-
created_start: nil,
|
49
|
-
created_end: nil,
|
50
|
-
modified_start: nil,
|
51
|
-
modified_end: nil,
|
52
|
-
content_type: nil)
|
53
|
-
@latest_api = latest_api
|
54
|
-
@resource_type = resource_type.to_sym
|
55
|
-
@rendering = rendering
|
56
|
-
@uuid = uuid
|
57
|
-
@id = id
|
58
|
-
@params = params
|
59
|
-
@limit = limit
|
60
|
-
@offset = offset
|
61
|
-
@created_start = created_start
|
62
|
-
@created_end = created_end
|
63
|
-
@modified_start = modified_start
|
64
|
-
@modified_end = modified_end
|
65
|
-
@content_type = content_type
|
66
|
-
|
67
|
-
# strip any trailing slash
|
68
|
-
@url = @url.sub(/(\/)+$/, '')
|
69
|
-
@headers['Accept'] = 'application/xml'
|
70
|
-
@req = HTTP.headers accept: @headers['Accept']
|
71
|
-
if @headers['Authorization']
|
72
|
-
@req = @req.auth @headers['Authorization']
|
73
|
-
end
|
74
|
-
@req.get(build_url, params: parameters)
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def parameters
|
80
|
-
query = {}
|
81
|
-
if @uuid
|
82
|
-
query['uuids.uuid'] = @uuid
|
83
|
-
else
|
84
|
-
if @id
|
85
|
-
query['pureInternalIds.id'] = @id
|
86
|
-
end
|
87
|
-
end
|
88
|
-
query['rendering'] = @rendering
|
89
|
-
if @resource_type != :server
|
90
|
-
query['window.size'] = @limit
|
91
|
-
query['window.offset'] = @offset if @limit > 0
|
92
|
-
end
|
93
|
-
|
94
|
-
# Pure does allow blank value
|
95
|
-
query['contentType'] = @content_type if @content_type
|
96
|
-
|
97
|
-
# Pure does not allow blanks for these
|
98
|
-
query['createdDate.toDate'] = @created_start if @created_start
|
99
|
-
query['createdDate.fromDate'] = @created_end if @created_end
|
100
|
-
query['modifiedDate.toDate'] = @modified_start if @modified_start
|
101
|
-
query['modifiedDate.fromDate'] = @modified_end if @modified_end
|
102
|
-
query
|
103
|
-
end
|
104
|
-
|
105
|
-
def build_url
|
106
|
-
service = @api_map.service_name(@resource_type)
|
107
|
-
if @latest_api === false
|
108
|
-
service_api_mode = service
|
109
|
-
else
|
110
|
-
service_api_mode = service + '.current'
|
111
|
-
end
|
112
|
-
@url + '/' + service_api_mode
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Extractor
|
4
|
-
|
5
|
-
# A collection extractor can retrieve any number of resources of the same type.
|
6
|
-
#
|
7
|
-
class Collection
|
8
|
-
include Puree::API::Authentication
|
9
|
-
|
10
|
-
# @option (see Puree::API::Authentication#configure_api)
|
11
|
-
# @param resource [Symbol]
|
12
|
-
def initialize(config:, resource:)
|
13
|
-
@resource_type = resource
|
14
|
-
@api_map = Puree::API::Map.new.get
|
15
|
-
configure_api config
|
16
|
-
end
|
17
|
-
|
18
|
-
# Gets an array of objects of resource type specified in constructor.
|
19
|
-
#
|
20
|
-
# @param limit [Fixnum]
|
21
|
-
# @param offset [Fixnum]
|
22
|
-
# @param created_start [String] using format YYYY-MM-DD
|
23
|
-
# @param created_end [String] using format YYYY-MM-DD
|
24
|
-
# @param modified_start [String] using format YYYY-MM-DD
|
25
|
-
# @param modified_end [String] using format YYYY-MM-DD
|
26
|
-
# @return [Array<Puree::Model::Resource subclass>] Resource metadata e.g. Puree::Model::Dataset.
|
27
|
-
def get(
|
28
|
-
limit: 0,
|
29
|
-
offset: 0,
|
30
|
-
created_start: nil,
|
31
|
-
created_end: nil,
|
32
|
-
modified_start: nil,
|
33
|
-
modified_end: nil
|
34
|
-
)
|
35
|
-
@response = @request.get rendering: :system,
|
36
|
-
limit: limit,
|
37
|
-
offset: offset,
|
38
|
-
resource_type: @resource_type,
|
39
|
-
created_start: created_start,
|
40
|
-
created_end: created_end,
|
41
|
-
modified_start: modified_start,
|
42
|
-
modified_end: modified_end
|
43
|
-
set_content @response.body
|
44
|
-
end
|
45
|
-
|
46
|
-
# Gets a random resource of type specified in constructor.
|
47
|
-
#
|
48
|
-
# @return [Puree::Model::Resource subclass, nil] Resource metadata e.g. Puree::Model::Dataset.
|
49
|
-
def random_resource
|
50
|
-
@response = @request.get rendering: :system,
|
51
|
-
limit: 1,
|
52
|
-
offset: rand(0..count-1),
|
53
|
-
resource_type: @resource_type
|
54
|
-
content = set_content @response.body
|
55
|
-
content[0] if content
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
# Count of records available for a resource type.
|
60
|
-
#
|
61
|
-
# @return [Fixnum]
|
62
|
-
def count
|
63
|
-
get_count
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
# Array of UUIDs (from system response).
|
69
|
-
#
|
70
|
-
# @return [Array<String>]
|
71
|
-
def uuids
|
72
|
-
@extractor.uuids
|
73
|
-
end
|
74
|
-
|
75
|
-
def combine_metadata
|
76
|
-
collect_resources
|
77
|
-
end
|
78
|
-
|
79
|
-
def get_count
|
80
|
-
@response = @request.get resource_type: @resource_type,
|
81
|
-
rendering: :system,
|
82
|
-
limit: 0
|
83
|
-
make_xml_extractor
|
84
|
-
@extractor.count
|
85
|
-
end
|
86
|
-
|
87
|
-
def collect_resources
|
88
|
-
data = []
|
89
|
-
resource_class = "Puree::Extractor::#{Puree::Util::String.titleize(@resource_type)}"
|
90
|
-
|
91
|
-
# whitelist symbol
|
92
|
-
if @api_map[:resource_type].has_key?(@resource_type)
|
93
|
-
config = {
|
94
|
-
url: @config.url,
|
95
|
-
username: @config.username,
|
96
|
-
password: @config.password
|
97
|
-
}
|
98
|
-
|
99
|
-
uuids.each do |u|
|
100
|
-
r = Object.const_get(resource_class).new config
|
101
|
-
record = r.find uuid: u
|
102
|
-
data << record
|
103
|
-
end
|
104
|
-
data
|
105
|
-
else
|
106
|
-
raise 'Invalid resource class'
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# Set content from XML. In order for metadata extraction to work, the XML must have
|
111
|
-
# been retrieved using the .current version of the Pure API endpoints
|
112
|
-
#
|
113
|
-
# @param xml [String]
|
114
|
-
def set_content(xml)
|
115
|
-
if xml
|
116
|
-
make_xml_extractor
|
117
|
-
@extractor.get_data? ? combine_metadata : nil
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def make_xml_extractor
|
122
|
-
@extractor = Puree::XMLExtractor::Collection.new xml: @response.body
|
123
|
-
end
|
124
|
-
|
125
|
-
alias :find :get
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Extractor
|
4
|
-
|
5
|
-
# Download extractor.
|
6
|
-
#
|
7
|
-
class Download
|
8
|
-
include Puree::API::Authentication
|
9
|
-
|
10
|
-
# @option (see Puree::API::Authentication#configure_api)
|
11
|
-
def initialize(config)
|
12
|
-
@resource_type = :download
|
13
|
-
@api_map = Puree::API::Map.new.get # Workararound to provide access to service_family
|
14
|
-
configure_api config
|
15
|
-
end
|
16
|
-
|
17
|
-
# Get download statistics. Only for Datasets.
|
18
|
-
#
|
19
|
-
# @param limit [Fixnum]
|
20
|
-
# @param offset [Fixnum]
|
21
|
-
# @param resource [Symbol] The resource being reported
|
22
|
-
# @return [Array<Puree::Model::DownloadHeader>]
|
23
|
-
def get(limit: 0,
|
24
|
-
offset: 0,
|
25
|
-
resource:)
|
26
|
-
raise 'Cannot perform a request without a configuration' if @config.nil?
|
27
|
-
@response = @request.get rendering: :system,
|
28
|
-
limit: limit,
|
29
|
-
offset: offset,
|
30
|
-
resource_type: @resource_type,
|
31
|
-
content_type: service_family(resource)
|
32
|
-
set_content @response.body
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def combine_metadata
|
38
|
-
@extractor.statistics
|
39
|
-
end
|
40
|
-
|
41
|
-
# Set content from XML. In order for metadata extraction to work, the XML must have
|
42
|
-
# been retrieved using the .current version of the Pure API endpoints
|
43
|
-
#
|
44
|
-
# @param xml [String]
|
45
|
-
def set_content(xml)
|
46
|
-
if xml
|
47
|
-
make_extractor
|
48
|
-
@extractor.get_data? ? combine_metadata : []
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def make_extractor
|
53
|
-
@extractor = Puree::XMLExtractor::Download.new xml: @response.body
|
54
|
-
end
|
55
|
-
|
56
|
-
def service_family(resource_type)
|
57
|
-
if @api_map[:resource_type].has_key? resource_type
|
58
|
-
# Family data is only populated for datasets (required for download)
|
59
|
-
@api_map[:resource_type][resource_type][:family]
|
60
|
-
else
|
61
|
-
raise "#{resource_type} is an unrecognised resource type"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
alias :find :get
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Extractor
|
4
|
-
|
5
|
-
# Organisation extractor.
|
6
|
-
#
|
7
|
-
class Organisation < Puree::Extractor::Resource
|
8
|
-
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
setup :organisation
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def combine_metadata
|
18
|
-
super
|
19
|
-
@model.address = @extractor.address
|
20
|
-
@model.email_addresses = @extractor.email_addresses
|
21
|
-
@model.name = @extractor.name
|
22
|
-
@model.organisations = @extractor.organisations
|
23
|
-
@model.parent = @extractor.parent
|
24
|
-
@model.phone_numbers = @extractor.phone_numbers
|
25
|
-
@model.type = @extractor.type
|
26
|
-
@model.urls = @extractor.urls
|
27
|
-
@model
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
module Extractor
|
3
|
-
|
4
|
-
# Paper base extractor.
|
5
|
-
# Do not use directly.
|
6
|
-
#
|
7
|
-
class PaperBase < Puree::Extractor::Publication
|
8
|
-
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def combine_metadata
|
17
|
-
super
|
18
|
-
|
19
|
-
@model.pages = @extractor.pages
|
20
|
-
@model.page_range = @extractor.page_range
|
21
|
-
@model.peer_reviewed = @extractor.peer_reviewed
|
22
|
-
@model
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Extractor
|
4
|
-
|
5
|
-
# Publication extractor.
|
6
|
-
#
|
7
|
-
class Publication < Puree::Extractor::Resource
|
8
|
-
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
setup :publication
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def combine_metadata
|
18
|
-
super
|
19
|
-
|
20
|
-
@model.associated = @extractor.associated
|
21
|
-
@model.bibliographical_note = @extractor.bibliographical_note
|
22
|
-
@model.category = @extractor.category
|
23
|
-
@model.description = @extractor.description
|
24
|
-
@model.doi = @extractor.doi
|
25
|
-
@model.dois = @extractor.dois
|
26
|
-
@model.external_organisations = @extractor.external_organisations
|
27
|
-
@model.files = @extractor.files
|
28
|
-
@model.keywords = @extractor.keywords
|
29
|
-
@model.language = @extractor.language
|
30
|
-
@model.links = @extractor.links
|
31
|
-
@model.organisations = @extractor.organisations
|
32
|
-
@model.owner = @extractor.owner
|
33
|
-
@model.persons_internal = @extractor.persons_internal
|
34
|
-
@model.persons_external = @extractor.persons_external
|
35
|
-
@model.persons_other = @extractor.persons_other
|
36
|
-
@model.publication_place = @extractor.publication_place
|
37
|
-
@model.publisher = @extractor.publisher
|
38
|
-
@model.scopus_id = @extractor.scopus_id
|
39
|
-
@model.statuses = @extractor.statuses
|
40
|
-
@model.subtitle = @extractor.subtitle
|
41
|
-
@model.title = @extractor.title
|
42
|
-
@model.translated_subtitle = @extractor.translated_subtitle
|
43
|
-
@model.translated_title = @extractor.translated_title
|
44
|
-
@model.type = @extractor.type
|
45
|
-
@model.workflow_state = @extractor.workflow_state
|
46
|
-
@model
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Extractor
|
4
|
-
|
5
|
-
# Server extractor.
|
6
|
-
#
|
7
|
-
class Server
|
8
|
-
include Puree::API::Authentication
|
9
|
-
|
10
|
-
# @option (see Puree::API::Authentication#configure_api)
|
11
|
-
def initialize(config)
|
12
|
-
@resource_type = :server
|
13
|
-
configure_api config
|
14
|
-
end
|
15
|
-
|
16
|
-
# Get server information.
|
17
|
-
#
|
18
|
-
# @return [Puree::Model::Server, nil]
|
19
|
-
def get
|
20
|
-
raise 'Cannot perform a request without a configuration' if @config.nil?
|
21
|
-
@response = @request.get resource_type: @resource_type
|
22
|
-
set_content @response.body
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def combine_metadata
|
28
|
-
model = Puree::Model::Server.new
|
29
|
-
model.version = @extractor.version
|
30
|
-
model
|
31
|
-
end
|
32
|
-
|
33
|
-
# Set content from XML. In order for metadata extraction to work, the XML must have
|
34
|
-
# been retrieved using the .current version of the Pure API endpoints
|
35
|
-
#
|
36
|
-
# @param xml [String]
|
37
|
-
# @return [Puree::Model::Server, nil]
|
38
|
-
def set_content(xml)
|
39
|
-
if xml
|
40
|
-
make_extractor
|
41
|
-
@extractor.get_data? ? combine_metadata : nil
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def make_extractor
|
46
|
-
@extractor = Puree::XMLExtractor::Server.new xml: @response.body
|
47
|
-
end
|
48
|
-
|
49
|
-
alias :find :get
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
module Model
|
3
|
-
|
4
|
-
# A minimal representation of a Download.
|
5
|
-
#
|
6
|
-
class DownloadHeader < Puree::Model::Structure
|
7
|
-
|
8
|
-
# @return [String, nil]
|
9
|
-
attr_reader :uuid
|
10
|
-
|
11
|
-
# @return [Fixnum, nil]
|
12
|
-
attr_accessor :count
|
13
|
-
|
14
|
-
# @param v [String]
|
15
|
-
def uuid=(v)
|
16
|
-
@uuid = v if v && !v.empty?
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
module Model
|
3
|
-
|
4
|
-
# A base paper.
|
5
|
-
#
|
6
|
-
class PaperBase < Puree::Model::Publication
|
7
|
-
|
8
|
-
# @return [Fixnum, nil]
|
9
|
-
attr_accessor :pages
|
10
|
-
|
11
|
-
# @return [String, nil]
|
12
|
-
attr_accessor :page_range
|
13
|
-
|
14
|
-
# @return [Boolean, nil]
|
15
|
-
attr_accessor :peer_reviewed
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/puree/model/server.rb
DELETED
data/lib/puree/query/funding.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module Puree
|
2
|
-
|
3
|
-
module Query
|
4
|
-
|
5
|
-
# For querying information about funding.
|
6
|
-
#
|
7
|
-
class Funding
|
8
|
-
|
9
|
-
def initialize(config)
|
10
|
-
@config = config
|
11
|
-
end
|
12
|
-
|
13
|
-
# Project funders
|
14
|
-
# @param uuid [String] Project UUID.
|
15
|
-
# @return [Array<Puree::Model::ExternalOrganisation>] List of funders which have funded this project.
|
16
|
-
def project_funders(uuid:)
|
17
|
-
funders = []
|
18
|
-
project_extractor = Puree::Extractor::Project.new @config
|
19
|
-
project = project_extractor.find uuid: uuid
|
20
|
-
if project
|
21
|
-
if project.funded
|
22
|
-
project.external_organisations.each do |org|
|
23
|
-
external_organisation_extractor = Puree::Extractor::ExternalOrganisation.new @config
|
24
|
-
external_organisation = external_organisation_extractor.find uuid: org.uuid
|
25
|
-
funders << external_organisation if external_organisation.type == '/dk/atira/pure/ueoexternalorganisation/ueoexternalorganisationtypes/ueoexternalorganisation/researchFundingBody'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
funders.uniq { |i| i.uuid }
|
30
|
-
end
|
31
|
-
|
32
|
-
# Publication funders
|
33
|
-
# @param uuid [String] Publication UUID.
|
34
|
-
# @return [Array<Puree::Model::ExternalOrganisation>] List of funders which have funded this publication via a project.
|
35
|
-
def publication_funders(uuid:)
|
36
|
-
funders = []
|
37
|
-
publication_extractor = Puree::Extractor::Publication.new @config
|
38
|
-
publication = publication_extractor.find uuid: uuid
|
39
|
-
if publication
|
40
|
-
publication.associated.each do |associated|
|
41
|
-
if associated.type == 'Research'
|
42
|
-
single_project_funders = project_funders uuid: associated.uuid
|
43
|
-
funders += single_project_funders
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
funders.uniq { |i| i.uuid }
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|