Commit b7c44aa3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

icons are merged on the map

parent e92ffa3b
......@@ -1084,7 +1084,13 @@ CustomMap.prototype.fetchIdentifiedElements = function (elements, complete) {
var modelId = modelIds[i];
promises.push(this.getSubmapById(modelId).getModel().getByIdentifiedElements(modelElements[modelId], complete));
}
return Promise.all(promises);
var result = [];
return Promise.all(promises).then(function (data) {
for (var i = 0; i < data.length; i++) {
result.push.apply(result, data[i]);
}
return result;
});
};
......
......@@ -11,6 +11,8 @@ var Alias = require('../data/Alias');
var IdentifiedElement = require('../data/IdentifiedElement');
var InvalidArgumentException = require('../../InvalidArgumentError');
var Reaction = require('../data/Reaction');
var SearchBioEntityGroup = require('../data/SearchBioEntityGroup');
var ServerConnector = require('../../ServerConnector');
......@@ -236,27 +238,50 @@ SearchDbOverlay.prototype.searchByTarget = function (element) {
SearchDbOverlay.prototype.getIdentifiedElements = function () {
var self = this;
var queries = self.getQueries();
var result = [];
return new Promise(function (resolve) {
var queries = self.getQueries();
var result = [];
for (var i = 0; i < queries.length; i++) {
var query = queries[i];
var elements = self._elementsByQuery[query];
return Promise.each(queries, function (query, index) {
var identifiedElements = self._elementsByQuery[query];
return self.getMap().fetchIdentifiedElements(identifiedElements).then(function (elements) {
var iconCounter = 1;
for (var j = 0; j < elements.length; j++) {
var element = elements[j];
var groups = [];
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var alreadyExists = false;
var icon = null;
var group;
for (var j = 0; j < groups.length; j++) {
group = groups[j];
if (group.bioEntityMatch(element)) {
alreadyExists = true;
group.addBioEntity(element);
icon = group.getIcon();
}
}
if (!alreadyExists) {
if (element instanceof Alias) {
icon = self.getIcon(index, iconCounter++)
}
group = new SearchBioEntityGroup(element);
group.setIcon(icon);
groups.push(group);
}
var ie = new IdentifiedElement(element);
if (element.getType() === "ALIAS") {
ie.setIcon(self.getIcon(i, iconCounter++));
} else if (element.getType() !== "REACTION") {
throw new Error("Unknown element type: " + element.getType());
if (element instanceof Alias) {
ie.setIcon(icon);
} else if (!(element instanceof Reaction)) {
throw new Error("Unknown element type: " + ie.getType());
}
result.push(ie);
}
}
resolve(result);
});
}).then(function () {
return result;
});
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment