Class: DatasetRecord::DarwinCore::Occurrence::ImportProtonym::MatchExisting

Inherits:
Object
  • Object
show all
Defined in:
app/models/dataset_record/darwin_core/occurrence.rb

Class Method Summary collapse

Class Method Details

.execute(origins, parent, name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'app/models/dataset_record/darwin_core/occurrence.rb', line 44

def self.execute(origins, parent, name)
  Protonym.find_by(name.slice(:rank_class, :name).merge!({ parent: parent })).tap do |protonym|
    if protonym.nil?
      raise DatasetRecord::DarwinCore::InvalidData.new({
        origins[name.object_id] =>
        ["Protonym #{name[:name]} not found with that name and/or classification. Importing new names is disabled by import settings."]
      })
    end
  end
end