Author: ygrego Date: 2015-04-03 13:10:50 +0000 (Fri, 03 Apr 2015) New Revision: 1072 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1072 Log: Two arrays are added to "_constraints" and a new method "addChannelConstraint" has been added. Modified: oipf/js/impl/model/MetadataSearch.js Modified: oipf/js/impl/model/MetadataSearch.js =================================================================== --- oipf/js/impl/model/MetadataSearch.js 2015-04-03 12:32:15 UTC (rev 1071) +++ oipf/js/impl/model/MetadataSearch.js 2015-04-03 13:10:50 UTC (rev 1072) @@ -132,7 +132,10 @@ init: function(searchTarget, searchManager) { this.searchTarget = searchTarget; this._searchManager = searchManager; - this._constraints = {}; + this._constraints = { + channels: [], + ratings: [] + }; }, /* @@ -184,6 +187,33 @@ */ setQuery: function(query){ this._currentQuery = query; + }, + + /* + * Description: + * Constrain the search to only include results from + * the specified channel(s). + * If a channelconstraint has already been set, subsequent calls to + * addChannelConstraint() SHALL add the specified channel(s) to the list of + * channels from which results should be returned. + * For CoD searches, adding a channel constraint SHALL have no effect. + * + * Arguments: + * -channels: The channel(s) from which results SHALL be returned. + * If the value of this argument is null, any existing channel + * constraint SHALL be removed. + * + */ + addChannelConstraint: function(channels) { + if (channels.length) { + for (var i = 0, l = channels.length; i <= l; i + 1) { + this._constraints.channels && + this._constraints.channels.push(channels[i]); + } + } else { + this._constraints.channels && + this._constraints.channels.push(channels); + } } }); \ No newline at end of file