Skip to content

Instantly share code, notes, and snippets.

@cfitz
Created April 14, 2015 13:46
Show Gist options
  • Select an option

  • Save cfitz/f031108cc44bd109620b to your computer and use it in GitHub Desktop.

Select an option

Save cfitz/f031108cc44bd109620b to your computer and use it in GitHub Desktop.
RAC ead converter
class RacEADConverter < EADConverter
def self.import_types(show_hidden = false)
[
{
:name => "rac_ead_xml",
:description => "Import RAC EAD records from an XML file"
}
]
end
def self.instance_for(type, input_file)
if type == "rac_ead_xml"
self.new(input_file)
else
nil
end
end
def self.profile
"Convert EAD To ArchivesSpace JSONModel records"
end
def self.configure
super
%w(accessrestrict accessrestrict/legalstatus \
accruals acqinfo altformavail appraisal arrangement \
bioghist custodhist dimensions \
fileplan odd otherfindaid originalsloc phystech \
prefercite processinfo relatedmaterial scopecontent \
separatedmaterial userestrict ).each do |note|
with note do |node|
content = inner_xml.tap {|xml|
xml.sub!(/<head>.*?<\/head>/m, '')
# xml.sub!(/<list [^>]*>.*?<\/list>/m, '')
# xml.sub!(/<chronlist [^>]*>.*<\/chronlist>/m, '')
}
make :note_multipart, {
:type => node.name,
:persistent_id => att('id'),
:publish => att('audience') != 'internal', #added this line for publishing notes on import
:subnotes => {
'jsonmodel_type' => 'note_text',
'content' => format_content( content )
}
} do |note|
set ancestor(:resource, :archival_object), :notes, note
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment