return $class->entityize($marcdoc->documentElement->toString);
}
+# marcdoc is an XML::LibXML document
+# updates the document and returns the entityized MARC string.
+sub set_marc_905u {
+ my ($class, $marcdoc, $username) = @_;
+
+ # Look for existing 905$u subfields. If any exist, do nothing.
+ my @nodes = $marcdoc->findnodes('//field[@tag="905"]/subfield[@code="u"]');
+ unless (@nodes) {
+ # We create a new 905 and the subfield u to that.
+ my $parentNode = $marcdoc->createElement('field');
+ $parentNode->setAttribute('tag', '905');
+ $parentNode->setAttribute('ind1', '');
+ $parentNode->setAttribute('ind2', '');
+ $marcdoc->documentElement->addChild($parentNode);
+ my $node = $marcdoc->createElement('subfield');
+ $node->setAttribute('code', 'u');
+ $node->appendTextNode($username);
+ $parentNode->addChild($node);
+
+ }
+
+ return $class->entityize($marcdoc->documentElement->toString);
+}
+
# Given a list of PostgreSQL arrays of numbers,
# unnest the numbers and return a unique set, skipping any list elements
# that are just '{NULL}'.
my $marcdoc = XML::LibXML->new->parse_string($rec->marc);
$rec->marc($U->strip_marc_fields($e, $marcdoc, $strip_grps));
+ # Set the imported record's 905$u, so
+ # editor/creator/edit_date are set correctly.
+ $marcdoc = XML::LibXML->new->parse_string($rec->marc);
+ $rec->marc($U->set_marc_905u($marcdoc, $requestor->usrname));
+
unless ($e->$update_func($rec)) {
$$report_args{evt} = $e->die_event;
finish_rec_import_attempt($report_args);