[open-ils-commits] r17937 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Circ src/perlmods/OpenILS/Application/Storage/Publisher web/js/dojo/openils (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Sep 23 19:38:11 EDT 2010


Author: miker
Date: 2010-09-23 19:38:10 -0400 (Thu, 23 Sep 2010)
New Revision: 17937

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
   trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js
   trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
Log:
Stopping the leak

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2010-09-23 23:01:47 UTC (rev 17936)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2010-09-23 23:38:10 UTC (rev 17937)
@@ -24,6 +24,7 @@
 use OpenILS::Perm;
 use OpenILS::Event;
 use OpenSRF::Utils;
+use OpenSRF::AppSession;
 use OpenSRF::Utils::Logger qw(:logger);
 use OpenILS::Utils::CStoreEditor q/:funcs/;
 use OpenILS::Utils::PermitHold;
@@ -1265,26 +1266,127 @@
     my $hold_ids = $U->storagereq(
         'open-ils.storage.direct.action.hold_request.pull_list.id_list.current_copy_circ_lib.status_filtered.atomic',
         $org_id, 10000);
-
+    
     return undef unless @$hold_ids;
     $client->status(new OpenSRF::DomainObject::oilsContinueStatus);
-
+    
     # Holds will /NOT/ be in order after this ...
     my $holds = $e->search_action_hold_request({id => $hold_ids}, {substream => 1});
     $client->status(new OpenSRF::DomainObject::oilsContinueStatus);
-
+    
     # ... so we must resort.
     my $hold_map = +{map { $_->id => $_ } @$holds};
     my $sorted_holds = [];
     push @$sorted_holds, $hold_map->{$_} foreach @$hold_ids;
-
+    
     return $U->fire_object_event(
         undef, "ahr.format.pull_list", $sorted_holds, $org_id
     );
+
 }
 
+__PACKAGE__->register_method(
+    method    => "print_hold_pull_list_stream",
+    api_name  => "open-ils.circ.hold_pull_list.print.stream",
+    signature => {
+        desc   => 'Returns a stream of fleshed holds',
+        params => [
+            { desc => 'Authtoken', type => 'string'},
+            { desc => 'Hash of optional param: Org unit ID (defaults to workstation org unit), limit, offset, sort (array of: acplo.position, call_number, request_time)',
+              type => 'object'
+            },
+        ],
+        return => {
+            desc => 'A stream of fleshed holds',
+            type => 'object'
+        }
+    }
+);
 
