From: erickson Date: Fri, 8 Dec 2006 18:06:13 +0000 (+0000) Subject: added a method to retrieve the types of marc xml templates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9d044d0cab517f1eec987ef47cfb20abffeb72d2;p=Evergreen.git added a method to retrieve the types of marc xml templates git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@6667 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index 30f9de0f08..e4c80b6192 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -56,21 +56,40 @@ __PACKAGE__->register_method( sub retrieve_marc_template { my( $self, $client, $type ) = @_; - return $marctemplates{$type} if defined($marctemplates{$type}); $marctemplates{$type} = _load_marc_template($type); return $marctemplates{$type}; } -sub _load_marc_template { - my $type = shift; +__PACKAGE__->register_method( + method => 'fetch_marc_template_types', + api_name => 'open-ils.cat.marc_template.types.retrieve' +); + +my $marc_template_files; + +sub fetch_marc_template_types { + my( $self, $conn ) = @_; + __load_marc_templates(); + return [ keys %$marc_template_files ]; +} +sub __load_marc_templates { + return if $marc_template_files; if(!$conf) { $conf = OpenSRF::Utils::SettingsClient->new; } - my $template = $conf->config_value( - "apps", "open-ils.cat","app_settings", "marctemplates", $type ); - warn "Opening template file $template\n"; + $marc_template_files = $conf->config_value( + "apps", "open-ils.cat","app_settings", "marctemplates" ); + $logger->info("Loaded marc templates: " . Dumper($marc_template_files)); +} + +sub _load_marc_template { + my $type = shift; + + __load_marc_templates(); + + my $template = $$marc_template_files{$type}; open( F, $template ) or throw OpenSRF::EX::ERROR ("Unable to open MARC template file: $template : $@"); @@ -162,6 +181,8 @@ __PACKAGE__->register_method( sub biblio_record_replace_marc { my( $self, $conn, $auth, $recid, $newxml, $source ) = @_; + warn "Updating MARC with xml\n$newxml\n"; + my $e = OpenILS::Utils::Editor->new(authtoken=>$auth, xact=>1); return $e->event unless $e->checkauth;