diff --git a/app/models/doi.rb b/app/models/doi.rb index 5a8946f0c..8934531e8 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -31,12 +31,10 @@ class Doi < ActiveRecord::Base state :tombstoned, :registered, :findable, :flagged, :broken event :register do - # can't register test prefix transitions from: [:draft], to: :registered, if: [:registerable?] end event :publish do - # can't index test prefix transitions from: [:draft], to: :findable, if: [:registerable?] transitions from: :registered, to: :findable end @@ -567,12 +565,8 @@ def suffix uid.split("/", 2).last if doi.present? end - def is_test_prefix? - prefix == "10.5072" - end - def registerable? - prefix != "10.5072" # && url.present? + true # && url.present? end # def is_valid? @@ -657,18 +651,6 @@ def event=(value) self.send(value) if %w(register publish hide show).include?(value) end - # delete all DOIs with test prefix 10.5072 not updated since from_date - # we need to use destroy_all to also delete has_many associations for metadata and media - def self.delete_test_dois(from_date: nil) - from_date ||= Time.zone.now - 1.month - collection = Doi.where("updated < ?", from_date) - collection.where("doi LIKE ?", "10.5072%").find_each do |d| - logger = Logger.new(STDOUT) - logger.info "Automatically deleted #{d.doi}, last updated #{d.updated.iso8601}." - d.destroy - end - end - # to be used after DOIs were transferred to another DOI RA def self.delete_dois_by_prefix(prefix, options={}) logger = Logger.new(STDOUT) diff --git a/app/serializers/prefix_serializer.rb b/app/serializers/prefix_serializer.rb index b642c2f63..989bdf8ae 100644 --- a/app/serializers/prefix_serializer.rb +++ b/app/serializers/prefix_serializer.rb @@ -7,6 +7,6 @@ class PrefixSerializer attributes :registration_agency, :created, :updated - has_many :clients, record_type: :clients, if: Proc.new { |record| record.prefix != "10.5072" } - has_many :providers, record_type: :providers, if: Proc.new { |record| record.prefix != "10.5072" } + has_many :clients, record_type: :clients + has_many :providers, record_type: :providers end diff --git a/lib/tasks/client.rake b/lib/tasks/client.rake index cea9387ae..b53dfe859 100644 --- a/lib/tasks/client.rake +++ b/lib/tasks/client.rake @@ -87,7 +87,7 @@ namespace :client do end # These prefixes are used by multiple clients - prefixes_to_keep = %w(10.5072 10.4124 10.4225 10.4226 10.4227) + prefixes_to_keep = %w(10.4124 10.4225 10.4226 10.4227) # delete all associated prefixes and DOIs prefixes = client.prefixes.where.not('prefix IN (?)', prefixes_to_keep).pluck(:prefix) @@ -130,7 +130,7 @@ namespace :client do end # These prefixes are used by multiple clients - prefixes_to_keep = %w(10.5072 10.4124 10.4225 10.4226 10.4227) + prefixes_to_keep = %w(10.4124 10.4225 10.4226 10.4227) # delete all associated prefixes prefixes = client.prefixes.where.not('prefix IN (?)', prefixes_to_keep).pluck(:prefix) diff --git a/lib/tasks/doi.rake b/lib/tasks/doi.rake index d35a1f8bb..59d93b9b5 100644 --- a/lib/tasks/doi.rake +++ b/lib/tasks/doi.rake @@ -47,12 +47,6 @@ namespace :doi do Doi.set_minted end - desc 'Delete DOIs with test prefix older than one month' - task :delete_test_dois => :environment do - from_date = ENV['FROM_DATE'] || Time.zone.now - 1.month - Doi.delete_test_dois(from_date: from_date) - end - desc 'Migrates landing page data handling camelCase changes at same time' task :migrate_landing_page => :environment do Doi.migrate_landing_page diff --git a/lib/tasks/prefix.rake b/lib/tasks/prefix.rake index 6164a372e..54608ceb4 100644 --- a/lib/tasks/prefix.rake +++ b/lib/tasks/prefix.rake @@ -2,7 +2,7 @@ namespace :prefix do desc 'Delete prefix and associated DOIs' task :delete => :environment do # These prefixes are used by multiple clients and can't be deleted - prefixes_to_keep = %w(10.5072 10.4124 10.4225 10.4226 10.4227) + prefixes_to_keep = %w(10.4124 10.4225 10.4226 10.4227) if ENV['PREFIX'].nil? puts "ENV['PREFIX'] is required." diff --git a/spec/concerns/crosscitable_spec.rb b/spec/concerns/crosscitable_spec.rb index d22097c52..8796145df 100644 --- a/spec/concerns/crosscitable_spec.rb +++ b/spec/concerns/crosscitable_spec.rb @@ -178,7 +178,7 @@ expect(meta["string"]).to eq(string) expect(meta["from"]).to eq("datacite") - expect(meta["doi"]).to eq("10.5072/testpub") + expect(meta["doi"]).to eq("10.14454/testpub") expect(meta["creators"]).to eq([{"familyName"=>"Smith", "givenName"=>"John", "name"=>"Smith, John", "nameType"=>"Personal"}, {"name"=>"つまらないものですが"}]) expect(meta["titles"]).to eq([{"title"=>"Właściwości rzutowań podprzestrzeniowych"}, {"title"=>"Translation of Polish titles", "titleType"=>"TranslatedTitle"}]) expect(meta["publication_year"]).to eq("2010") @@ -365,7 +365,7 @@ string = file_fixture('datacite_schema_2.2.xml').read meta = subject.parse_xml(string) - expect(meta["doi"]).to eq("10.5072/testpub") + expect(meta["doi"]).to eq("10.14454/testpub") expect(meta["creators"]).to eq([{"familyName"=>"Smith", "givenName"=>"John", "name"=>"Smith, John", "nameType"=>"Personal"}, {"name"=>"つまらないものですが"}]) expect(meta["titles"]).to eq([{"title"=>"Właściwości rzutowań podprzestrzeniowych"}, {"title"=>"Translation of Polish titles", "titleType"=>"TranslatedTitle"}]) expect(meta["publication_year"]).to eq("2010") diff --git a/spec/concerns/helpable_spec.rb b/spec/concerns/helpable_spec.rb index cc083be89..1b8a3eca2 100644 --- a/spec/concerns/helpable_spec.rb +++ b/spec/concerns/helpable_spec.rb @@ -5,22 +5,22 @@ context "validate_prefix" do it 'should validate' do - str = "10.5072" - expect(subject.validate_prefix(str)).to eq("10.5072") + str = "10.14454" + expect(subject.validate_prefix(str)).to eq("10.14454") end it 'should validate with slash' do - str = "10.5072/" - expect(subject.validate_prefix(str)).to eq("10.5072") + str = "10.14454/" + expect(subject.validate_prefix(str)).to eq("10.14454") end it 'should validate with shoulder' do - str = "10.5072/FK2" - expect(subject.validate_prefix(str)).to eq("10.5072") + str = "10.14454/FK2" + expect(subject.validate_prefix(str)).to eq("10.14454") end it 'should not validate if not DOI prefix' do - str = "20.5072" + str = "20.14454" expect(subject.validate_prefix(str)).to be_nil end end diff --git a/spec/fixtures/files/datacite_schema_2.2.xml b/spec/fixtures/files/datacite_schema_2.2.xml index bc9bf74a7..6f8c0a143 100644 --- a/spec/fixtures/files/datacite_schema_2.2.xml +++ b/spec/fixtures/files/datacite_schema_2.2.xml @@ -1,6 +1,6 @@ - 10.5072/testpub + 10.14454/testpub Smith, John diff --git a/spec/fixtures/files/large_file.xml b/spec/fixtures/files/large_file.xml index 0068b7ffa..a5427059e 100644 --- a/spec/fixtures/files/large_file.xml +++ b/spec/fixtures/files/large_file.xml @@ -2,7 +2,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd"> - 10.5072/dans-xcy-enug + 10.14454/dans-xcy-enug Chris Baars at DANS for testing diff --git a/spec/models/doi_spec.rb b/spec/models/doi_spec.rb index bd2ead599..6b01ff43f 100644 --- a/spec/models/doi_spec.rb +++ b/spec/models/doi_spec.rb @@ -41,12 +41,6 @@ subject.register expect(subject).to have_state(:registered) end - - it "can't register with test prefix" do - subject = create(:doi, doi: "10.5072/x") - subject.register - expect(subject).to have_state(:draft) - end end describe "findable" do @@ -54,12 +48,6 @@ subject.publish expect(subject).to have_state(:findable) end - - it "can't publish with test prefix" do - subject = create(:doi, doi: "10.5072/x") - subject.publish - expect(subject).to have_state(:draft) - end end describe "flagged" do