1 dump('entering OpenILS/data.js\n');
3 if (typeof OpenILS == 'undefined') OpenILS = {};
4 OpenILS.data = function (auth) {
8 JSAN.use('util.error'); this.error = new util.error();
9 JSAN.use('main.network'); this.network = new main.network();
13 JSAN.use('util.file');
14 JSAN.use('util.functional');
15 JSAN.use('util.fm_utils');
17 function gen_fm_retrieval_func(classname,data) {
18 var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
23 if (obj.list[classname].constructor.name == 'Array') {
25 util.functional.convert_object_list_to_hash(
31 obj.error.sdump('D_ERROR',E + '\n');
37 obj.list[classname] = obj.network.request( app, method, params);
39 // if cacheable, store an offline copy
41 var file = new util.file( classname );
42 file.set_object( obj.list[classname] );
46 // if cacheable, try offline
49 var file = new util.file( classname );
50 obj.list[classname] = file.get_object();
66 var f = gen_fm_retrieval_func(
70 'open-ils.search.actor.user.session',
71 [ obj.auth.session.key ],
78 // Probably the one thing we should not cache, so what do we do?
79 obj.list.au = new au();
80 obj.list.au.home_lib( '1' );
85 obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
87 for (var i in this._fm_objects) {
88 this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
91 // The previous org_tree call returned a tree, not a list or hash.
94 obj.org_tree = obj.list.aou;
95 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.org_tree );
96 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
101 gen_fm_retrieval_func('my_aou',
104 'open-ils.actor.org_unit.full_path.retrieve',
105 [ obj.auth.session.key ],
111 // Do this after we get the user object
116 gen_fm_retrieval_func( 'my_actsc',
119 'open-ils.circ.stat_cat.actor.retrieve.all',
120 [ obj.auth.session.key, obj.list.au.home_ou() ],
130 OpenILS.data.prototype = {
135 'init' : function () {
137 if (typeof this.on_complete == 'function') {
139 this.chain.push( this.on_complete );
142 JSAN.use('util.exec');
143 util.exec.chain( this.chain );
148 'pgt' : [ 'open-ils.actor', 'open-ils.actor.groups.retrieve', [], true ],
149 'cit' : [ 'open-ils.actor', 'open-ils.actor.user.ident_types.retrieve', [], true ],
150 'cst' : [ 'open-ils.actor', 'open-ils.actor.standings.retrieve', [], true ],
151 'acpl' : [ 'open-ils.search', 'open-ils.search.config.copy_location.retrieve.all', [], true ],
152 'ccs' : [ 'open-ils.search', 'open-ils.search.config.copy_status.retrieve.all', [], true ],
153 'aou' : [ 'open-ils.actor', 'open-ils.actor.org_tree.retrieve', [], true ],
154 'aout' : [ 'open-ils.actor', 'open-ils.actor.org_types.retrieve', [], true ]
159 dump('exiting OpenILS/data.js\n');