diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 75a871248..5baec2d24 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -12,7 +12,7 @@ module Indexable logger = Logger.new(STDOUT) logger.info "[Elasticsearch] Indexing of DOI #{doi} finished #{index_interval.to_s} seconds after DOI update." - # send_import_message(self.to_jsonapi) + send_import_message(self.to_jsonapi) if aasm_state == "findable" end end diff --git a/app/models/doi.rb b/app/models/doi.rb index 905a65164..419666add 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -26,7 +26,7 @@ class Doi < ActiveRecord::Base include Elasticsearch::Model aasm :whiny_transitions => false do - # draft is initial istate for new DOIs. + # draft is initial state for new DOIs. state :draft, :initial => true state :tombstoned, :registered, :findable, :flagged, :broken @@ -366,25 +366,8 @@ def update_media def to_jsonapi attributes = { "doi" => doi, - "identifier" => identifier, - "url" => url, - "creator" => author, - "title" => title, - "publisher" => publisher, - "resource-type-subtype" => additional_type, - "version" => version, - "schema-version" => schema_version, - "metadata-version" => metadata_version, - "client-id" => client_id, - "provider-id" => provider_id, - "resource-type-id" => resource_type_general, - "prefix" => prefix, "state" => aasm_state, - "source" => source, - "is-active" => is_active == "\x01", "created" => created, - "published" => date_published, - "registered" => date_registered, "updated" => date_updated } { "id" => doi, "type" => "dois", "attributes" => attributes } diff --git a/spec/models/doi_spec.rb b/spec/models/doi_spec.rb index 1e1ff8f51..cee8aaa33 100644 --- a/spec/models/doi_spec.rb +++ b/spec/models/doi_spec.rb @@ -387,10 +387,9 @@ it "works" do params = doi.to_jsonapi expect(params.dig("id")).to eq(doi.doi) - expect(params.dig("attributes","url")).to eq(doi.url) - expect(params.dig("attributes","resource-type-id")).to eq("Text") - expect(params.dig("attributes","schema-version")).to eq("http://datacite.org/schema/kernel-3") - expect(params.dig("attributes","is-active")).to be false + expect(params.dig("attributes","state")).to eq("draft") + expect(params.dig("attributes","created")).to eq(doi.created) + expect(params.dig("attributes","updated")).to eq(doi.updated) end end