From da78f7d48d2c947503859bd4d76b63be2430ed91 Mon Sep 17 00:00:00 2001 From: dbs Date: Tue, 26 May 2009 06:17:49 +0000 Subject: [PATCH] More polish for MFHD record display * Add an owning_lib to SRE and SVR so that holdings are scoped to the search location * Add owning_lib as a context for deleting, merging, and updating MFHD records * Make the comma spacing regex global so that all current issues will be separated by a comma followed by a space * Use the MFHD id to invoke the MARC editor directly git-svn-id: svn://svn.open-ils.org/ILS/trunk@13227 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 10 +++++-- .../OpenILS/Application/Search/Serial.pm | 30 +++++++++++++++++-- .../src/perlmods/OpenILS/Utils/MFHDParser.pm | 6 +++- Open-ILS/src/sql/Pg/210.schema.serials.sql | 2 ++ Open-ILS/web/opac/skin/default/js/rdetail.js | 11 +++---- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index ad8f2b2986..bd6012cb09 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2274,6 +2274,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -2298,18 +2300,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + - + - - + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm index b7188e2bfe..6031659060 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm @@ -50,7 +50,7 @@ sub mfhd_to_hash { "open-ils.cstore.direct.serial.record_entry.retrieve", $id )->gather(1); my $u = OpenILS::Utils::MFHDParser->new(); - my $mfhd_hash = $u->generate_svr( $request->marc ); + my $mfhd_hash = $u->generate_svr( $request->id, $request->marc, $request->owning_lib ); $session->disconnect(); return $mfhd_hash; @@ -81,7 +81,7 @@ sub bib_to_mfhd_hash { # XXX perhaps this? --miker # my $e = OpenILS::Utils::CStoreEditor->new(); # my $mfhd = $e->search_serial_record_entry({ record => $bib }); -# return $u->generate_svr( $mfhd->[0]->marc ) if (ref $mfhd); +# return $u->generate_svr( $mfhd->[0] ) if (ref $mfhd); # return undef; my @mfhd = $U->cstorereq( "open-ils.cstore.json_query.atomic", { @@ -134,4 +134,30 @@ __PACKAGE__->register_method( note => "Given a bibliographic record ID, return MFHD holdings" ); +sub bib_to_mfhd { + my ($self, $client, $bib) = @_; + + my $mfhd; + + my $e = OpenILS::Utils::CStoreEditor->new(); + my $serials = $e->search_serial_record_entry({ record => $bib }); + if (!ref $serials) { + return undef; + } + + my $u = OpenILS::Utils::MFHDParser->new(); + foreach (@$serials) { + push(@$mfhd, $u->generate_svr($_->id, $_->marc, $_->owning_lib)); + } + + return $mfhd; +} + +__PACKAGE__->register_method( + method => "bib_to_mfhd", + api_name => "open-ils.search.serial.record.bib.retrieve", + argc => 1, + note => "Given a bibliographic record ID, return MFHD holdings" +); + 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm index ee2403d1c5..6611d0e727 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm @@ -149,6 +149,8 @@ Initialize the serial virtual record (svr) instance =cut sub init_holdings_virtual_record { my $record = Fieldmapper::serial::virtual_record->new; + $record->id(); + $record->owning_lib(); $record->holdings([]); $record->current_holdings([]); $record->supplements([]); @@ -171,7 +173,7 @@ Given an MFHD record, return a populated svr instance =cut sub generate_svr { - my ($self, $mfhd) = @_; + my ($self, $id, $mfhd, $owning_lib) = @_; if (!$mfhd) { return undef; @@ -180,6 +182,8 @@ sub generate_svr { my $record = init_holdings_virtual_record(); my $holdings = $self->mfhd_to_hash($mfhd); + $record->id($id); + $record->owning_lib($owning_lib); $record->holdings($holdings->{holdings}); $record->current_holdings($holdings->{current_holdings}); $record->supplements($holdings->{supplements}); diff --git a/Open-ILS/src/sql/Pg/210.schema.serials.sql b/Open-ILS/src/sql/Pg/210.schema.serials.sql index 43e8c568c0..a8a98d7f07 100644 --- a/Open-ILS/src/sql/Pg/210.schema.serials.sql +++ b/Open-ILS/src/sql/Pg/210.schema.serials.sql @@ -9,6 +9,7 @@ CREATE SCHEMA serial; CREATE TABLE serial.record_entry ( id BIGSERIAL PRIMARY KEY, record BIGINT REFERENCES biblio.record_entry (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, + owning_lib INT NOT NULL DEFAULT 1 REFERENCES actor.org_unit (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, creator INT NOT NULL DEFAULT 1, editor INT NOT NULL DEFAULT 1, source INT, @@ -21,6 +22,7 @@ CREATE TABLE serial.record_entry ( ); CREATE INDEX serial_record_entry_creator_idx ON serial.record_entry ( creator ); CREATE INDEX serial_record_entry_editor_idx ON serial.record_entry ( editor ); +CREATE INDEX serial_record_entry_owning_lib_idx ON serial.record_entry ( owning_lib, deleted ); CREATE TABLE serial.full_rec ( id BIGSERIAL PRIMARY KEY, diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index 42d73b8903..835ec7fc37 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -204,7 +204,7 @@ function OpenMarcEditWindow(pcrud, rec) { function loadMarcEditor(recId) { var pcrud = new openils.PermaCrud({"authtoken": G.user.session}); - var recs = pcrud.search("sre", {"record": recId}); + var recs = pcrud.search("sre", {"id": recId, "deleted": false}); OpenMarcEditWindow(pcrud, recs[0]); } @@ -217,10 +217,12 @@ function _holdingsDraw(h) { if (!holdings) { return null; } dojo.forEach(holdings, _holdingsDrawMFHD); - } function _holdingsDrawMFHD(holdings, entryNum) { + if (!orgIsMine(findOrgUnit(holdings.owning_lib()), findOrgUnit(getLocation()))) { + return null; + } var hh = holdings.holdings(); var hch = holdings.current_holdings(); var hs = holdings.supplements(); @@ -252,13 +254,12 @@ function _holdingsDrawMFHD(holdings, entryNum) { if (isXUL()) { dojo.require('openils.Event'); dojo.require('openils.PermaCrud'); - dojo.place(" - Edit", "mfhdHoldingsCaption", "last"); + dojo.place(" - Edit", "mfhdHoldingsCaption", "last"); } } function _holdingsDrawMFHDEntry(entryNum, entryName, entry) { - var commaRegex = /,/; - var flatEntry = entry.toString().replace(commaRegex, ', '); + var flatEntry = entry.toString().replace(/,/g, ', '); dojo.place(" " + entryName + "" + flatEntry + "", "rdetail_holdings_tbody_" + entryNum, "last"); } -- 2.43.2