Class: Puree::XMLExtractor::ResearchOutput

Inherits:
Resource show all
Includes:
AbstractMixin, KeywordMixin, OrganisationalUnitMixin, OwnerMixin, PersonMixin, ProjectMixin, ResearchOutputMixin, 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 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

Returns a new instance of ResearchOutput.



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

def initialize(xml)
  super
  setup_model :research_output
end

Instance Method Details

#bibliographical_noteString?

Returns:

  • (String, nil)


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

def bibliographical_note
  xpath_query_for_single_value '/bibliographicalNote/text'
end

#categoryString?

Returns:

  • (String, nil)


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

def category
  xpath_query_for_single_value '/category/term/text'
end

#doiPuree::Model::DOI?

Digital Object Identifier (first one, if many)

Returns:

  • (Puree::Model::DOI, nil)


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

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

#doisArray<String>

Digital Object Identifiers

Returns:

  • (Array<String>)


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

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

#filesArray<Puree::Model::File>

Returns:



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

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>

Returns:

  • (Array<String>)


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

def keywords
  keyword_group 'keywordContainers'
end

#languageString?

Returns:

  • (String, nil)


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

def language
  xpath_query_for_single_value '/language/term/text'
end

Returns:

  • (Array<String>, nil)


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

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

#open_access_permissionString?

Returns:

  • (String, nil)


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

def open_access_permission
  xpath_query_for_single_value '/openAccessPermission/term/text'
end

#persons_externalArray<Puree::Model::EndeavourPerson>

Returns:



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

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

#persons_internalArray<Puree::Model::EndeavourPerson>

Returns:



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

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

#persons_otherArray<Puree::Model::EndeavourPerson>

Returns:



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

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

#publication_statusesArray<Puree::Model::PublicationStatus>



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

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/term/text').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?

Returns:

  • (Integer, nil)


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

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

#scopus_idString?

Returns:

  • (String, nil)


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

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

#scopus_metricsArray<Puree::Model::ResearchOutputScopusMetric>



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

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?

Returns:

  • (String, nil)


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

def subtitle
  xpath_query_for_single_value '/subTitle'
end

#titleString?

Returns:

  • (String, nil)


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

def title
  xpath_query_for_single_value '/title'
end

#translated_subtitleString?

Returns:

  • (String, nil)


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

def translated_subtitle
  xpath_query_for_single_value '/translatedSubTitle/text'
end

#translated_titleString?

Returns:

  • (String, nil)


167
168
169
# File 'lib/puree/xml_extractor/research_output.rb', line 167

def translated_title
  xpath_query_for_single_value '/translatedTitle/text'
end