Class: Puree::XMLExtractor::ResearchOutput

Inherits:
Resource show all
Includes:
AbstractMixin, KeywordMixin, OrganisationalUnitMixin, OwnerMixin, PersonMixin, ProjectMixin, ResearchOutputMixin, TitleMixin, TypeMixin, WorkflowMixin
Defined in:
lib/puree/xml_extractor/research_output.rb

Overview

Research output XML extractor.

Direct Known Subclasses

JournalArticle, Paper, Thesis

Instance Method Summary collapse

Methods included from TypeMixin

#type

Methods included from TitleMixin

#title

Methods included from WorkflowMixin

#workflow

Methods included from ResearchOutputMixin

#research_outputs

Methods included from ProjectMixin

#projects

Methods included from OwnerMixin

#owner

Methods included from OrganisationalUnitMixin

#organisational_units

Methods included from AbstractMixin

#description

Methods inherited from Resource

#created_at, #created_by, #id, #model, #modified_at, #modified_by, #previous_uuids, #uuid

Methods inherited from Base

#xpath_query_for_multi_value, #xpath_query_for_single_value

Constructor Details

#initialize(xml) ⇒ ResearchOutput



19
20
21
22
# File 'lib/puree/xml_extractor/research_output.rb', line 19

def initialize(xml)
  super
  setup_model :research_output
end

Instance Method Details

#bibliographical_noteString?



25
26
27
# File 'lib/puree/xml_extractor/research_output.rb', line 25

def bibliographical_note
  xpath_query_for_single_value('/bibliographicalNote')
end

#categoryString?



30
31
32
# File 'lib/puree/xml_extractor/research_output.rb', line 30

def category
  xpath_query_for_single_value '/category'
end

#doiPuree::Model::DOI?

Digital Object Identifier (first one, if many)



36
37
38
39
# File 'lib/puree/xml_extractor/research_output.rb', line 36

def doi
  multiple_dois = dois
  multiple_dois.empty? ? nil : multiple_dois.first
end

#doisArray<String>

Digital Object Identifiers



43
44
45
# File 'lib/puree/xml_extractor/research_output.rb', line 43

def dois
  xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionDoiAssociation"]/doi'
end

#filesArray<Puree::Model::File>



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/puree/xml_extractor/research_output.rb', line 48

def files
  xpath_result = xpath_query '/electronicVersions/electronicVersion[@type="wsElectronicVersionFileAssociation"]'
  docs = []
  xpath_result.each do |d|
    model = Puree::Model::File.new
    model.name = d.xpath('file/fileName').text.strip
    model.mime = d.xpath('file/mimeType').text.strip
    model.size = d.xpath('file/size').text.strip.to_i
    model.url = d.xpath('file/fileURL').text.strip
    # document_license = d.xpath('licenseType')
    # if !document_license.empty?
    #   license = Puree::Model::CopyrightLicense.new
    #   license.name = document_license.xpath('term/localizedString').text.strip
    #   license.url = document_license.xpath('description/localizedString').text.strip
    #   model.license = license if license.data?
    # end
    docs << model
  end
  docs.uniq { |d| d.url }
end

#keywordsArray<String>



70
71
72
# File 'lib/puree/xml_extractor/research_output.rb', line 70

def keywords
  keyword_group 'keywordContainers'
end

#languageString?



75
76
77
# File 'lib/puree/xml_extractor/research_output.rb', line 75

def language
  xpath_query_for_single_value '/language'
end


80
81
82
# File 'lib/puree/xml_extractor/research_output.rb', line 80

def links
  xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionLinkAssociation"]/link'
end

#open_access_permissionString?



85
86
87
# File 'lib/puree/xml_extractor/research_output.rb', line 85

def open_access_permission
  xpath_query_for_single_value '/openAccessPermission'
end

#persons_externalArray<Puree::Model::EndeavourPerson>



95
96
97
# File 'lib/puree/xml_extractor/research_output.rb', line 95

def persons_external
  persons 'external', '/personAssociations/personAssociation'
end

#persons_internalArray<Puree::Model::EndeavourPerson>



90
91
92
# File 'lib/puree/xml_extractor/research_output.rb', line 90

def persons_internal
  persons 'internal', '/personAssociations/personAssociation'
end

#persons_otherArray<Puree::Model::EndeavourPerson>



100
101
102
# File 'lib/puree/xml_extractor/research_output.rb', line 100

def persons_other
  persons 'other', '/personAssociations/personAssociation'
end

#publication_statusesArray<Puree::Model::PublicationStatus>



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/puree/xml_extractor/research_output.rb', line 105

def publication_statuses
  xpath_result = xpath_query '/publicationStatuses/publicationStatus'
  data = []
  xpath_result.each do |i|
    s = Puree::Model::PublicationStatus.new
    s.stage = i.xpath('publicationStatus').text.strip

    ymd = {}
    ymd['year'] = i.xpath('publicationDate/year').text.strip
    ymd['month'] = i.xpath('publicationDate/month').text.strip
    ymd['day'] = i.xpath('publicationDate/day').text.strip

    s.date = Puree::Util::Date.hash_to_time ymd

    data << s
  end
  data.uniq { |d| d.stage }
end

#scopus_citations_countInteger?



125
126
127
128
# File 'lib/puree/xml_extractor/research_output.rb', line 125

def scopus_citations_count
  xpath_result = xpath_query_for_single_value '/totalScopusCitations'
  xpath_result ? xpath_result.to_i : nil
end

#scopus_idString?



131
132
133
134
135
136
137
# File 'lib/puree/xml_extractor/research_output.rb', line 131

def scopus_id
  external_identifiers.each do |i|
    if i.type.downcase === 'scopus'
      return i.id
    end
  end
end

#scopus_metricsArray<Puree::Model::ResearchOutputScopusMetric>



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/puree/xml_extractor/research_output.rb', line 140

def scopus_metrics
  xpath_result = xpath_query '/scopusMetrics/scopusMetric'
  data = []
  xpath_result.each do |i|
    s = Puree::Model::ResearchOutputScopusMetric.new
    s.value = i.xpath('value').text.strip.to_i
    s.year = i.xpath('year').text.strip.to_i
    data << s
  end
  data
end

#subtitleString?



153
154
155
# File 'lib/puree/xml_extractor/research_output.rb', line 153

def subtitle
  xpath_query_for_single_value '/subTitle'
end

#translated_subtitleString?



158
159
160
# File 'lib/puree/xml_extractor/research_output.rb', line 158

def translated_subtitle
  xpath_query_for_single_value '/translatedSubTitle'
end

#translated_titleString?



163
164
165
# File 'lib/puree/xml_extractor/research_output.rb', line 163

def translated_title
  xpath_query_for_single_value '/translatedTitle'
end