]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
instead of the old progress meter, show some textual progress information
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / OpenILS / data.js
1 dump('entering OpenILS/data.js\n');
2
3 if (typeof OpenILS == 'undefined') OpenILS = {};
4 OpenILS.data = function () {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('util.network'); this.network = new util.network();
8
9         return this;
10 }
11
12 OpenILS.data.prototype = {
13
14         'list' : {},
15         'hash' : {},
16         'tree' : {},
17
18         'temp' : '',
19
20         'data_progress' : function(msg) {
21                 try {
22                         var x = document.getElementById('data_progress');
23                         if (x) {
24                                 x.appendChild( document.createTextNode( msg ) );
25                         }
26                 } catch(E) {
27                         this.error.sdump('D_ERROR',msg + '\n' + E);
28                 }
29         },
30
31         'init' : function (params) {
32
33                 try {
34                         if (params && params.via == 'stash') {  
35                                 this.stash_retrieve();
36                         } else {
37                                 this.network_retrieve();
38                         }
39                 
40                 } catch(E) {
41                         this.error.sdump('D_ERROR','Error in OpenILS.data.init('
42                                 +js2JSON(params)+'): ' + js2JSON(E) );
43                 }
44
45
46         },
47
48         'stash' : function () {
49                 try {
50                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
51                         const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
52                         var data_cache=new OpenILS( );
53                         for (var i = 0; i < arguments.length; i++) {
54                                 try {
55                                         if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + js2JSON(this[arguments[i]]) : '') + '\n');
56                                 } catch(F) { alert(F); }
57                                 data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]];
58                         }
59                 } catch(E) {
60                         this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) );
61                 }
62         },
63
64         'lookup' : function(key,value) {
65                 try {
66                         var obj = this; var found;
67                         if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value];
68                         switch(key) {
69                                 case 'acpl': 
70                                         found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID',[ value ]);
71                                 break;
72                                 default: return undefined; break;
73                         }
74                         if (typeof found.ilsevent != 'undefined') throw(found);
75                         if (!obj.hash[key]) obj.hash[key] = {};
76                         obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list');
77                         return found;
78                 } catch(E) {
79                         this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) );
80                         return undefined;
81                 }
82         },
83
84         '_debug_stash' : function() {
85                 try {
86                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
87                         const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
88                         var data_cache=new OpenILS( );
89                         for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) {
90                                 dump('_debug_stash ' + i + '\n');
91                         }
92                 } catch(E) {
93                         this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
94                 }
95         },
96
97         '_fm_objects' : {
98
99                 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ],
100                 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ],
101                 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ],
102                 /*
103                 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ],
104                 */
105                 /*
106                 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ],
107                 */
108                 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ],
109                 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ],
110                 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ],
111                 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ],
112         },
113
114         'stash_retrieve' : function() {
115                 try {
116                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
117                         const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
118                         var data_cache=new OpenILS( );
119                         var dc = data_cache.wrappedJSObject.OpenILS.prototype.data;
120                         for (var i in dc) {
121                                 this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n');
122                                 this[i] = dc[i];
123                         }
124                         if (typeof this.on_complete == 'function') {
125
126                                 this.on_complete();
127                         }
128                 } catch(E) {
129                         this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
130                 }
131         },
132
133         'print_list_defaults' : function() {
134                 var obj = this;
135                 //if (typeof obj.print_list_templates == 'undefined') {
136                 {
137                         obj.print_list_types = [ 
138                                 'offline_checkout', 
139                                 'offline_checkin', 
140                                 'offline_renew', 
141                                 'offline_inhouse_use', 
142                                 'items', 
143                                 'bills', 
144                                 'payment', 
145                                 'holds', 
146                                 /* 'patrons' */
147                         ];
148                         obj.print_list_templates = { 
149                                 'item_status' : {
150                                         'type' : 'items',
151                                         'header' : 'The following items have been examined:<hr/><ol>',
152                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%\r\n',
153                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
154                                 }, 
155                                 'transit_list' : {
156                                         'type' : 'transits',
157                                         'header' : 'Transits:<hr/><ol>',
158                                         'line_item' : '<li>From: %transit_source% To: %transit_dest_lib%<br/>\r\nWhen: %transit_source_send_time%<br />\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%<br/>\r\n',
159                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
160                                 }, 
161                                 'items_out' : {
162                                         'type' : 'items',
163                                         'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following items:<hr/><ol>',
164                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
165                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
166                                 }, 
167                                 'checkout' : {
168                                         'type' : 'items',
169                                         'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou checked out the following items:<hr/><ol>',
170                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
171                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
172                                 }, 
173                                 'offline_checkout' : {
174                                         'type' : 'offline_checkout',
175                                         'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
176                                         'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
177                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
178                                 },
179                                 'checkin' : {
180                                         'type' : 'items',
181                                         'header' : 'You checked in the following items:<hr/><ol>',
182                                         'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%  Call Number: %call_number%\r\n',
183                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
184                                 }, 
185                                 'bill_payment' : {
186                                         'type' : 'payment',
187                                         'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your  transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
188                                         'line_item' : 'Bill #%bill_id%  %last_billing_type% Received: $%payment%<br />%barcode% %title%<br /><br />',
189                                         'footer' : '</blockquote> </p> <hr />%PINES_CODE% %TODAY_TRIM%<br/> <br/> ',
190                                 },
191                                 'bills_historical' : {
192                                         'type' : 'bills',
193                                         'header' : 'Welcome to %LIBRARY%!<br/>You had the following bills:<hr/><ol>',
194                                         'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
195                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
196                                 }, 
197                                 'bills_current' : {
198                                         'type' : 'bills',
199                                         'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
200                                         'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
201                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\n<br/>\r\n',
202                                 }, 
203                                 'offline_checkin' : {
204                                         'type' : 'offline_checkin',
205                                         'header' : 'You checked in the following items:<hr/><ol>',
206                                         'line_item' : '<li>Barcode: %barcode%\r\n',
207                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
208                                 },
209                                 'offline_renew' : {
210                                         'type' : 'offline_renew',
211                                         'header' : 'You renewed the following items:<hr/><ol>',
212                                         'line_item' : '<li>Barcode: %barcode%\r\n',
213                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
214                                 },
215                                 'offline_inhouse_use' : {
216                                         'type' : 'offline_inhouse_use',
217                                         'header' : 'You marked the following in-house items used:<hr/><ol>',
218                                         'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
219                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
220                                 },
221                                 'in_house_use' : {
222                                         'type' : 'items',
223                                         'header' : 'You marked the following in-house items used:<hr/><ol>',
224                                         'line_item' : '<li>Barcode: %barcode%\r\nUses: %uses%\r\n<br />%alert_message%',
225                                         'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
226                                 },
227                                 'holds' : {
228                                         'type' : 'holds',
229                                         'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following titles on hold:<hr/><ol>',
230                                         'line_item' : '<li>%title%\r\n',
231                                         'footer' : '</ol><hr />%PINES_CODE% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n',
232                                 } 
233                         }; 
234
235                         obj.stash( 'print_list_templates', 'print_list_types' );
236                 }
237         },
238
239         'network_retrieve' : function() {
240                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
241                 var obj = this;
242
243
244                 JSAN.use('util.file'); var file = new util.file('print_list_templates');
245                 obj.print_list_defaults();
246                 obj.data_progress('Default print templates set. ');
247                 if (file._file.exists()) {
248                         try {
249                                 var x = file.get_object();
250                                 if (x) {
251                                         for (var i in x) {
252                                                 obj.print_list_templates[i] = x[i];
253                                         }
254                                         obj.stash('print_list_templates');
255                                         obj.data_progress('Saved print templates retrieved from file. ');
256                                 }
257                         } catch(E) {
258                                 alert(E);
259                         }
260                 }
261                 file.close();
262
263                 JSAN.use('util.file'); var file = new util.file('global_font_adjust');
264                 if (file._file.exists()) {
265                         try {
266                                 var x = file.get_object();
267                                 if (x) {
268                                         obj.global_font_adjust = x;
269                                         obj.stash('global_font_adjust');
270                                         obj.data_progress('Saved font settings retrieved from file. ');
271                                 }
272                         } catch(E) {
273                                 alert(E);
274                         }
275                 }
276                 file.close();
277
278                 JSAN.use('util.file'); var file = new util.file('no_sound');
279                 if (file._file.exists()) {
280                         try {
281                                 var x = file.get_content();
282                                 if (x) {
283                                         obj.no_sound = x;
284                                         obj.stash('no_sound');
285                                         obj.data_progress('Saved sound settings retrieved from file. ');
286                                 }
287                         } catch(E) {
288                                 alert(E);
289                         }
290                 }
291                 file.close();
292
293                 JSAN.use('util.functional');
294                 JSAN.use('util.fm_utils');
295
296                 function gen_fm_retrieval_func(classname,data) {
297                         var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
298                         return function () {
299                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
300
301                                 function convert() {
302                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
303                                         try {
304                                                 if (obj.list[classname].constructor.name == 'Array') {
305                                                         obj.hash[classname] = 
306                                                                 util.functional.convert_object_list_to_hash(
307                                                                         obj.list[classname]
308                                                                 );
309                                                 }
310                                         } catch(E) {
311
312                                                 obj.error.sdump('D_ERROR',E + '\n');
313                                         }
314
315                                 }
316
317                                 try {
318                                         var level = obj.error.sdump_levels.D_SES_RESULT;
319                                         if (classname == 'aou' || classname == 'my_aou')
320                                                 obj.error.sdump_levels.D_SES_RESULT = false;
321                                         var robj = obj.network.request( app, method, params);
322                                         if (!robj || robj.ilsevent) {
323                                                 obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj);
324                                                 throw(robj);
325                                         }
326                                         obj.list[classname] = robj;
327                                         obj.error.sdump_levels.D_SES_RESULT = level;
328                                         convert();
329                                         obj.data_progress('Retrieved list for ' + classname + ' objects. ');
330                                         // if cacheable, store an offline copy
331                                         /* FIXME -- we're going to revisit caching and do it differently
332                                         if (cacheable) {
333                                                 var file = new util.file( classname );
334                                                 file.set_object( obj.list[classname] );
335                                         }
336                                         */
337
338                                 } catch(E) {
339                                         // if cacheable, try offline
340                                         if (cacheable) {
341                                                 /* FIXME -- we're going to revisit caching and do it differently
342                                                 try {
343                                                         var file = new util.file( classname );
344                                                         obj.list[classname] = file.get_object(); file.close();
345                                                         convert();
346                                                 } catch(E) {
347                                                         throw(E);
348                                                 }
349                                                 */
350                                                 throw(E); // for now
351                                         } else {
352                                                 throw(E); // for now
353                                         }
354                                 }
355                         }
356                 }
357
358                 this.chain = [];
359
360                 this.chain.push(
361                         function() {
362                                 try {
363                                         var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]);
364                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
365                                         obj.list.circ_modifier = robj;
366                                         obj.data_progress('Retrieved circ modifier list. ');
367                                 } catch(E) {
368                                         var error = 'Error: ' + js2JSON(E);
369                                         obj.error.sdump('D_ERROR',error);
370                                         throw(E);
371                                 }
372                         }
373                 );
374
375                 this.chain.push(
376                         function() {
377                                 try {
378                                         var robj = obj.network.simple_request('BILLING_TYPE_LIST',[]);
379                                         if (typeof robj.ilsevent != 'undefined') throw(robj);
380                                         obj.list.billing_type = robj;
381                                         obj.data_progress('Retrieved billing type list. ');
382                                 } catch(E) {
383                                         var error = 'Error: ' + js2JSON(E);
384                                         obj.error.sdump('D_ERROR',error);
385                                         throw(E);
386                                 }
387                         }
388                 );
389
390
391                 this.chain.push(
392                         function() {
393                                 var f = gen_fm_retrieval_func(
394                                         'cnal',
395                                         [
396                                                 api.FM_CNAL_RETRIEVE.app,
397                                                 api.FM_CNAL_RETRIEVE.method,
398                                                 [ obj.session.key ],
399                                                 false
400                                         ]
401                                 );
402                                 try {
403                                         f();
404                                 } catch(E) {
405                                         var error = 'Error: ' + js2JSON(E);
406                                         obj.error.sdump('D_ERROR',error);
407                                         throw(E);
408                                 }
409                         }
410                 );
411
412                 this.chain.push(
413                         function() {
414                                 var f = gen_fm_retrieval_func(
415                                         'au',
416                                         [
417                                                 api.FM_AU_RETRIEVE_VIA_SESSION.app,
418                                                 api.FM_AU_RETRIEVE_VIA_SESSION.method,
419                                                 [ obj.session.key ],
420                                                 false
421                                         ]
422                                 );
423                                 try {
424                                         f();
425                                 } catch(E) {
426                                         var error = 'Error: ' + js2JSON(E);
427                                         obj.error.sdump('D_ERROR',error);
428                                         throw(E);
429                                 }
430                                 obj.list.au = [ obj.list.au ];
431                         }
432                 );
433
434                 this.chain.push(
435                         function() {
436                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
437                                 var f = gen_fm_retrieval_func(
438                                         'my_asv',
439                                         [
440                                                 api.FM_ASV_RETRIEVE_REQUIRED.app,
441                                                 api.FM_ASV_RETRIEVE_REQUIRED.method,
442                                                 [ obj.session.key ],
443                                                 true
444                                         ]
445                                 );
446                                 try {
447                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
448                                         f();
449                                 } catch(E) {
450                                         var error = 'Error: ' + js2JSON(E);
451                                         obj.error.sdump('D_ERROR',error);
452                                         throw(E);
453                                 }
454                         }
455                 );
456
457                 this.chain.push(
458                         function() {
459                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
460                                 var f = gen_fm_retrieval_func(
461                                         'asv',
462                                         [
463                                                 api.FM_ASV_RETRIEVE.app,
464                                                 api.FM_ASV_RETRIEVE.method,
465                                                 [ obj.session.key ],
466                                                 true
467                                         ]
468                                 );
469                                 try {
470                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
471                                         f();
472                                 } catch(E) {
473                                         var error = 'Error: ' + js2JSON(E);
474                                         obj.error.sdump('D_ERROR',error);
475                                         throw(E);
476                                 }
477                         }
478                 );
479
480                 obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
481
482                 for (var i in this._fm_objects) {
483                         this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
484                 }
485
486                 // The previous org_tree call returned a tree, not a list or hash.
487                 this.chain.push(
488                         function () {
489                                 obj.tree.aou = obj.list.aou;
490                                 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
491                                 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
492                         }
493                 );
494
495                 // The previous pgt call returned a tree, not a list or hash.
496                 this.chain.push(
497                         function () {
498                                 obj.tree.pgt = obj.list.pgt;
499                                 obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt );
500                                 obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt );
501                         }
502                 );
503
504                 // Do this after we get the user object
505                 this.chain.push(
506
507                         function() {
508
509                                 gen_fm_retrieval_func('my_aou', 
510                                         [ 
511                                                 api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app,
512                                                 api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method,
513                                                 [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */
514                                                 true
515                                         ]
516                                 )();
517                         }
518                 );
519
520                 this.chain.push(
521
522                         function () {
523
524                                 gen_fm_retrieval_func( 'my_actsc', 
525                                         [ 
526                                                 api.FM_ACTSC_RETRIEVE_VIA_AOU.app,
527                                                 api.FM_ACTSC_RETRIEVE_VIA_AOU.method,
528                                                 [ obj.session.key, obj.list.au[0].ws_ou() ],
529                                                 true
530                                         ]
531                                 )();
532                         }
533                 );
534
535                 this.chain.push(
536
537                         function () {
538
539                                 gen_fm_retrieval_func( 'my_asc', 
540                                         [ 
541                                                 api.FM_ASC_RETRIEVE_VIA_AOU.app,
542                                                 api.FM_ASC_RETRIEVE_VIA_AOU.method,
543                                                 [ obj.session.key, obj.list.au[0].ws_ou() ],
544                                                 true
545                                         ]
546                                 )();
547                         }
548                 );
549
550
551                 this.chain.push(
552                         function() {
553                                 var f = gen_fm_retrieval_func(
554                                         'cnct',
555                                         [
556                                                 api.FM_CNCT_RETRIEVE.app,
557                                                 api.FM_CNCT_RETRIEVE.method,
558                                                 [ obj.list.au[0].ws_ou() ], 
559                                                 false
560                                         ]
561                                 );
562                                 try {
563                                         f();
564                                 } catch(E) {
565                                         var error = 'Error: ' + js2JSON(E);
566                                         obj.error.sdump('D_ERROR',error);
567                                         throw(E);
568                                 }
569                         }
570                 );
571
572                 this.chain.push(
573                         function() {
574                                 var f = gen_fm_retrieval_func(
575                                         'acpl',
576                                         [
577                                                 api.FM_ACPL_RETRIEVE.app,
578                                                 api.FM_ACPL_RETRIEVE.method,
579                                                 [ obj.list.au[0].ws_ou() ],
580                                                 false
581                                         ]
582                                 );
583                                 try {
584                                         f();
585                                 } catch(E) {
586                                         var error = 'Error: ' + js2JSON(E);
587                                         obj.error.sdump('D_ERROR',error);
588                                         throw(E);
589                                 }
590                         }
591                 );
592
593
594
595                 if (typeof this.on_complete == 'function') {
596
597                         this.chain.push( this.on_complete );
598                 }
599                 JSAN.use('util.exec'); this.exec = new util.exec();
600                 this.exec.on_error = function(E) { 
601                 
602                         if (typeof obj.on_error == 'function') {
603                                 obj.on_error();
604                         } else {
605                                 alert('oops: ' + E ); 
606                         }
607
608                         return false; /* break chain */
609                 }
610
611                 this.exec.chain( this.chain );
612
613         }
614 }
615
616 dump('exiting OpenILS/data.js\n');