Skip to content

Commit

Permalink
better error handling for doi import
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 10, 2019
1 parent 191b0c8 commit 7b3524f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/graphql/types/doi_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module DoiItem
field :provider, ProviderType, null: true, description: "The provider account managing this resource"

def type
object.types["schema_org"]
object.types["schemaOrg"]
end

def creators(first: nil)
Expand Down
8 changes: 5 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Doi < ActiveRecord::Base
has_many :media, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy
has_many :metadata, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy

delegate :provider, to: :client
delegate :provider, to: :client, allow_nil: true
delegate :consortium_id, to: :provider, allow_nil: true

validates_presence_of :doi
Expand Down Expand Up @@ -452,8 +452,8 @@ def as_indexed_json(options={})
"created" => created,
"updated" => updated,
"published" => published,
"client" => client.as_indexed_json,
"provider" => provider.as_indexed_json,
"client" => client.try(:as_indexed_json),
"provider" => provider.try(:as_indexed_json),
"resource_type" => resource_type.try(:as_indexed_json),
"media" => media.map { |m| m.try(:as_indexed_json) }
}
Expand Down Expand Up @@ -628,6 +628,8 @@ def uid

def resource_type_id
types["resourceTypeGeneral"].underscore.dasherize if types.to_h["resourceTypeGeneral"].present?
rescue TypeError
nil
end

def media_ids
Expand Down

0 comments on commit 7b3524f

Please sign in to comment.