added method to retrieve bib-source types. updated marc update method to allow for...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Dec 2006 19:08:43 +0000 (19:08 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 13 Dec 2006 19:08:43 +0000 (19:08 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6696 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Cat.pm

index e4c80b6..40db4d9 100644 (file)
@@ -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);