1 dump('entering OpenILS/data.js\n');
3 if (typeof OpenILS == 'undefined') OpenILS = {};
4 OpenILS.data = function (mw,G) {
6 this.mw = mw; this.G = G;
10 JSAN.use('util.file');
11 JSAN.use('util.functional');
12 JSAN.use('util.fm_utils');
14 function gen_fm_retrieval_func(classname,data) {
15 var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
20 if (obj.list[classname].constructor.name == 'Array') {
22 util.functional.convert_object_list_to_hash(
28 obj.G.error.sdump('D_ERROR',E + '\n');
34 obj.list[classname] = obj.G.network.request( app, method, params);
36 // if cacheable, store an offline copy
38 var file = new util.file( obj.mw, obj.G, classname );
39 file.set_object( obj.list[classname] );
43 // if cacheable, try offline
46 var file = new util.file( obj.mw, obj.G, classname );
47 obj.list[classname] = file.get_object();
53 //throw(E); // for now
61 gen_fm_retrieval_func(
65 'open-ils.search.actor.user.session',
66 [ obj.G.auth.session.key ],
72 obj.G.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
74 for (var i in this._fm_objects) {
75 this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
78 // The previous org_tree call returned a tree, not a list or hash.
81 obj.org_tree = obj.list.aou;
82 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.org_tree );
83 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
88 gen_fm_retrieval_func('my_aou',
91 'open-ils.actor.org_unit.full_path.retrieve',
92 [ obj.G.auth.session.key ],
98 // Do this after we get the user object
103 gen_fm_retrieval_func( 'my_actsc',
106 'open-ils.circ.stat_cat.actor.retrieve.all',
107 [ obj.G.auth.session.key, obj.list.au.home_ou() ],
117 OpenILS.data.prototype = {
122 'init' : function () {
124 if (typeof this.on_complete == 'function') {
126 this.chain.push( this.on_complete );
129 JSAN.use('util.exec');
130 util.exec.chain( this.chain );
135 'pgt' : [ 'open-ils.actor', 'open-ils.actor.groups.retrieve', [], true ],
136 'cit' : [ 'open-ils.actor', 'open-ils.actor.user.ident_types.retrieve', [], true ],
137 'cst' : [ 'open-ils.actor', 'open-ils.actor.standings.retrieve', [], true ],
138 'acpl' : [ 'open-ils.search', 'open-ils.search.config.copy_location.retrieve.all', [], true ],
139 'ccs' : [ 'open-ils.search', 'open-ils.search.config.copy_status.retrieve.all', [], true ],
140 'aou' : [ 'open-ils.actor', 'open-ils.actor.org_tree.retrieve', [], true ],
141 'aout' : [ 'open-ils.actor', 'open-ils.actor.org_types.retrieve', [], true ]
146 dump('exiting OpenILS/data.js\n');