Skip to content

Commit

Permalink
use agency field for crossref dois. datacite/levriero#56
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 14, 2019
1 parent 7fc79d2 commit af26bbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def random
def get_url
authorize! :get_url, @doi

if !@doi.is_registered_or_findable? || %w(europ ethz).include?(@doi.provider_id) || %w(Crossref).include?(@doi.agency)
if !@doi.is_registered_or_findable? || %w(europ ethz crossref).include?(@doi.provider_id) || %w(Crossref).include?(@doi.agency)
url = @doi.url
head :no_content and return unless url.present?
else
Expand Down Expand Up @@ -596,8 +596,8 @@ def safe_params

read_attrs_keys = [:url, :creators, :contributors, :titles, :publisher,
:publicationYear, :types, :descriptions, :container, :sizes,
:formats, :language, :dates, :identifiers,
:relatedIdentifiers, :fundingReferences, :geoLocations, :rightsList,
:formats, :language, :dates, :identifiers, :relatedIdentifiers,
:fundingReferences, :geoLocations, :rightsList, :agency,
:subjects, :contentUrl, :schemaVersion]

# merge attributes from xml into regular attributes
Expand Down
5 changes: 3 additions & 2 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class Doi < ActiveRecord::Base
attribute :only_validate, :boolean, default: false
attribute :exists, :boolean, default: false
attribute :should_validate, :boolean, default: false
attribute :agency, :string, default: "DataCite"

belongs_to :client, foreign_key: :datacentre
has_many :media, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy
Expand Down Expand Up @@ -229,6 +228,7 @@ class Doi < ActiveRecord::Base
indexes :aasm_state, type: :keyword
indexes :schema_version, type: :keyword
indexes :metadata_version, type: :keyword
indexes :agency, type: :keyword
indexes :source, type: :keyword
indexes :prefix, type: :keyword
indexes :suffix, type: :keyword
Expand Down Expand Up @@ -297,6 +297,7 @@ def as_indexed_json(options={})
"xml" => xml,
"is_active" => is_active,
"landing_page" => landing_page,
"agency" => agency,
"aasm_state" => aasm_state,
"schema_version" => schema_version,
"metadata_version" => metadata_version,
Expand Down Expand Up @@ -526,7 +527,7 @@ def validatable?
def update_url
return nil if current_user.nil? || !is_registered_or_findable?

if %w(europ ethz).include?(provider_id) || %w(Crossref).include?(agency)
if %w(europ ethz crossref).include?(provider_id) || %w(Crossref).include?(agency)
UrlJob.perform_later(doi)
else
HandleJob.perform_later(doi)
Expand Down
2 changes: 1 addition & 1 deletion spec/concerns/crosscitable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
expect(meta["titles"]).to eq([{"title"=>"Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"}])
expect(meta["publication_year"]).to eq("2014")
expect(meta["publisher"]).to eq("(:unav)")
expect(meta["container"]).to eq("identifier"=>"2050-084X", "identifierType"=>"ISSN", "title"=>"eLife", "type"=>"Journal", "volume"=>"3")
expect(meta["container"]).to eq("identifier" => "2050-084X", "identifierType"=>"ISSN", "title"=>"eLife", "type"=>"Journal", "volume"=>"3")
expect(meta["agency"]).to eq("Crossref")
end

Expand Down
1 change: 1 addition & 0 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@
expect(json.dig('data', 'attributes', 'url')).to eq("https://elifesciences.org/articles/01567")
expect(json.dig('data', 'attributes', 'doi')).to eq("10.7554/elife.01567")
expect(json.dig('data', 'attributes', 'titles')).to eq([{"title"=>"Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"}])
# expect(json.dig('data', 'attributes', 'agency')).to eq("Crossref")
expect(json.dig('data', 'attributes', 'state')).to eq("findable")

xml = Maremma.from_xml(Base64.decode64(json.dig('data', 'attributes', 'xml'))).fetch("resource", {})
Expand Down

0 comments on commit af26bbe

Please sign in to comment.