"use strict"; /** *  * Licensed Materials - Property of IBM  * IBM Cognos Products: Cognos * Analytics  * Copyright IBM Corp. 2015, 2016  * US Government Users Restricted * Rights - Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp.   */ define(['doT', 'q', 'jquery', 'underscore', 'bi/admin/nls/StringResource', 'bi/admin/common/ui/listview/ListDataAdaptor'], function (dot, Q, $, _, StringResource, ListDataAdaptor) { var SessionDataAdaptor = ListDataAdaptor.extend({ pageSize: 2000, session: null, init: function init(options) { SessionDataAdaptor.inherited('init', this, arguments); $.extend(this, options); }, hasMore: function hasMore() { return this.hasNextPage(); }, onConditionChanged: function onConditionChanged() { this.clearSession(); }, _hasSecondaryRequest: function _hasSecondaryRequest(name) { var found = null; var sr = this.session ? this.session['secondaryRequest'] : null; if (sr) { found = _.find(sr, function (item) { return item.name === name; }); } return !!found; }, hasNextPage: function hasNextPage() { return this._hasSecondaryRequest('nextPage'); }, hasRelease: function hasRelease() { return this._hasSecondaryRequest('release'); }, clearSession: function clearSession() { this.session = null; }, getResultRowsKey: function getResultRowsKey() { if (this.activityType === 'schedule') { return 'schedules'; } else { return 'activities'; } }, cacheSession: function cacheSession(result) { this.session = null; this.session = _.pick(result, 'secondaryRequest', 'primaryRequest', 'tracking', this.getResultRowsKey()); } }); return SessionDataAdaptor; });