fixed bug in opensrf_all
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 27 Jul 2005 19:31:39 +0000 (19:31 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 27 Jul 2005 19:31:39 +0000 (19:31 +0000)
add untested code for new marc templates

git-svn-id: svn://svn.open-ils.org/ILS/trunk@1548 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/openils.xml.example
Open-ILS/src/Makefile
Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
OpenSRF/bin/opensrf_all

index bd4de89..1f297a5 100644 (file)
@@ -181,6 +181,13 @@ For non-core config info, see the inline documentation within this file
                                        <max_spare_children>5</max_spare_children>
                                </unix_config>
 
+                               <app_settings>
+                                       <marctemplates>
+                                               <book>/path/to/templates/marc/book.xml</book>
+                                       </marctemplates>
+                               </app_settings>
+
+
                        </open-ils.cat>
 
 
index 7e90a60..0ca3a4c 100644 (file)
@@ -18,6 +18,8 @@ perl-install:
        mkdir -p $(PERLDIR)
        cp -r perlmods/* $(PERLDIR)
        cp ../examples/openils.xml.example $(ETCDIR)
+       mkdir -p $(TEMPLATEDIR)
+       cp -r templates/marc $(TEMPLATEDIR)
 
 javascript-install:
        @echo "Installing javascript to $(JSDIR)"
index 7cc1244..1e5aab1 100644 (file)
@@ -12,11 +12,76 @@ use XML::LibXML;
 use Data::Dumper;
 use OpenILS::Utils::FlatXML;
 use OpenILS::Perm;
+use OpenSRF::Utils::SettingsClient;
 
 my $apputils = "OpenILS::Application::AppUtils";
 
 my $utils = "OpenILS::Application::Cat::Utils";
 
+my $conf;
+
+my %marctemplates;
+
+
+__PACKAGE__->register_method(
+       method  => "retrieve_marc_template",
+       api_name        => "open-ils.cat.biblio.marc_template.retrieve",
+       notes           => <<"  NOTES");
+       Returns a MARC 'record tree' based on a set of pre-defined templates.
+       Templates include : book
+       NOTES
+
+sub retrieve_marc_template {
+       my( $self, $client, $type ) = @_;
+       my $xml = _load_marc_template($type);
+       my $nodes = OpenILS::Utils::FlatXML->new()->xml_to_nodeset( $xml ); 
+       return $utils->nodeset2tree( $nodes->nodeset );
+}
+
+sub _load_marc_template {
+       my $type = shift;
+
+       if(!defined( $marctemplates{$type} )) {
+               if(!$conf) { $conf = OpenSRF::Utils::SettingsClient->new; }
+               my $template = $conf->config_value(                                     
+                       "apps", "open-ils.cat","app_settings", "marctemplates", $type );
+               open( F, $template );
+               my @xml = <F>;
+               $marctemplates{$type} = join('', @xml);
+       }
+
+       warn "Loaded MARC template XML:\n" . $marctemplates{$type} . "\n";
+
+       return $marctemplates{$type};
+}
+
+
+
+__PACKAGE__->register_method(
+       method  => "create_record_tree",
+       api_name        => "open-ils.cat.biblio.record_tree.create",
+       notes           => <<"  NOTES");
+       Inserts a new MARC 'record tree' into the system
+       NOTES
+
+sub create_record_tree {
+       my( $self, $client, $login, $tree ) = @_;
+
+       my $user_obj = $apputils->check_user_session($login);
+
+       if($apputils->check_user_perms(
+                       $user_obj->id, $user_obj->home_ou, "CREATE_MARC")) {
+               return OpenILS::Perm->new("CREATE_MARC"); 
+       }
+
+       warn "Creating a new record tree entry...";
+       my $meth = $self->method_lookup("open-ils.cat.biblio.record.tree.import");
+       my ($s) = $meth->run($login, $tree);
+       return $s;
+}
+
+
+
 
 __PACKAGE__->register_method(
        method  => "biblio_record_tree_import",
index 2c12c66..18d182a 100755 (executable)
@@ -111,6 +111,7 @@ function makeMeGo {
                startOpenSRF;
                echo "OpenSRF started OK";
        fi
+       return 0;
                
 }
 
@@ -128,6 +129,7 @@ function stopMe {
        
        echo "Stopping Chop Chop...";
        killall jserver-c;
+       return 0;
 }