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();
63 var f = gen_fm_retrieval_func(
67 'open-ils.search.actor.user.session',
68 [ obj.G.auth.session.key ],
75 // Probably the one thing we should not cache, so what do we do?
76 obj.list.au = new au();
77 obj.list.au.home_lib( '1' );
82 obj.G.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
84 for (var i in this._fm_objects) {
85 this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
88 // The previous org_tree call returned a tree, not a list or hash.
91 obj.org_tree = obj.list.aou;
92 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.org_tree );
93 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
98 gen_fm_retrieval_func('my_aou',
101 'open-ils.actor.org_unit.full_path.retrieve',
102 [ obj.G.auth.session.key ],
108 // Do this after we get the user object
113 gen_fm_retrieval_func( 'my_actsc',
116 'open-ils.circ.stat_cat.actor.retrieve.all',
117 [ obj.G.auth.session.key, obj.list.au.home_ou() ],
127 OpenILS.data.prototype = {
132 'init' : function () {
134 if (typeof this.on_complete == 'function') {
136 this.chain.push( this.on_complete );
139 JSAN.use('util.exec');
140 util.exec.chain( this.chain );
145 'pgt' : [ 'open-ils.actor', 'open-ils.actor.groups.retrieve', [], true ],
146 'cit' : [ 'open-ils.actor', 'open-ils.actor.user.ident_types.retrieve', [], true ],
147 'cst' : [ 'open-ils.actor', 'open-ils.actor.standings.retrieve', [], true ],
148 'acpl' : [ 'open-ils.search', 'open-ils.search.config.copy_location.retrieve.all', [], true ],
149 'ccs' : [ 'open-ils.search', 'open-ils.search.config.copy_status.retrieve.all', [], true ],
150 'aou' : [ 'open-ils.actor', 'open-ils.actor.org_tree.retrieve', [], true ],
151 'aout' : [ 'open-ils.actor', 'open-ils.actor.org_types.retrieve', [], true ]
156 dump('exiting OpenILS/data.js\n');