diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index b0620d5ff..00bb470e2 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -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 @@ -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 diff --git a/app/models/doi.rb b/app/models/doi.rb index 06dcd6a2e..f6aadf69d 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -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 @@ -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 @@ -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, @@ -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) diff --git a/spec/concerns/crosscitable_spec.rb b/spec/concerns/crosscitable_spec.rb index 6b8c41b6f..c092dbb0b 100644 --- a/spec/concerns/crosscitable_spec.rb +++ b/spec/concerns/crosscitable_spec.rb @@ -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 diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index cbff108ea..df5a5c483 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -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", {})