+sub print_hold_pull_list_stream {
+    my($self, $client, $auth, $params) = @_;
 
+    my $e = new_editor(authtoken=>$auth, xact=>1);
+    return $e->die_event unless $e->checkauth;
+
+    delete($$params{org_id}) unless (int($$params{org_id}));
+    delete($$params{limit}) unless (int($$params{limit}));
+    delete($$params{offset}) unless (int($$params{offset}));
+
+    $$params{org_id} = (defined $$params{org_id}) ? $$params{org_id}: $e->requestor->ws_ou;
+    return $e->die_event unless $e->allowed('VIEW_HOLD', $$params{org_id });
+
+    my $sort = 'ahr.request_time';
+    if ($$params{sort} && @{ $$params{sort} }) {
+        $sort = '';
+        for my $s (@{ $$params{sort} }) {
+            if ($s eq 'acplo.position') {
+                $s = 'coalesce(acplo.position,999)';
+            } elsif ($s eq 'call_number') {
+                $s = 'acn.label';
+            } elsif ($s eq 'request_time') {
+                $s = 'ahr.request_time';
+            } else {
+                $s = '';
+            }
+
+            $sort .= ', ' if ($sort);
+            $sort .= $s;
+        }
+    }
+
+    my $req = OpenSRF::AppSession->create('open-ils.cstore')->request(
+        'open-ils.cstore.direct.action.hold_request',
+        {   capture_time => undef,
+            cancel_time => undef,
+            '-or' => [
+                { expire_time => undef },
+                { expire_time => { '>' => 'now' } }
+            ]
+        },{
+            flesh => 3,
+            flesh_fields => {
+                ahr => [ "usr","current_copy" ],
+                au  => [ "card" ],
+                acp => [ "location", "call_number" ],
+                acn => [ "record" ]
+            },
+            join => {
+                acp => { 
+                    field => 'id',
+                    fkey => 'current_copy',
+                    filter => { circ_lib => $$params{org_id}, status => [0,7] },
+                    join => {
+                        acn => {
+                            field => 'id',
+                            fkey => 'call_number' 
+                        },
+                        acplo => {
+                            field => 'org',
+                            fkey => 'circ_lib', 
+                            type => 'left'
+                        }
+                    }
+                }
+            },
+            order_by => $sort,
+            ($$params{limit} ? (limit => $$params{limit}) : ()),
+            ($$params{offset} ? (offset => $$params{offset}) : ()),
+        }
+    );
+
+    while (my $resp = $req->recv( timeout => 180 )) {
+        if ($req->failed) {
+            throw OpenSRF::EX::ERROR ($self->failed()->stringify())
+        }
+        $self->respond( $resp->content );
+    }
+
+    return $self->respond_complete;
+}
+
+
+
 __PACKAGE__->register_method(
     method        => 'fetch_hold_notify',
     api_name      => 'open-ils.circ.hold_notification.retrieve_by_hold',

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-09-23 23:01:47 UTC (rev 17936)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-09-23 23:38:10 UTC (rev 17937)
@@ -1294,7 +1294,7 @@
 					my %circ_lib_map =  map { (''.$_->circ_lib => 1) } @$all_copies;
 					my $circ_lib_list = [keys %circ_lib_map];
 	
-					my $cstore = OpenSRF::AppSession->connect('open-ils.cstore');
+					my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
 	
 					# Grab the "biggest" loop for this hold so far
 					my $current_loop = $cstore->request(

Modified: trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js	2010-09-23 23:01:47 UTC (rev 17936)
+++ trunk/Open-ILS/web/js/dojo/openils/BibTemplate.js	2010-09-23 23:38:10 UTC (rev 17937)
@@ -36,6 +36,9 @@
             this.locale = kwargs.locale || OpenSRF.locale || 'en-US';
             this.nodelay = kwargs.delay == false;
 
+            if (this.xml && this.xml instanceof String)
+                this.xml = dojox.xml.parser.parse(this.xml);
+
             this.mode = 'biblio-record_entry';
             this.default_datatype = 'marcxml-uris';
             if (kwargs.metarecord) {
@@ -56,12 +59,11 @@
         },
 
         textContent : function (node) {
-            var content = '';
             if (node) {
-                if(window.ActiveXObject) content = node.text;
-                else content = node.textContent;
+                if (node instanceof HTMLElement) return node.innerText || node.textContent;
+                return dojox.xml.parser.textContent(node);
             }
-            return content;
+            return '';
         },
 
         render : function() {

Modified: trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js	2010-09-23 23:01:47 UTC (rev 17936)
+++ trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js	2010-09-23 23:38:10 UTC (rev 17937)
@@ -26,11 +26,13 @@
         session : null,
         authtoken : null,
         connnected : false,
+        authoritative : false,
 
         constructor : function ( kwargs ) {
             kwargs = kwargs || {};
 
             this.authtoken = kwargs.authtoken;
+            this.authoritative = kwargs.authoritative;
 
             this.session =
                 kwargs.session ||
@@ -66,8 +68,42 @@
                 return false;
             }
         },
-        
 
+        _session_request : function ( args /* hash */, commitOnComplete /* set to true, else no */ ) {
+
+            var me = this;
+            var endstyle = 'rollback';
+            if (commitOnComplete) endstyle = 'commit';
+
+            if (me.authoritative) {
+                if (!me.connected) me.connect();
+                if (args.timeout && !args.oncomplete && !args.onresponse) { // pure sync call
+                    args.oncomplete = function (r) {
+                        me.session.request('open-ils.pcrud.transaction.' + endstyle, me.auth());
+                        me.session.disconnect();
+                        me.disconnect();
+                    };
+                } else if (args.oncomplete) { // there's an oncomplete, fire that, and then end the transaction
+                    var orig_oncomplete = args.oncomplete;
+                    args.oncomplete = function (r) {
+                        var ret;
+                        try {
+                            ret = orig_oncomplete(r);
+                        } finally {
+                            me.session.request('open-ils.pcrud.transaction.' + endstyle, me.auth());
+                            me.session.disconnect();
+                            me.disconnect();
+                        }
+                        return ret;
+                    };
+                }
+
+            if (me.authoritative) me.session.request('open-ils.pcrud.transaction.begin', me.auth() );
+
+            return me.session.request( args );
+
+        },
+
         retrieve : function ( fm_class /* Fieldmapper class hint */, id /* Fieldmapper object primary key value */,  opts /* Option hash */) {
             if(!opts) opts = {};
             var req_hash = dojo.mixin(
@@ -80,7 +116,7 @@
             if (!opts.async && !opts.timeout) req_hash.timeout = 10;
 
             var _pcrud = this;
-            var req = this.session.request( req_hash );
+            var req = this._session_request( req_hash );
 
             if (!req.onerror)
                 req.onerror = function (r) { throw js2JSON(r); };
@@ -129,7 +165,7 @@
             if (!opts.async && !opts.timeout) req_hash.timeout = 10;
 
             var _pcrud = this;
-            var req = this.session.request( req_hash );
+            var req = this._session_request( req_hash );
 
             if (!req.onerror)
                 req.onerror = function (r) { throw js2JSON(r); };
@@ -175,7 +211,7 @@
             if (!opts.async && !opts.timeout) req_hash.timeout = 10;
 
             var _pcrud = this;
-            var req = this.session.request( req_hash );
+            var req = this._session_request( req_hash );
 
             if (!req.onerror)
                 req.onerror = function (r) { throw js2JSON(r); };



More information about the open-ils-commits mailing list