class Puree::XMLExtractor::ResearchOutput

Research output XML extractor.

Public Class Methods

new(xml) click to toggle source
Calls superclass method Puree::XMLExtractor::Resource::new
# File lib/puree/xml_extractor/research_output.rb, line 18
def initialize(xml)
  super
  setup_model :research_output
end

Public Instance Methods

bibliographical_note() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 24
def bibliographical_note
  xpath_query_for_single_value '/bibliographicalNote/text'
end
category() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 29
def category
  xpath_query_for_single_value '/category/term/text'
end
doi() click to toggle source

Digital Object Identifier (first one, if many) @return [Puree::Model::DOI, nil]

# File lib/puree/xml_extractor/research_output.rb, line 35
def doi
  multiple_dois = dois
  multiple_dois.empty? ? nil : multiple_dois.first
end
dois() click to toggle source

Digital Object Identifiers @return [Array<String>]

# File lib/puree/xml_extractor/research_output.rb, line 42
def dois
  xpath_query_for_multi_value '/electronicVersions/electronicVersion[@type="wsElectronicVersionDoiAssociation"]/doi'
end
files() click to toggle source

@return [Array<Puree::Model::File>]

# 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
keywords() click to toggle source

@return [Array<String>]

# File lib/puree/xml_extractor/research_output.rb, line 69
def keywords
  keyword_group 'keywordContainers'
end
language() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 74
def language
  xpath_query_for_single_value '/language/term/text'
end
open_access_permission() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 84
def open_access_permission
  xpath_query_for_single_value '/openAccessPermission/term/text'
end
persons_external() click to toggle source

@return [Array<Puree::Model::EndeavourPerson>]

# File lib/puree/xml_extractor/research_output.rb, line 94
def persons_external
  persons 'external', '/personAssociations/personAssociation'
end
persons_internal() click to toggle source

@return [Array<Puree::Model::EndeavourPerson>]

# File lib/puree/xml_extractor/research_output.rb, line 89
def persons_internal
  persons 'internal', '/personAssociations/personAssociation'
end
persons_other() click to toggle source

@return [Array<Puree::Model::EndeavourPerson>]

# File lib/puree/xml_extractor/research_output.rb, line 99
def persons_other
  persons 'other', '/personAssociations/personAssociation'
end
publication_statuses() click to toggle source

@return [Array<Puree::Model::PublicationStatus>]

# 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_count() click to toggle source

@return [Integer, nil]

# 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_id() click to toggle source

@return [String, nil]

# 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_metrics() click to toggle source

@return [Array<Puree::Model::ResearchOutputScopusMetric>]

# 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
subtitle() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 152
def subtitle
  xpath_query_for_single_value '/subTitle'
end
title() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 157
def title
  xpath_query_for_single_value '/title'
end
translated_subtitle() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 162
def translated_subtitle
  xpath_query_for_single_value '/translatedSubTitle/text'
end
translated_title() click to toggle source

@return [String, nil]

# File lib/puree/xml_extractor/research_output.rb, line 167
def translated_title
  xpath_query_for_single_value '/translatedTitle/text'
end

Private Instance Methods

combine_metadata() click to toggle source
# File lib/puree/xml_extractor/research_output.rb, line 177
def combine_metadata
  super
  @model.bibliographical_note = bibliographical_note
  @model.category = category
  @model.description = description
  @model.doi = doi
  @model.dois = dois
  @model.files = files
  @model.keywords = keywords
  @model.language = language
  @model.links = links
  @model.open_access_permission = open_access_permission
  @model.organisations = organisational_units
  @model.owner = owner
  @model.persons_internal = persons_internal
  @model.persons_external = persons_external
  @model.persons_other = persons_other
  @model.projects = projects
  @model.publication_statuses = publication_statuses
  @model.research_outputs = research_outputs
  @model.scopus_citations_count = scopus_citations_count
  @model.scopus_id = scopus_id
  @model.scopus_metrics = scopus_metrics
  @model.subtitle = subtitle
  @model.title = title
  @model.translated_subtitle = translated_subtitle
  @model.translated_title = translated_title
  @model.type = type
  @model.workflow = workflow
  @model
end
external_identifiers() click to toggle source
# File lib/puree/xml_extractor/research_output.rb, line 209
def external_identifiers
  xpath_result = xpath_query '/info/additionalExternalIds/id'
  data = []
  xpath_result.each do |d|
    identifier = Puree::Model::Identifier.new
    identifier.id = d.text.strip
    identifier.type = d.attr('idSource').strip
    data << identifier
  end
  data.uniq { |d| d.id }
end
xpath_root() click to toggle source
# File lib/puree/xml_extractor/research_output.rb, line 173
def xpath_root
  '/*'
end