From a1b33d4fef72f29a0008623f621361aea2f75ea0 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 13 Dec 2006 19:08:43 +0000 Subject: [PATCH] added method to retrieve bib-source types. updated marc update method to allow for auto-generated TCN values for creating new marc git-svn-id: svn://svn.open-ils.org/ILS/trunk@6696 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Cat.pm | 40 +++++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index e4c80b6192..40db4d90a3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -105,8 +105,7 @@ sub bib_source_from_name { my $name = shift; $logger->debug("searching for bib source: $name"); - $__bib_sources = new_editor()->retrieve_all_config_bib_source() - unless $__bib_sources; + fetch_bib_sources(); my ($s) = grep { lc($_->source) eq lc($name) } @$__bib_sources; @@ -115,6 +114,17 @@ sub bib_source_from_name { } +__PACKAGE__->register_method( + method => 'fetch_bib_sources', + api_name => 'open-ils.cat.bib_sources.retrieve.all'); + +sub fetch_bib_sources { + $__bib_sources = new_editor()->retrieve_all_config_bib_source() + unless $__bib_sources; + return $__bib_sources; +} + + __PACKAGE__->register_method( method => "create_record_xml", @@ -250,7 +260,7 @@ __PACKAGE__->register_method( sub biblio_record_xml_import { - my( $self, $client, $authtoken, $xml, $source) = @_; + my( $self, $client, $authtoken, $xml, $source, $auto_tcn) = @_; my $override = 1 if $self->api_name =~ /override/; @@ -260,8 +270,13 @@ sub biblio_record_xml_import { my $session = $apputils->start_db_session(); - ( $tcn, $tcn_source, $marcdoc, $evt ) = _find_tcn_info($session, $xml, $override); - return $evt if $evt; + if( $auto_tcn ) { + # auto_tcn forces a blank TCN value so the DB will have to generate one for us + $marcdoc = __make_marc_doc($xml); + } else { + ( $tcn, $tcn_source, $marcdoc, $evt ) = _find_tcn_info($session, $xml, $override); + return $evt if $evt; + } $logger->activity("user ".$requestor->id. " creating new biblio entry with tcn=$tcn and tcn_source $tcn_source"); @@ -298,6 +313,14 @@ sub biblio_record_xml_import { return undef; } +sub __make_marc_doc { + my $xml = shift; + my $marcxml = XML::LibXML->new->parse_string( $xml ); + $marcxml->documentElement->setNamespace( + "http://www.loc.gov/MARC21/slim", "marc", 1 ); + return $marcxml; +} + sub _find_tcn_info { my $session = shift; @@ -306,9 +329,10 @@ sub _find_tcn_info { my $existing_rec = shift || 0; # parse the XML - my $marcxml = XML::LibXML->new->parse_string( $xml ); - $marcxml->documentElement->setNamespace( - "http://www.loc.gov/MARC21/slim", "marc", 1 ); + my $marcxml = __make_marc_doc($xml); +# my $marcxml = XML::LibXML->new->parse_string( $xml ); +# $marcxml->documentElement->setNamespace( +# "http://www.loc.gov/MARC21/slim", "marc", 1 ); my $xpath = '//marc:controlfield[@tag="001"]'; my $tcn = $marcxml->documentElement->findvalue($xpath); -- 2.11.0