"mapClause": null,
"sloClause": null,
"limit": 25,
+ "offset": 0,
"constructor": function(/* object */ args) {
"_prepare_flattener_params": function(req) {
var limit = (!isNaN(req.count) && req.count != Infinity) ?
req.count : this.limit;
+ var offset = (!isNaN(req.start) && req.start != Infinity) ?
+ req.start : this.offset;
- // XXX TODO
- // get offset(start) too, mixing base sort if any, check
- // grid sorting (multicolumn)
-// var slo = dojo.clone(this.sloClause);
-// slo.limit = limit;
-//
- var slo = {"limit": limit, "sort": "barcode"};
-
- // XXX offset
var content = {
"hint": this.fmClass,
"ses": openils.User.authtoken,
"where": dojo.toJson(req.query),
- "slo": dojo.toJson(slo)
- //"identifier": this.fmIdentifier
+ "slo": dojo.toJson({
+ "sort": req.sort, /* XXX TODO translate from dojo sort format to flattener format - easy */
+ "limit": limit,
+ "offset": offset
+ })
};
if (this.mapKey) { /* XXX TODO, get a map key */
/* object */ item,
/* string */ attribute,
/* anything */ defaultValue) {
- console.log("getValue(" + lazy(item) + ", " + attribute + ", " + defaultValue + ")")
+ //console.log("getValue(" + lazy(item) + ", " + attribute + ", " + defaultValue + ")")
if (!this.isItem(item))
throw new FlattenerStoreError("getValue(): bad item " + item);
else if (typeof attribute != "string")
},
"isItem": function(/* anything */ something) {
- console.log("isItem(" + lazy(something) + ")");
+ //console.log("isItem(" + lazy(something) + ")");
if (typeof something != "object" || something === null)
return false;
"close": function(/* object */ request) { /* no-op */ return; },
- /* =========== not dealt with at all below here yet ============ */
-
"getLabel": function(/* object */ item) {
console.log("getLabel(" + item + ")");
- return "match";
+ return "XXX TODO";
},
"getLabelAttributes": function(/* object */ item) {
console.log("getLabelAttributes(" + item + ")");
- return ["match"];
+ return ["XXX TODO"];
},
"loadItem": function(/* object */ keywordArgs) {
// translation for our server-side service
// count an int
// onBegin a callback that takes the number of items
- // that this call to fetch() will return, but
- // we always give it -1 (i.e. unknown)
+ // that this call to fetch() will return
// onItem a callback that takes each item as we get it
// onComplete a callback that takes the list of items
// after they're all fetched
return;
console.log(dojo.toJson(obj));
- if (typeof req.onBegin == "function")
+ if (typeof req.onBegin == "function") {
+ console.debug("onBegin(" + obj.length + ", ...)");
req.onBegin.call(callback_scope, obj.length, req);
+ }
dojo.forEach(
obj,
function(item) {
- self._current_items[item.id] = item;
+ self._current_items[item[self.fmIdentifier]] = item;
- if (typeof req.onItem == "function")
+ if (typeof req.onItem == "function") {
req.onItem.call(callback_scope, item, req);
+ }
}
);
if (!this.isItem(item))
throw new FlattenerStoreError("not an item");
- return item.id;
+ return item[this.fmIdentifier];
},
"getIdentityAttributes": function(/* object */ item) {
console.log("getIdentityAttributes(" + item + ")");
- return ["id"];
+ return [this.fmIdentifier];
},
"fetchItemByIdentity": function(/* object */ keywordArgs) {
+
+ /* XXX This almost certainly needs attention, and/or
+ * needs to be able to call fetch() or to talk to the
+ * web service directly. */
+
console.log("fetchItemByIdentity(" + dojo.toJson(keywordArgs)+ ")");
if (keywordArgs.identity == undefined)
return null; // Identity API spec unclear whether error callback