added a method to retrieve the types of marc xml templates
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 8 Dec 2006 18:06:13 +0000 (18:06 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 8 Dec 2006 18:06:13 +0000 (18:06 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6667 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

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