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
@@ -0,0 +1,18 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Owner mixin.
|
6
|
+
#
|
7
|
+
module OwnerMixin
|
8
|
+
|
9
|
+
# @return [Puree::Model::OrganisationalUnitHeader, nil]
|
10
|
+
def owner
|
11
|
+
xpath_result = xpath_query '/managingOrganisationalUnit'
|
12
|
+
Puree::XMLExtractor::Shared.organisation_header xpath_result
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -8,7 +8,7 @@ module Puree
|
|
8
8
|
|
9
9
|
# @return [Boolean, nil]
|
10
10
|
def peer_reviewed
|
11
|
-
xpath_result = xpath_query_for_single_value('/peerReview
|
11
|
+
xpath_result = xpath_query_for_single_value('/peerReview')
|
12
12
|
return true if xpath_result === 'true'
|
13
13
|
return false if xpath_result === 'false'
|
14
14
|
nil
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Person mixin.
|
6
|
+
#
|
7
|
+
module PersonMixin
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# @return [Array<Puree::Model::EndeavourPerson>]
|
12
|
+
def persons(type, xpath_query_path)
|
13
|
+
xpath_result = xpath_query xpath_query_path
|
14
|
+
arr = []
|
15
|
+
xpath_result.each do |i|
|
16
|
+
uuid_internal = i.at_xpath('person/@uuid')
|
17
|
+
uuid_external = i.at_xpath('externalPerson/@uuid')
|
18
|
+
if uuid_internal
|
19
|
+
person_type = 'internal'
|
20
|
+
uuid = uuid_internal.text.strip
|
21
|
+
elsif uuid_external
|
22
|
+
person_type = 'external'
|
23
|
+
uuid = uuid_external.text.strip
|
24
|
+
else
|
25
|
+
person_type = 'other'
|
26
|
+
uuid = ''
|
27
|
+
end
|
28
|
+
if person_type === type
|
29
|
+
person = Puree::Model::EndeavourPerson.new
|
30
|
+
person.uuid = uuid
|
31
|
+
name = Puree::Model::PersonName.new
|
32
|
+
name.first = i.xpath('name/firstName').text.strip
|
33
|
+
name.last = i.xpath('name/lastName').text.strip
|
34
|
+
person.name = name if name.data?
|
35
|
+
person.role = i.xpath('personRole').text.strip
|
36
|
+
arr << person if person.data?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
arr
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Publisher extractor mixin.
|
6
|
+
#
|
7
|
+
module PublisherMixin
|
8
|
+
|
9
|
+
# @return [Puree::Model::PublisherHeader, nil]
|
10
|
+
def publisher
|
11
|
+
xpath_result = xpath_query '/publisher'
|
12
|
+
h = Puree::Model::PublisherHeader.new
|
13
|
+
h.uuid = xpath_result.xpath('@uuid').text.strip
|
14
|
+
h.name = xpath_result.xpath('name').text.strip
|
15
|
+
h.type = xpath_result.xpath('type').text.strip
|
16
|
+
h.data? ? h : nil
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -2,19 +2,19 @@ module Puree
|
|
2
2
|
|
3
3
|
module XMLExtractor
|
4
4
|
|
5
|
-
#
|
5
|
+
# Research output extractor mixin.
|
6
6
|
#
|
7
|
-
module
|
7
|
+
module ResearchOutputMixin
|
8
8
|
|
9
|
-
#
|
9
|
+
# Related research outputs
|
10
10
|
# @return [Array<Puree::Model::RelatedContentHeader>]
|
11
|
-
def
|
12
|
-
xpath_result = xpath_query '/
|
11
|
+
def research_outputs
|
12
|
+
xpath_result = xpath_query '/relatedResearchOutputs/relatedResearchOutput'
|
13
13
|
data_arr = []
|
14
14
|
xpath_result.each { |i|
|
15
15
|
related = Puree::Model::RelatedContentHeader.new
|
16
|
-
related.type = i.xpath('
|
17
|
-
related.title = i.xpath('
|
16
|
+
related.type = i.xpath('type').text.strip
|
17
|
+
related.title = i.xpath('name').text.strip
|
18
18
|
related.uuid = i.attr('uuid').strip
|
19
19
|
data_arr << related
|
20
20
|
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Organisational unit XML extractor.
|
6
|
+
#
|
7
|
+
class OrganisationalUnit < Puree::XMLExtractor::Resource
|
8
|
+
include Puree::XMLExtractor::TypeMixin
|
9
|
+
|
10
|
+
def initialize(xml)
|
11
|
+
super
|
12
|
+
setup_model :organisational_unit
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Puree::Model::Address]
|
16
|
+
def address
|
17
|
+
xpath_result = xpath_query '/addresses/address'
|
18
|
+
if !xpath_result.empty?
|
19
|
+
a = Puree::Model::Address.new
|
20
|
+
street = xpath_result.xpath('street').text.strip
|
21
|
+
a.street = street unless street.empty?
|
22
|
+
building = xpath_result.xpath('building').text.strip
|
23
|
+
a.building = building unless building.empty?
|
24
|
+
postcode = xpath_result.xpath('postalCode').text.strip
|
25
|
+
a.postcode = postcode unless building.empty?
|
26
|
+
city = xpath_result.xpath('city').text.strip
|
27
|
+
a.city = city unless city.empty?
|
28
|
+
country = xpath_result.xpath('country').text.strip
|
29
|
+
a.country = country unless country.empty?
|
30
|
+
a
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Array<String>]
|
35
|
+
def email_addresses
|
36
|
+
xpath_query_for_multi_value '/emails/email'
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [String, nil]
|
40
|
+
def name
|
41
|
+
xpath_query_for_single_value '/name'
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Puree::Model::OrganisationalUnitHeader, nil]
|
45
|
+
def parent
|
46
|
+
xpath_result = xpath_query '/parents/parent'
|
47
|
+
Puree::XMLExtractor::Shared.organisation_header xpath_result
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Array<String>]
|
51
|
+
def phone_numbers
|
52
|
+
xpath_query_for_multi_value '/phoneNumbers/phoneNumber'
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Array<String>]
|
56
|
+
def urls
|
57
|
+
xpath_query_for_multi_value '/webAddresses/webAddress'
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def xpath_root
|
63
|
+
'/organisationalUnit'
|
64
|
+
end
|
65
|
+
|
66
|
+
def combine_metadata
|
67
|
+
super
|
68
|
+
@model.address = address
|
69
|
+
@model.email_addresses = email_addresses
|
70
|
+
@model.name = name
|
71
|
+
@model.parent = parent
|
72
|
+
@model.phone_numbers = phone_numbers
|
73
|
+
@model.type = type
|
74
|
+
@model.urls = urls
|
75
|
+
@model
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -1,14 +1,28 @@
|
|
1
1
|
module Puree
|
2
2
|
module XMLExtractor
|
3
3
|
|
4
|
-
# Paper XML extractor.
|
4
|
+
# Paper base XML extractor.
|
5
5
|
#
|
6
|
-
class Paper < Puree::XMLExtractor::
|
6
|
+
class Paper < Puree::XMLExtractor::ResearchOutput
|
7
|
+
include Puree::XMLExtractor::PagesMixin
|
8
|
+
include Puree::XMLExtractor::PageRangeMixin
|
9
|
+
include Puree::XMLExtractor::PeerReviewedMixin
|
7
10
|
|
8
|
-
def initialize(xml
|
11
|
+
def initialize(xml)
|
9
12
|
super
|
13
|
+
setup_model :paper
|
10
14
|
end
|
11
15
|
|
16
|
+
private
|
17
|
+
|
18
|
+
def combine_metadata
|
19
|
+
super
|
20
|
+
@model.pages = pages
|
21
|
+
@model.page_range = page_range
|
22
|
+
@model.peer_reviewed = peer_reviewed
|
23
|
+
@model
|
24
|
+
end
|
25
|
+
|
12
26
|
end
|
13
27
|
end
|
14
28
|
end
|
@@ -5,47 +5,44 @@ module Puree
|
|
5
5
|
# Person XML extractor.
|
6
6
|
#
|
7
7
|
class Person < Puree::XMLExtractor::Resource
|
8
|
+
include Puree::XMLExtractor::IdentifierMixin
|
9
|
+
include Puree::XMLExtractor::KeywordMixin
|
8
10
|
|
9
|
-
def initialize(xml
|
11
|
+
def initialize(xml)
|
10
12
|
super
|
11
|
-
|
13
|
+
setup_model :person
|
12
14
|
end
|
13
15
|
|
14
|
-
# @return [Array<Puree::Model::
|
16
|
+
# @return [Array<Puree::Model::OrganisationalUnitHeader>]
|
15
17
|
def affiliations
|
16
|
-
xpath_result = xpath_query '
|
17
|
-
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
|
18
|
+
xpath_result = xpath_query '/staffOrganisationAssociations/staffOrganisationAssociation/organisationalUnit'
|
19
|
+
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result if xpath_result
|
18
20
|
end
|
19
21
|
|
20
22
|
# @return [Array<String>]
|
21
23
|
def email_addresses
|
22
|
-
xpath_query_for_multi_value '
|
23
|
-
end
|
24
|
-
|
25
|
-
# @return [String, nil]
|
26
|
-
def employee_id
|
27
|
-
id '/dk/atira/pure/person/personsources/employee'
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [String, nil]
|
31
|
-
def hesa_id
|
32
|
-
id '/dk/atira/pure/person/personsources/hesastaff'
|
24
|
+
xpath_query_for_multi_value '/staffOrganisationAssociations/staffOrganisationAssociation/emails/email'
|
33
25
|
end
|
34
26
|
|
35
27
|
# @return [Array<String>]
|
36
28
|
def image_urls
|
37
|
-
|
29
|
+
xpath_result = xpath_query '/profilePhotos/profilePhoto'
|
30
|
+
arr = []
|
31
|
+
xpath_result.each do |i|
|
32
|
+
arr << i.attr('url').strip
|
33
|
+
end
|
34
|
+
arr.uniq
|
38
35
|
end
|
39
36
|
|
40
37
|
# @return [Array<String>]
|
41
38
|
def keywords
|
42
|
-
|
39
|
+
keyword_group 'userDefinedKeywordContainers'
|
43
40
|
end
|
44
41
|
|
45
42
|
# @return [Puree::Model::PersonName, nil]
|
46
43
|
def name
|
47
44
|
xpath_result = xpath_query '/name'
|
48
|
-
if xpath_result
|
45
|
+
if !xpath_result.empty?
|
49
46
|
first = xpath_result.xpath('firstName').text.strip
|
50
47
|
last = xpath_result.xpath('lastName').text.strip
|
51
48
|
model = Puree::Model::PersonName.new
|
@@ -60,26 +57,24 @@ module Puree
|
|
60
57
|
xpath_query_for_single_value '/orcid'
|
61
58
|
end
|
62
59
|
|
63
|
-
# @return [String, nil]
|
64
|
-
def scopus_id
|
65
|
-
id '/dk/atira/pure/person/personsources/scopusauthor'
|
66
|
-
end
|
67
|
-
|
68
60
|
private
|
69
61
|
|
70
|
-
|
71
|
-
|
72
|
-
xpath_result = xpath_query '/sources/classificationDefinedStringFieldExtension'
|
73
|
-
if xpath_result
|
74
|
-
xpath_result.each do |i|
|
75
|
-
if i.xpath('classification/uri').text.strip === uri
|
76
|
-
return i.xpath('value').text.strip
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
nil
|
62
|
+
def xpath_root
|
63
|
+
'/person'
|
81
64
|
end
|
82
65
|
|
66
|
+
def combine_metadata
|
67
|
+
super
|
68
|
+
@model.affiliations = affiliations
|
69
|
+
@model.email_addresses = email_addresses
|
70
|
+
@model.identifiers = identifiers
|
71
|
+
@model.image_urls = image_urls
|
72
|
+
@model.keywords = keywords
|
73
|
+
@model.name = name
|
74
|
+
@model.orcid = orcid
|
75
|
+
@model
|
76
|
+
end
|
77
|
+
|
83
78
|
end
|
84
79
|
|
85
80
|
end
|
@@ -5,12 +5,16 @@ module Puree
|
|
5
5
|
# Project XML extractor.
|
6
6
|
#
|
7
7
|
class Project < Puree::XMLExtractor::Resource
|
8
|
-
|
9
|
-
include Puree::XMLExtractor::
|
10
|
-
|
11
|
-
|
8
|
+
include Puree::XMLExtractor::ExternalOrganisationMixin
|
9
|
+
include Puree::XMLExtractor::IdentifierMixin
|
10
|
+
include Puree::XMLExtractor::OrganisationalUnitMixin
|
11
|
+
include Puree::XMLExtractor::PersonMixin
|
12
|
+
include Puree::XMLExtractor::TitleMixin
|
13
|
+
include Puree::XMLExtractor::TypeMixin
|
14
|
+
|
15
|
+
def initialize(xml)
|
12
16
|
super
|
13
|
-
|
17
|
+
setup_model :project
|
14
18
|
end
|
15
19
|
|
16
20
|
# @return [String, nil]
|
@@ -20,23 +24,10 @@ module Puree
|
|
20
24
|
|
21
25
|
# @return [String, nil]
|
22
26
|
def description
|
23
|
-
xpath_query_for_single_value '/description
|
24
|
-
end
|
25
|
-
|
26
|
-
# @return [Boolean]
|
27
|
-
def funded?
|
28
|
-
xpath_result = xpath_query_for_single_value '/type'
|
29
|
-
return false if xpath_result.downcase.include? 'nonfunded'
|
30
|
-
true
|
31
|
-
end
|
32
|
-
|
33
|
-
# @return [Array<Puree::Model::OrganisationHeader>]
|
34
|
-
def organisations
|
35
|
-
xpath_result = xpath_query '/organisations/association/organisation'
|
36
|
-
Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
|
27
|
+
xpath_query_for_single_value '/descriptions/description'
|
37
28
|
end
|
38
29
|
|
39
|
-
# @return [Puree::Model::
|
30
|
+
# @return [Puree::Model::OrganisationalUnitHeader, nil]
|
40
31
|
def owner
|
41
32
|
xpath_result = xpath_query '/owner'
|
42
33
|
Puree::XMLExtractor::Shared.organisation_header xpath_result
|
@@ -44,86 +35,59 @@ module Puree
|
|
44
35
|
|
45
36
|
# @return [Array<Puree::Model::EndeavourPerson>]
|
46
37
|
def persons_internal
|
47
|
-
persons 'internal'
|
38
|
+
persons 'internal', '/participants/participant'
|
48
39
|
end
|
49
40
|
|
50
41
|
# @return [Array<Puree::Model::EndeavourPerson>]
|
51
42
|
def persons_external
|
52
|
-
persons 'external'
|
43
|
+
persons 'external', '/participants/participant'
|
53
44
|
end
|
54
45
|
|
55
46
|
# @return [Array<Puree::Model::EndeavourPerson>]
|
56
47
|
def persons_other
|
57
|
-
persons 'other'
|
48
|
+
persons 'other', '/participants/participant'
|
58
49
|
end
|
59
50
|
|
60
51
|
# @return [String, nil]
|
61
52
|
def status
|
62
|
-
xpath_query_for_single_value '/status
|
53
|
+
xpath_query_for_single_value '/status'
|
63
54
|
end
|
64
55
|
|
65
56
|
# @return [Puree::Model::TemporalRange, nil]
|
66
|
-
def
|
67
|
-
temporal_range '/
|
68
|
-
end
|
69
|
-
|
70
|
-
# @return [Puree::Model::TemporalRange, nil]
|
71
|
-
def temporal_actual
|
72
|
-
temporal_range '/startFinishDate/startDate', '/startFinishDate/endDate'
|
73
|
-
end
|
74
|
-
|
75
|
-
# @return [String, nil]
|
76
|
-
def title
|
77
|
-
xpath_query_for_single_value '/title/localizedString'
|
78
|
-
end
|
79
|
-
|
80
|
-
# @return [String, nil]
|
81
|
-
def type
|
82
|
-
xpath_query_for_single_value '/typeClassification/term/localizedString'
|
57
|
+
def temporal
|
58
|
+
temporal_range '/period/startDate', '/period/endDate'
|
83
59
|
end
|
84
60
|
|
85
61
|
# @return [String, nil]
|
86
62
|
def url
|
87
|
-
xpath_query_for_single_value '/
|
63
|
+
xpath_query_for_single_value '/links/link/url'
|
88
64
|
end
|
89
65
|
|
90
66
|
private
|
91
67
|
|
92
|
-
|
93
|
-
|
94
|
-
xpath_result = xpath_query '/persons/participantAssociation'
|
95
|
-
arr = []
|
96
|
-
xpath_result.each do |i|
|
97
|
-
uuid_internal = i.at_xpath('person/@uuid')
|
98
|
-
uuid_external = i.at_xpath('externalPerson/@uuid')
|
99
|
-
if uuid_internal
|
100
|
-
person_type = 'internal'
|
101
|
-
uuid = uuid_internal.text.strip
|
102
|
-
elsif uuid_external
|
103
|
-
person_type = 'external'
|
104
|
-
uuid = uuid_external.text.strip
|
105
|
-
else
|
106
|
-
person_type = 'other'
|
107
|
-
uuid = ''
|
108
|
-
end
|
109
|
-
if person_type === type
|
110
|
-
person = Puree::Model::EndeavourPerson.new
|
111
|
-
person.uuid = uuid
|
112
|
-
|
113
|
-
name = Puree::Model::PersonName.new
|
114
|
-
name.first = i.xpath('person/name/firstName').text.strip
|
115
|
-
name.last = i.xpath('person/name/lastName').text.strip
|
116
|
-
person.name = name
|
117
|
-
|
118
|
-
role = i.xpath('personRole/term/localizedString').text.strip
|
119
|
-
person.role = role
|
120
|
-
|
121
|
-
arr << person if person.data?
|
122
|
-
end
|
123
|
-
end
|
124
|
-
arr.uniq { |d| d.uuid }
|
68
|
+
def xpath_root
|
69
|
+
'/project'
|
125
70
|
end
|
126
71
|
|
72
|
+
def combine_metadata
|
73
|
+
super
|
74
|
+
@model.acronym = acronym
|
75
|
+
@model.description = description
|
76
|
+
@model.external_organisations = external_organisations
|
77
|
+
@model.identifiers = identifiers
|
78
|
+
@model.organisational_units = organisational_units
|
79
|
+
@model.owner = owner
|
80
|
+
@model.persons_internal = persons_internal
|
81
|
+
@model.persons_external = persons_external
|
82
|
+
@model.persons_other = persons_other
|
83
|
+
@model.status = status
|
84
|
+
@model.temporal = temporal
|
85
|
+
@model.title = title
|
86
|
+
@model.type = type
|
87
|
+
@model.url = url
|
88
|
+
@model
|
89
|
+
end
|
90
|
+
|
127
91
|
# @return [Puree::Model::TemporalRange, nil]
|
128
92
|
def temporal_range(start_path, end_path)
|
129
93
|
range_start = xpath_query_for_single_value start_path
|
@@ -5,10 +5,11 @@ module Puree
|
|
5
5
|
# Publisher XML extractor.
|
6
6
|
#
|
7
7
|
class Publisher < 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 :publisher
|
12
13
|
end
|
13
14
|
|
14
15
|
# @return [String, nil]
|
@@ -16,10 +17,18 @@ module Puree
|
|
16
17
|
xpath_query_for_single_value '/name'
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
private
|
21
|
+
|
22
|
+
def xpath_root
|
23
|
+
'/publisher'
|
24
|
+
end
|
25
|
+
|
26
|
+
def combine_metadata
|
27
|
+
super
|
28
|
+
@model.name = name
|
29
|
+
@model.type = type
|
30
|
+
@model
|
31
|
+
end
|
23
32
|
|
24
33
|
end
|
25
34
|
|