diff --git a/platform/commonUI/browse/res/templates/browse.html b/platform/commonUI/browse/res/templates/browse.html index aa4816a882..f2f0d4baa5 100644 --- a/platform/commonUI/browse/res/templates/browse.html +++ b/platform/commonUI/browse/res/templates/browse.html @@ -28,11 +28,11 @@ > -
+
bModified) ? a : (b || a); + } + + // Merge results from multiple providers into one + // large result object. + function mergeModels(provided, ids) { + var result = {}; + ids.forEach(function (id) { + provided.forEach(function (models) { + if (models[id]) { + result[id] = pick(result[id], models[id]); + } + }); + }); + return result; + } + + return { + /** + * Get models with the specified identifiers. + * + * This will invoke the `getModels()` method of all providers + * given at constructor-time, and aggregate the result into + * one object. + * + * Note that the returned object may contain a subset or a + * superset of the models requested. + * + * @param {string[]} ids an array of domain object identifiers + * @returns {Promise.} a promise for an object + * containing key-value pairs, + * where keys are object identifiers and values + * are object models. + */ + getModels: function (ids) { + return $q.all(providers.map(function (provider) { + return provider.getModels(ids); + })).then(function (provided) { + return mergeModels(provided, ids); + }); + } + }; + } + + return ModelAggregator; + } +); \ No newline at end of file diff --git a/platform/features/search/src/QueryService.js b/platform/features/search/src/SearchService.js similarity index 99% rename from platform/features/search/src/QueryService.js rename to platform/features/search/src/SearchService.js index 93cfe94e5b..16fb061cff 100644 --- a/platform/features/search/src/QueryService.js +++ b/platform/features/search/src/SearchService.js @@ -43,7 +43,7 @@ define( * elasticsearch). * @constructor */ - function QueryService($http, objectService, ROOT) { + function SearchService($http, objectService, ROOT) { var DEFAULT_MAX_RESULTS = 100; /////////////// The following is for non-Elastic Search ///////////////// @@ -286,6 +286,6 @@ define( }; } - return QueryService; + return SearchService; } ); \ No newline at end of file diff --git a/platform/features/search/src/SearchController.js b/platform/features/search/src/controllers/SearchController.js similarity index 94% rename from platform/features/search/src/SearchController.js rename to platform/features/search/src/controllers/SearchController.js index ec3cb7e8c7..423e6253bb 100644 --- a/platform/features/search/src/SearchController.js +++ b/platform/features/search/src/controllers/SearchController.js @@ -27,12 +27,12 @@ define(function () { "use strict"; - function SearchController($scope, queryService) { + function SearchController($scope, searchService) { return { // Search the database using the user input of id "searchinput" search: function (inputID) { - queryService.query(inputID).then(function (c) { + searchService.query(inputID).then(function (c) { $scope.results = c; }); }, diff --git a/platform/features/search/src/SearchbarController.js b/platform/features/search/src/controllers/SearchbarController.js similarity index 93% rename from platform/features/search/src/SearchbarController.js rename to platform/features/search/src/controllers/SearchbarController.js index f1166d51ea..1a48a9c793 100644 --- a/platform/features/search/src/SearchbarController.js +++ b/platform/features/search/src/controllers/SearchbarController.js @@ -27,12 +27,12 @@ define(function () { "use strict"; - function SearchbarController($scope, queryService) { + function SearchbarController($scope, searchService) { return { // Search the database using the user input of id "searchinput" search: function (inputID) { - queryService.query(inputID).then(function (c) { + searchService.query(inputID).then(function (c) { $scope.results = c; }); }, diff --git a/platform/features/search/src/providers/ElasticsearchSearchProvider.js b/platform/features/search/src/providers/ElasticsearchSearchProvider.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/features/search/src/providers/EverythingSearchProvider.js b/platform/features/search/src/providers/EverythingSearchProvider.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/features/search/src/providers/WARPTaxonomySearchProvider.js b/platform/features/search/src/providers/WARPTaxonomySearchProvider.js new file mode 100644 index 0000000000..e69de29bb2