Skip to content

MARC_Importer

Julie Allinson edited this page Jun 21, 2019 · 3 revisions

MARC Importer

Add the gem

gem 'leaf_addons', :git => 'git://github.com/leaf-research-technologies/leaf_addons.git'

Run bundle install

Run the importers generator 'rails g leaf_addons:importers'

Run:

bin/import_from_marc<server> <marc_file>

For example:

bin/import_from_marc localhost my_marc_data.utf8

What the script does

  • Reads through the marc and builds an object of a particular type

The Code

The importer code can be found here:

lib/importer/marc

Supported Models

From DogBiscuits:

  • PublishedWork
  • ConferenceItem
  • JournalArticle

To use different models, make sure there is a Factory and override the 'find_model' method in lib/importer/marc/marc_attributes_override.rb

Supported Fields

To add support for a new field, add a method into lib/importer/marc/marc_attributes.rb (core code) or in the local application, into lib/importer/marc/marc_attributes_overrides.rb

For example, to process MARC 625 subfield $g and map it to a property called 'lovely_field'. Add the following to lib/importer/marc/marc_attributes_overrides.rb, a file inserted into your local application when the importer generator is run.

    marc_mappings[:lovely_field] = [{ code: '625', subfield: 'g' }]

Note:

  • The property MUST be available to the specified model in Hyku/Hyrax
  • Any field that will be processed via a custom method should be added to the 'special_attributes_list'
  • See 'creator' for an example of more complex field processing
Clone this wiki locally