<div dir="ltr">Hi Joshua,<div><br></div><div>Thanks so much for the response. I don't want to do anything to the ead which is why I'm avoiding using the EADSerializer.add_serialize_step(EADUserDefinedFieldSerialize) step. I see that the MarcModel code is getting the archival object. I don't really have anything to override the mapping in MarcModel code or add anything to EADSerializer...so I'm a little stuck right now and apologize if I'm missing something obvious.</div><div><br>Thanks again.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 2, 2016 at 8:57 AM, Joshua D. Shaw <span dir="ltr"><<a href="mailto:Joshua.D.Shaw@dartmouth.edu" target="_blank">Joshua.D.Shaw@dartmouth.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>
<div>Hi Esha-</div>
<div><br>
</div>
<div>I think you'll want something like the following, where I'm adding the ead_id to a new 035 field.</div>
<div><br>
</div>
<div>
<div> def datafields</div>
<div> extra_fields = []</div>
<div> </div>
<div> if @record.aspace_record.ead_id</div>
<div> extra_fields << DataField.new('035', ' ', ' ', [SubField.new('a', @record.aspace_record.ead_id)])</div>
<div> end</div>
</div>
<div><br>
</div>
<div>
<div> (@record.datafields + extra_fields).sort_by(&:tag)</div>
<div> end</div>
</div>
<div><br>
</div>
<div>There's a complete view of what Dartmouth is doing - at least in my local test environment against v1.4+ here:
<a href="https://github.com/jdshaw/dartmouth_udf_exports/tree/1.5-compatible" target="_blank">https://github.com/jdshaw/dartmouth_udf_exports/tree/1.5-compatible</a> I've optimistically labeled it 1.5+ compatible, but I think it should work with 1.4 as well. It's a work in
progress, so feel free to let me know if you spot some major nastiness!</div>
<div><br>
</div>
<div>We haven't updated from 1.3 in production yet, but I've rolled most of the changes to the exporter into a 1.3 version which ca be found here: <a href="https://github.com/jdshaw/dartmouth_udf_exports" target="_blank">https://github.com/jdshaw/dartmouth_udf_exports</a></div>
<div><br>
</div>
<div>Best,</div>
<div>Joshua</div>
<div><br>
</div>
<div>
<div></div>
</div>
</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:12pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>Esha Datta<br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:esha@nyu.edu" target="_blank">esha@nyu.edu</a>", Archivesspace Users Group<br>
<span style="font-weight:bold">Date: </span>Tuesday, March 1, 2016 at 1:16 PM<br>
<span style="font-weight:bold">To: </span>Archivesspace Users Group<br>
<span style="font-weight:bold">Subject: </span>[Archivesspace_Users_Group] marcxml exporter plugin questions<br>
</div><div><div class="h5">
<div><br>
</div>
<div>
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>I am trying to write a plugin to apply some custom mappings to the marc export for Archives Space records. I am using Hudson Molonglo's <a href="https://github.com/hudmol/dartmouth_udf_exports" target="_blank">plugin</a> and the ASpace plugin
<a href="http://archivesspace.github.io/archivesspace/user/archivesspace-plug-ins-readme/" target="_blank">
documentation</a> as a template. My question is how do I access the archives space object? So far, I have created a custom marc serializer class where I specify the class in the MarcSerializer add decorator method. I can inspect the object(record) in the MarcCustomFieldSerialize
class and see the marc record...which is pretty cool. However, I also need to access the archives space object before it's transformed to marc to access some other values.</div>
<div><br>
</div>
<div>I see from the plugin listed above that the MarcModel class is being re-defined in it and is getting the aspace record. It also has some decorator logic which I assume got pulled back into the main code, as I see it there now. However, I'm not sure how
object is being read in the plugin. I see how that's happening in the main source code.</div>
<div><br>
</div>
<div>So far, I have:</div>
<div>plugins/name/</div>
<div>plugin_init.rb:</div>
<div> MARCSerializer.add_decorator(MARCCustomFieldSerialize)</div>
<div>and the class:</div>
<div>plugins/name/backend/lib/</div>
<div>
<div>class MARCCustomFieldSerialize</div>
<div> ControlField = Struct.new(:tag, :text)</div>
<div> DataField = Struct.new(:tag, :ind1, :ind2, :subfields)</div>
<div> SubField = Struct.new(:code, :text)</div>
<div> </div>
<div> def initialize(record)</div>
<div> @record = record</div>
<div> end</div>
<div>end</div>
<div><br>
</div>
<div>I'd really appreciate any feedback on this. Thanks for your time! Please let me know if you need any clarifications.</div>
<div><br>
</div>
<div>Thanks.</div>
<div><br>
</div>
<div>Esha Datta</div>
<div>Senior Programmer/Analyst</div>
<div>Bobst Library</div>
<div>NYU</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div></div></span>
</div>
</blockquote></div><br></div>