From 3f3a19cd4c65b6dd55ba48bdd46089860c966513 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 27 Jul 2005 19:31:39 +0000 Subject: [PATCH] fixed bug in opensrf_all 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 | 7 ++ Open-ILS/src/Makefile | 2 + .../src/perlmods/OpenILS/Application/Cat.pm | 65 +++++++++++++++++++ OpenSRF/bin/opensrf_all | 2 + 4 files changed, 76 insertions(+) diff --git a/Open-ILS/examples/openils.xml.example b/Open-ILS/examples/openils.xml.example index bd4de89c3d..1f297a5765 100644 --- a/Open-ILS/examples/openils.xml.example +++ b/Open-ILS/examples/openils.xml.example @@ -181,6 +181,13 @@ For non-core config info, see the inline documentation within this file 5 + + + /path/to/templates/marc/book.xml + + + + diff --git a/Open-ILS/src/Makefile b/Open-ILS/src/Makefile index 7e90a60d61..0ca3a4cfec 100644 --- a/Open-ILS/src/Makefile +++ b/Open-ILS/src/Makefile @@ -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)" diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index 7cc1244a15..1e5aab15f1 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -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 = ; + $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", diff --git a/OpenSRF/bin/opensrf_all b/OpenSRF/bin/opensrf_all index 2c12c66e13..18d182ad48 100755 --- a/OpenSRF/bin/opensrf_all +++ b/OpenSRF/bin/opensrf_all @@ -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; } -- 2.43.2