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, #model, #modified_at, #modified_by, #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.



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?

Returns:

  • (String, nil)


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

def bibliographical_note
  xpath_query_for_single_value('/bibliographicalNote')
end

#categoryString?

Returns:

  • (String, nil)


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

def category
  xpath_query_for_single_value '/category'
end

#doiString?

Digital Object Identifier

Returns:

  • (String, nil)


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

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

#filesArray<Puree::Model::File>

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/puree/xml_extractor/research_output.rb', line 41

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/URL').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>)


63
64
65
# File 'lib/puree/xml_extractor/research_output.rb', line 63

def keywords
  keyword_group 'keywordContainers'
end

#languageString?

Returns:

  • (String, nil)


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

def language
  xpath_query_for_single_value '/language'
end

Returns:

  • (Array<String>, nil)


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

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

#open_access_permissionString?

Returns:

  • (String, nil)


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

def open_access_permission
  xpath_query_for_single_value '/openAccessPermission'
end

#persons_externalArray<Puree::Model::EndeavourPerson>

Returns:



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

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

#persons_internalArray<Puree::Model::EndeavourPerson>

Returns:



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

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

#persons_otherArray<Puree::Model::EndeavourPerson>

Returns:



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

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

#publication_statusesArray<Puree::Model::PublicationStatus>



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/puree/xml_extractor/research_output.rb', line 98

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_countFixnum?

Returns:

  • (Fixnum, nil)


118
119
120
121
# File 'lib/puree/xml_extractor/research_output.rb', line 118

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)


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

def scopus_id
  xpath_result = xpath_query '/externalableInfo/secondarySources/secondarySource'
  return if xpath_result.empty?
  source = xpath_result.xpath('source')
  if source && source.text.strip.downcase === 'scopus'
    return xpath_result.xpath('sourceId').text.strip
  end
end

#scopus_metricsArray<Puree::Model::ResearchOutputScopusMetric>



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/puree/xml_extractor/research_output.rb', line 134

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
    s.year = i.xpath('year').text.strip
    data << s
  end
  data
end

#subtitleString?

Returns:

  • (String, nil)


147
148
149
# File 'lib/puree/xml_extractor/research_output.rb', line 147

def subtitle
  xpath_query_for_single_value '/subTitle'
end

#translated_subtitleString?

Returns:

  • (String, nil)


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

def translated_subtitle
  xpath_query_for_single_value '/translatedSubTitle'
end

#translated_titleString?

Returns:

  • (String, nil)


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

def translated_title
  xpath_query_for_single_value '/translatedTitle'
end