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];
18 obj.list[classname] = obj.G.network.request( app, method, params);
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');
30 // if cacheable, store an offline copy
32 var file = new util.file( obj.mw, obj.G, classname );
33 file.set_object( obj.list[classname] );
37 // if cacheable, try offline
48 gen_fm_retrieval_func(
52 'open-ils.search.actor.user.session',
53 [ obj.G.auth.session.key ],
59 obj.G.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
61 for (var i in this._fm_objects) {
62 this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
65 // The previous org_tree call returned a tree, not a list or hash.
68 obj.org_tree = obj.list.aou;
69 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.org_tree );
70 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
75 gen_fm_retrieval_func('my_aou',
78 'open-ils.actor.org_unit.full_path.retrieve',
79 [ obj.G.auth.session.key ],
85 // Do this after we get the user object
90 gen_fm_retrieval_func( 'my_actsc',
93 'open-ils.circ.stat_cat.actor.retrieve.all',
94 [ obj.G.auth.session.key, obj.list.au.home_ou() ],
104 OpenILS.data.prototype = {
109 'init' : function () {
111 if (typeof this.on_complete == 'function') {
113 this.chain.push( this.on_complete );
116 JSAN.use('util.exec');
117 util.exec.chain( this.chain );
122 'pgt' : [ 'open-ils.actor', 'open-ils.actor.groups.retrieve', [], true ],
123 'cit' : [ 'open-ils.actor', 'open-ils.actor.user.ident_types.retrieve', [], true ],
124 'cst' : [ 'open-ils.actor', 'open-ils.actor.standings.retrieve', [], true ],
125 'acpl' : [ 'open-ils.search', 'open-ils.search.config.copy_location.retrieve.all', [], true ],
126 'ccs' : [ 'open-ils.search', 'open-ils.search.config.copy_status.retrieve.all', [], true ],
127 'aou' : [ 'open-ils.actor', 'open-ils.actor.org_tree.retrieve', [], true ],
128 'aout' : [ 'open-ils.actor', 'open-ils.actor.org_types.retrieve', [], true ]
133 dump('exiting OpenILS/data.js\n');