From 5f131e8dc71a5aa2431f2ef00fa37270580616cb Mon Sep 17 00:00:00 2001 From: pines Date: Sun, 3 Sep 2006 21:16:56 +0000 Subject: [PATCH] move to id lists for bulk hold retrieval. Now need an uber method for single hold retrieval git-svn-id: svn://svn.open-ils.org/ILS/trunk@5898 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/Holds.pm | 102 +++++-- .../chrome/content/main/constants.js | 4 + .../xul/staff_client/server/patron/holds.js | 259 +++++++++--------- 3 files changed, 215 insertions(+), 150 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index fd57865e6d..3c7c4f5d1d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -312,6 +312,14 @@ user id. The login session is the requestor and if the requestor is different from the user, then the requestor must have VIEW_HOLD permissions. NOTE +__PACKAGE__->register_method( + method => "retrieve_holds", + api_name => "open-ils.circ.holds.id_list.retrieve", + notes => < { ahr => "request_time" } } ); - for my $hold ( @$holds ) { - $hold->transit( - $apputils->simplereq( - 'open-ils.cstore', - "open-ils.cstore.direct.action.hold_transit_copy.search.atomic", - { hold => $hold->id }, - { order_by => { ahtc => 'id desc' }, limit => 1 } - )->[0] - ); + if( ! $self->api_name =~ /id_list/ ) { + for my $hold ( @$holds ) { + $hold->transit( + $apputils->simplereq( + 'open-ils.cstore', + "open-ils.cstore.direct.action.hold_transit_copy.search.atomic", + { hold => $hold->id }, + { order_by => { ahtc => 'id desc' }, limit => 1 } + )->[0] + ); + } } - return $holds; + if( $self->api_name =~ /id_list/ ) { + return [ map { $_->id } @$holds ]; + } else { + return $holds; + } } __PACKAGE__->register_method( @@ -353,6 +367,13 @@ Retrieves all the holds, with hold transits attached, for the specified pickup_ou id. NOTE +__PACKAGE__->register_method( + method => "retrieve_holds_by_pickup_lib", + api_name => "open-ils.circ.holds.id_list.retrieve_by_pickup_lib", + notes => < { ahr => "request_time" } }); - flesh_hold_transits($holds); - return $holds; -} + if( ! $self->api_name =~ /id_list/ ) { + flesh_hold_transits($holds); + } + if( $self->api_name =~ /id_list/ ) { + return [ map { $_->id } @$holds ]; + } else { + return $holds; + } +} __PACKAGE__->register_method( method => "cancel_hold", @@ -672,12 +699,22 @@ sub fetch_related_holds { __PACKAGE__->register_method ( method => "hold_pull_list", api_name => "open-ils.circ.hold_pull_list.retrieve", + signature => q/ + Returns a list of holds that need to be "pulled" + by a given location + / +); + +__PACKAGE__->register_method ( + method => "hold_pull_list", + api_name => "open-ils.circ.hold_pull_list.id_list.retrieve", signature => q/ Returns a list of hold ID's that need to be "pulled" by a given location / ); + sub hold_pull_list { my( $self, $conn, $authtoken, $limit, $offset ) = @_; my( $reqr, $evt ) = $U->checkses($authtoken); @@ -689,9 +726,15 @@ sub hold_pull_list { $evt = $U->check_perms($reqr->id, $org, 'VIEW_HOLD'); return $evt if $evt; - return $U->storagereq( - 'open-ils.storage.direct.action.hold_request.pull_list.search.current_copy_circ_lib.atomic', - $org, $limit, $offset ); + if( $self->api_name =~ /id_list/ ) { + return $U->storagereq( + 'open-ils.storage.direct.action.hold_request.pull_list.id_list.current_copy_circ_lib.atomic', + $org, $limit, $offset ); + } else { + return $U->storagereq( + 'open-ils.storage.direct.action.hold_request.pull_list.search.current_copy_circ_lib.atomic', + $org, $limit, $offset ); + } } __PACKAGE__->register_method ( @@ -901,12 +944,23 @@ sub flesh_hold_notices { __PACKAGE__->register_method( method => 'fetch_captured_holds', api_name => 'open-ils.circ.captured_holds.on_shelf.retrieve', + signature => q/ + Returns a list of un-fulfilled holds for a given title id + @param authtoken The login session key + @param org The org id of the location in question + / +); + +__PACKAGE__->register_method( + method => 'fetch_captured_holds', + api_name => 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve', signature => q/ Returns a list ids of un-fulfilled holds for a given title id @param authtoken The login session key @param org The org id of the location in question / ); + sub fetch_captured_holds { my( $self, $conn, $auth, $org ) = @_; @@ -934,13 +988,17 @@ sub fetch_captured_holds { $copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF; } - flesh_hold_transits(\@res); - flesh_hold_notices(\@res, $e); - return \@res; -} - - + if( ! $self->api_name =~ /id_list/ ) { + flesh_hold_transits(\@res); + flesh_hold_notices(\@res, $e); + } + if( $self->api_name =~ /id_list/ ) { + return [ map { $_->id } @res ]; + } else { + return \@res; + } +} __PACKAGE__->register_method( diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 7a77ea4d55..2ec1eb6f93 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -55,11 +55,15 @@ const api = { 'FM_AHN_RETRIEVE_VIA_AHR' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.retrieve_by_hold' }, 'FM_AHR_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_by_id' }, 'FM_AHR_RETRIEVE_VIA_AU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve' }, + 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve' }, 'FM_AHR_RETRIEVE_VIA_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_holds.retrieve' }, 'FM_AHR_RETRIEVE_ALL_VIA_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_all_from_title' }, 'FM_AHR_RETRIEVE_VIA_PICKUP_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_by_pickup_lib' }, + 'FM_AHR_ID_LIST_RETRIEVE_VIA_PICKUP_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve_by_pickup_lib' }, 'FM_AHR_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.retrieve' }, + 'FM_AHR_ID_LIST_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.id_list.retrieve' }, 'FM_AHR_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.on_shelf.retrieve' }, + 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve' }, 'FM_AHR_COUNT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count' }, 'FM_AHR_CANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.cancel' }, 'FM_AHR_UPDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.update' }, diff --git a/Open-ILS/xul/staff_client/server/patron/holds.js b/Open-ILS/xul/staff_client/server/patron/holds.js index 08a2f942d4..77b329dee3 100644 --- a/Open-ILS/xul/staff_client/server/patron/holds.js +++ b/Open-ILS/xul/staff_client/server/patron/holds.js @@ -46,101 +46,128 @@ patron.holds.prototype = { 'retrieve_row' : function(params) { var row = params.row; try { - obj.network.simple_request('FM_AHR_STATUS',[ ses(), row.my.ahr.id() ], - function(status_req) { - var status_robj = status_req.getResultObject(); - row.my.status = status_robj; - switch(row.my.ahr.hold_type()) { - case 'M' : - obj.network.request( - api.MODS_SLIM_METARECORD_RETRIEVE.app, - api.MODS_SLIM_METARECORD_RETRIEVE.method, - [ row.my.ahr.target() ], - function(mvr_req) { - row.my.mvr = mvr_req.getResultObject(); - if ( row.my.ahr.current_copy() && ! row.my.acp) { - obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ], - function(acp_req) { - row.my.acp = acp_req.getResultObject(); - if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } - } - ); - } else { - if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } - } - } - ); - break; - case 'T' : - obj.network.request( - api.MODS_SLIM_RECORD_RETRIEVE.app, - api.MODS_SLIM_RECORD_RETRIEVE.method, - [ row.my.ahr.target() ], - function(mvr_req) { - row.my.mvr = mvr_req.getResultObject(); - if ( row.my.ahr.current_copy() && ! row.my.acp) { - obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ], - function(acp_req) { - row.my.acp = acp_req.getResultObject(); - if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } - } - ); - } else { - if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } - } + obj.network.simple_request('FM_AHR_RETRIEVE', [ ses(), row.my.hold_id ], + function(ahr_req) { + try { + var ahr_robj = ahr_req.getResultObject(); + if (typeof ahr_robj.ilsevent != 'undefined') throw(ahr_robj); + row.my.ahr = ahr_robj[0]; + obj.holds_map[ row.my.ahr.id() ] = row.my.ahr; + params.row_node.setAttribute('retrieve_id', + js2JSON({ + 'copy_id':row.my.ahr.current_copy(), + 'id':row.my.ahr.id(), + 'type':row.my.ahr.hold_type(), + 'target':row.my.ahr.target(), + 'usr':row.my.ahr.usr(), + }) + ); - } - ); - break; - case 'V' : - row.my.acn = obj.network.simple_request( 'FM_ACN_RETRIEVE', [ row.my.ahr.target() ], - function(acn_req) { - row.my.acn = acn_req.getResultObject(); - obj.network.request( - api.MODS_SLIM_RECORD_RETRIEVE.app, - api.MODS_SLIM_RECORD_RETRIEVE.method, - [ row.my.acn.record() ], - function(mvr_req) { - try { row.my.mvr = mvr_req.getResultObject(); } catch(E) {} - if ( row.my.ahr.current_copy() && ! row.my.acp) { - obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ], - function(acp_req) { - row.my.acp = acp_req.getResultObject(); + obj.network.simple_request('FM_AHR_STATUS',[ ses(), row.my.ahr.id() ], + function(status_req) { + try { + var status_robj = status_req.getResultObject(); + row.my.status = status_robj; + switch(row.my.ahr.hold_type()) { + case 'M' : + obj.network.request( + api.MODS_SLIM_METARECORD_RETRIEVE.app, + api.MODS_SLIM_METARECORD_RETRIEVE.method, + [ row.my.ahr.target() ], + function(mvr_req) { + row.my.mvr = mvr_req.getResultObject(); + if ( row.my.ahr.current_copy() && ! row.my.acp) { + obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ], + function(acp_req) { + row.my.acp = acp_req.getResultObject(); + if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + } + ); + } else { if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } } - ); - } else { - if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } - } - } - ); - } - ); - break; - case 'C' : - obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.target() ], - function(acp_req) { - row.my.acp = acp_req.getResultObject(); - obj.network.simple_request( 'FM_ACN_RETRIEVE', [ typeof row.my.acp.call_number() == 'object' ? row.my.acp.call_number().id() : row.my.acp.call_number() ], - function(acn_req) { - row.my.acn = acn_req.getResultObject(); + } + ); + break; + case 'T' : obj.network.request( api.MODS_SLIM_RECORD_RETRIEVE.app, api.MODS_SLIM_RECORD_RETRIEVE.method, - [ row.my.acn.record() ], + [ row.my.ahr.target() ], function(mvr_req) { - try { row.my.mvr = mvr_req.getResultObject(); } catch(E) {} - if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + row.my.mvr = mvr_req.getResultObject(); + if ( row.my.ahr.current_copy() && ! row.my.acp) { + obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ], + function(acp_req) { + row.my.acp = acp_req.getResultObject(); + if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + } + ); + } else { + if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + } + } ); - } - ); + break; + case 'V' : + row.my.acn = obj.network.simple_request( 'FM_ACN_RETRIEVE', [ row.my.ahr.target() ], + function(acn_req) { + row.my.acn = acn_req.getResultObject(); + obj.network.request( + api.MODS_SLIM_RECORD_RETRIEVE.app, + api.MODS_SLIM_RECORD_RETRIEVE.method, + [ row.my.acn.record() ], + function(mvr_req) { + try { row.my.mvr = mvr_req.getResultObject(); } catch(E) {} + if ( row.my.ahr.current_copy() && ! row.my.acp) { + obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.current_copy() ], + function(acp_req) { + row.my.acp = acp_req.getResultObject(); + if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + } + ); + } else { + if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + } + } + ); + } + ); + break; + case 'C' : + obj.network.simple_request( 'FM_ACP_RETRIEVE', [ row.my.ahr.target() ], + function(acp_req) { + row.my.acp = acp_req.getResultObject(); + obj.network.simple_request( 'FM_ACN_RETRIEVE', [ typeof row.my.acp.call_number() == 'object' ? row.my.acp.call_number().id() : row.my.acp.call_number() ], + function(acn_req) { + row.my.acn = acn_req.getResultObject(); + obj.network.request( + api.MODS_SLIM_RECORD_RETRIEVE.app, + api.MODS_SLIM_RECORD_RETRIEVE.method, + [ row.my.acn.record() ], + function(mvr_req) { + try { row.my.mvr = mvr_req.getResultObject(); } catch(E) {} + if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); } + } + ); + } + ); + } + ); + break; + } + } catch(E) { + obj.error.standard_unexpected_error_alert('Error retrieving status for hold #' + row.my.hold_id, E); } - ); - break; + } + ); + } catch(E) { + obj.error.standard_unexpected_error_alert('Error retrieving hold #' + row.my.hold_id, E); } } ); + } catch(E) { obj.error.sdump('D_ERROR','retrieve_row: ' + E ); } @@ -619,25 +646,25 @@ patron.holds.prototype = { obj.holds = window.xulG.holds; } else { var method; var params = [ ses() ]; - if (obj.patron_id) { - method = 'FM_AHR_RETRIEVE_VIA_AU'; + if (obj.patron_id) { /*************************************************** PATRON ******************************/ + method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU'; params.push( obj.patron_id ); obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true'); - } else if (obj.docid) { + } else if (obj.docid) { /*************************************************** RECORD ******************************/ method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE'; params.push( obj.docid ); obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false'); - } else if (obj.pull) { - method = 'FM_AHR_PULL_LIST'; + } else if (obj.pull) { /*************************************************** PULL ******************************/ + method = 'FM_AHR_ID_LIST_PULL_LIST'; params.push( 50 ); params.push( 0 ); } else if (obj.shelf) { - method = 'FM_AHR_ONSHELF_RETRIEVE'; + method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE'; /*************************************************** HOLD SHELF ******************************/ params.push( obj.foreign_shelf || obj.data.list.au[0].ws_ou() ); obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false'); obj.render_lib_menu(); } else { //method = 'FM_AHR_RETRIEVE_VIA_PICKUP_AOU'; - method = 'FM_AHR_PULL_LIST'; + method = 'FM_AHR_ID_LIST_PULL_LIST'; /*************************************************** PULL ******************************/ params.push( 50 ); params.push( 0 ); obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false'); } @@ -652,22 +679,15 @@ patron.holds.prototype = { } else { obj.holds = robj; } + //alert('method = ' + method + ' params = ' + js2JSON(params)); } - function list_append(hold) { - obj.holds_map[ hold.id() ] = hold; + function list_append(hold_id) { obj.list.append( { - 'retrieve_id' : js2JSON({ - 'copy_id':hold.current_copy(), - 'id':hold.id(), - 'type':hold.hold_type(), - 'target':hold.target(), - 'usr':hold.usr(), - }), 'row' : { 'my' : { - 'ahr' : hold, + 'hold_id' : hold_id, } } } @@ -676,42 +696,25 @@ patron.holds.prototype = { function gen_list_append(hold) { return function() { - if (typeof hold == 'object') { - if (typeof obj.controller.view.lib_menu == 'undefined') { - list_append(hold); - } else { - var pickup_lib = hold.pickup_lib(); - if (typeof pickup_lib == 'object') pickup_lib = pickup_lib.id(); - if (pickup_lib == obj.controller.view.lib_menu.value) { - list_append(hold); - } - } + if (typeof obj.controller.view.lib_menu == 'undefined') { + list_append(typeof hold == 'object' ? hold.id() : hold); } else { - obj.network.simple_request('FM_AHR_RETRIEVE', [ ses(), hold ], - function(req) { - try { - var robj = req.getResultObject(); - if (typeof robj.ilsevent != 'undefined') throw(robj); - if (typeof obj.controller.view.lib_menu == 'undefined') { - list_append(robj[0]); - } else { - var pickup_lib = robj[0].pickup_lib(); - if (typeof pickup_lib == 'object') pickup_lib = pickup_lib.id(); - if (pickup_lib == obj.controller.view.lib_menu.value) { - list_append(robj[0]); - } - } - } catch(E) { - obj.error.standard_unexpected_error_alert('Error retrieving hold #' + hold, E); - } - } - ); + /* + var pickup_lib = hold.pickup_lib(); + if (typeof pickup_lib == 'object') pickup_lib = pickup_lib.id(); + if (pickup_lib == obj.controller.view.lib_menu.value) { + */ + list_append(typeof hold == 'object' ? hold.id() : hold); + /* + } + */ } }; } obj.list.clear(); + //alert('obj.holds = ' + js2JSON(obj.holds)); JSAN.use('util.exec'); var exec = new util.exec(2); var rows = []; for (var i in obj.holds) { -- 2.43.2