[Archivesspace_Users_Group] Plugin: Custom import mapping for MarcXML Agents, help

Carlos Lemus carlos.lemus at unlv.edu
Wed Sep 9 01:35:51 EDT 2015


My question is how do i map the controlfield to one agent? it is currently
creating two and the control field does not have a primary name to complete
the job (Returns an error primary name missing)

I am working on a plugin to import agents from a marcxml file. There is a
lot of fields the current mapping for agents doesn't have. To begin, I have
started with trying to import the authority id from the controlfield
tag=001. I have been able to mimic and learn a lot of the mapping system
through yale_marcxml2accession plugin.

I've been able to accomplish importing mapping the authority id to the
field, but only if i add a pirmary name to the name_person object, because
what is happening is it is creating two agents as far as I can see from the
log debugs I created. One of the log debugs is in the agent template
(working with the agent/person template mix)
#<JSONModel(:agent_person) {"jsonmodel_type"=>"agent_person",
"agent_contacts"=>[], "linked_agent_roles"=>[], "external_documents"=>[],
"rights_statements"=>[], "notes"=>[], "dates_of_existence"=>[],
"names"=>[#<JSONModel(:name_person) {"jsonmodel_type"=>"name_person",
"use_dates"=>[], "authorized"=>false, "is_display_name"=>false,
"sort_name_auto_generate"=>true, "uri"=>nil, "primary_name"=>"Goodman",
"rest_of_name"=>"Oscar Baylin,", "dates"=>"1939-",
"name_order"=>"inverted", "source"=>"ingest"}>], "related_agents"=>[],

and the other is from the mapping of the code below (working with the
authority id)
 #<JSONModel(:agent_person) {"jsonmodel_type"=>"agent_person",
"agent_contacts"=>[], "linked_agent_roles"=>[], "external_documents"=>[],
"rights_statements"=>[], "notes"=>[], "dates_of_existence"=>[],
"names"=>[#<JSONModel(:name_person) {"jsonmodel_type"=>"name_person",
"use_dates"=>[], "authorized"=>false, "is_display_name"=>false,
"sort_name_auto_generate"=>true, "uri"=>nil, "authority_id"=>"n
2003051366", "name_order"=>"direct", "source"=>"ingest"}>],

The code below also debugs the resource that shows both agents under the
linked agents
#<JSONModel(:resource) {"jsonmodel_type"=>"resource", "external_ids"=>[],
"subjects"=>[], "linked_events"=>[], "extents"=>[], "dates"=>[],
"external_documents"=>[], "rights_statements"=>[],
"linked_agents"=>[{:role=>"subject", :terms=>[], :relator=>nil,
{:role=>"subject", :terms=>[], :relator=>nil,
"restrictions"=>false, "revision_statements"=>[], "instances"=>[],
"deaccessions"=>[], "related_accessions"=>[], "classifications"=>[],
"notes"=>[], "hello_worlds"=>[],
"language"=>nil, "finding_aid_description_rules"=>"rda",

I want to basically end up with the two of these combined in the sense of
primary_name, dates, authority_id, etc can be imported as one agent. There
is some relationship to the first agent created I'm missing if someone
could help me fill that link I'd appreciate it. Let me know if I need to
clarify anything.

config["/record"][:map]["controlfield[@tag='001']"] = {
    :rel => -> resource, agent {
       resource[:linked_agents] << {
         # stashed value for the role
         :role => agent['_role'] || 'subject',
         :terms => agent['_terms'] || [],
         :relator => agent['_relator'],
         :ref => agent.uri
    :obj => :agent_person,
    :map => {
    "self::controlfield" => {
       :obj => :name_person,
       :rel => :names,
       :map => {
          "self::controlfield" => -> name, node {

              val = node.inner_text
             #name['primary_name'] = test
             name['authority_id'] = val
    :defaults => {
       :name_order => 'direct',
       :source => 'ingest'

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150908/b69ab113/attachment.html>

More information about the Archivesspace_Users_Group mailing list