Skip to content

Commit

Permalink
add NiiImporter
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed May 6, 2020
1 parent 342ff4a commit 8e4be27
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app/importers/nii_importer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require_dependency EnjuBiblio::Engine.config.root.join('app', 'importers', 'manifestation_importer.rb').to_s

module NiiImporter
def create_nii_entry(row, **options)
entry = super
entry.ncid = row['ncid']
entry
end
end

module NiiEntryImporter
attr_accessor :ncid

def import
super
import_ncid
end

def hoge
puts "aaa"
super
end

def find_by_ncid
return if ncid.blank?
NcidRecord.find_by(body: ncid)&.manifestation
end

def import_ncid
return if ncid.blank?

ncid_record = NcidRecord.find_or_initialize_by(body: ncid)
ncid_record.update!(manifestation: manifestation_record)
end
end

ManifestationImporter.singleton_class.send(:prepend, NiiImporter)
ManifestationImporter.send(:prepend, NiiEntryImporter)

0 comments on commit 8e4be27

Please sign in to comment.