[open-ils-commits] r13227 - in trunk/Open-ILS: examples src/perlmods/OpenILS/Application/Search src/perlmods/OpenILS/Utils src/sql/Pg web/opac/skin/default/js (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue May 26 02:17:52 EDT 2009
Author: dbs
Date: 2009-05-26 02:17:49 -0400 (Tue, 26 May 2009)
New Revision: 13227
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm
trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm
trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql
trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
Log:
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
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-05-25 18:56:34 UTC (rev 13226)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-05-26 06:17:49 UTC (rev 13227)
@@ -2274,6 +2274,8 @@
</class>
<class id="svr" controller="open-ils.cstore" oils_obj:fieldmapper="serial::virtual_record" oils_persist:virtual="true" reporter:label="Serial Virtual Record">
<fields>
+ <field name="id" oils_persist:virtual="true" />
+ <field name="owning_lib" oils_persist:virtual="true" />
<field name="holdings" oils_persist:virtual="true" />
<field name="current_holdings" oils_persist:virtual="true" />
<field name="supplements" oils_persist:virtual="true" />
@@ -2298,18 +2300,20 @@
<field name="last_xact_id" />
<field name="marc" />
<field name="source" />
+ <field reporter:label="Owning Org Unit" name="owning_lib" reporter:datatype="org_unit"/>
</fields>
<links>
<link field="record" reltype="has_a" key="id" map="" class="bre"/>
<link field="editor" reltype="has_a" key="id" map="" class="au"/>
<link field="creator" reltype="has_a" key="id" map="" class="au"/>
+ <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
- <create permission="CREATE_MFHD_RECORD" global_required="true"/>
+ <create permission="CREATE_MFHD_RECORD" context_field="owning_lib"/>
<retrieve/>
- <update permission="UPDATE_MFHD_RECORD" global_required="true"/>
- <delete permission="DELETE_MFHD_RECORD" global_required="true"/>
+ <update permission="UPDATE_MFHD_RECORD" context_field="owning_lib"/>
+ <delete permission="DELETE_MFHD_RECORD" context_field="owning_lib"/>
</actions>
</permacrud>
</class>
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm 2009-05-25 18:56:34 UTC (rev 13226)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Serial.pm 2009-05-26 06:17:49 UTC (rev 13227)
@@ -50,7 +50,7 @@
"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 @@
# 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 @@
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;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm 2009-05-25 18:56:34 UTC (rev 13226)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm 2009-05-26 06:17:49 UTC (rev 13227)
@@ -149,6 +149,8 @@
=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 @@
=cut
sub generate_svr {
- my ($self, $mfhd) = @_;
+ my ($self, $id, $mfhd, $owning_lib) = @_;
if (!$mfhd) {
return undef;
@@ -180,6 +182,8 @@
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});
Modified: trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql 2009-05-25 18:56:34 UTC (rev 13226)
+++ trunk/Open-ILS/src/sql/Pg/210.schema.serials.sql 2009-05-26 06:17:49 UTC (rev 13227)
@@ -9,6 +9,7 @@
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 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,
Modified: trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/rdetail.js 2009-05-25 18:56:34 UTC (rev 13226)
+++ trunk/Open-ILS/web/opac/skin/default/js/rdetail.js 2009-05-26 06:17:49 UTC (rev 13227)
@@ -204,7 +204,7 @@
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 @@
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 @@
if (isXUL()) {
dojo.require('openils.Event');
dojo.require('openils.PermaCrud');
- dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" + getRid() + ")'> Edit</a>", "mfhdHoldingsCaption", "last");
+ dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" + holdings.id() + ")'> Edit</a>", "mfhdHoldingsCaption", "last");
}
}
function _holdingsDrawMFHDEntry(entryNum, entryName, entry) {
- var commaRegex = /,/;
- var flatEntry = entry.toString().replace(commaRegex, ', ');
+ var flatEntry = entry.toString().replace(/,/g, ', ');
dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>" + entryName + "</td><td class='rdetail_item'>" + flatEntry + "</td></tr>", "rdetail_holdings_tbody_" + entryNum, "last");
}
More information about the open-ils-commits
mailing list