From: miker Date: Thu, 13 Nov 2008 19:49:18 +0000 (+0000) Subject: finally moving to tag 901 for local identifier stuff X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=308d1ad59cf9e9b93231a5b66f7039a111337d5d;p=Evergreen.git finally moving to tag 901 for local identifier stuff git-svn-id: svn://svn.open-ils.org/ILS/trunk@11167 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm index a14db797df..183b946b43 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm @@ -191,17 +191,27 @@ sub find_free_tcn { my $editor = shift; my $existing_rec = shift; - my $add_039 = 0; + my $add_901 = 0; - my $xpath = '//marc:datafield[@tag="039"]/marc:subfield[@code="a"]'; + my $xpath = '//marc:datafield[@tag="901"]/marc:subfield[@code="a"]'; my ($tcn) = $marcxml->documentElement->findvalue($xpath) =~ /(\w+)\s*$/o; - $xpath = '//marc:datafield[@tag="039"]/marc:subfield[@code="b"]'; - my $tcn_source = $marcxml->documentElement->findvalue($xpath) || "System Local"; + + if (!$tcn) { + $xpath = '//marc:datafield[@tag="039"]/marc:subfield[@code="a"]'; + ($tcn) = $marcxml->documentElement->findvalue($xpath) =~ /(\w+)\s*$/o; + } + + $xpath = '//marc:datafield[@tag="901"]/marc:subfield[@code="b"]'; + my ($tcn_source) = $marcxml->documentElement->findvalue($xpath); + if (!$tcn_source) { + $xpath = '//marc:datafield[@tag="039"]/marc:subfield[@code="b"]'; + $tcn_source = $marcxml->documentElement->findvalue($xpath) || "System Local"; + } if(_tcn_exists($editor, $tcn, $tcn_source, $existing_rec)) { $tcn = undef; } else { - $add_039++; + $add_901++; } @@ -241,9 +251,9 @@ sub find_free_tcn { return undef unless $tcn; - if ($add_039) { + if ($add_901) { my $df = $marcxml->createElementNS( 'http://www.loc.gov/MARC21/slim', 'datafield'); - $df->setAttribute( tag => '039' ); + $df->setAttribute( tag => '901' ); $df->setAttribute( ind1 => ' ' ); $df->setAttribute( ind2 => ' ' ); $marcxml->documentElement->appendChild( $df ); @@ -257,6 +267,13 @@ sub find_free_tcn { $sfb->setAttribute( code => 'b' ); $sfb->appendChild( $marcxml->createTextNode( $tcn_source ) ); $df->appendChild( $sfb ); + + if ($existing_rec) { + my $sfc = $marcxml->createElementNS( 'http://www.loc.gov/MARC21/slim', 'subfield'); + $sfc->setAttribute( code => 'c' ); + $sfc->appendChild( $marcxml->createTextNode( $existing_rec ) ); + $df->appendChild( $sfb ); + } } return $tcn;