Skip to content
Snippets Groups Projects
Commit 6a6feb08 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

getBioentities allows to pass list of identifiers

parent 644a0570
No related branches found
No related tags found
1 merge request!12Resolve "new JS API calls"
......@@ -194,6 +194,40 @@ function createMarkerElements(options) {
return markerElements;
}
function getElements(elementIdentifiers, customMap) {
var identifiedElements = [];
var elementsByModelId = [];
for (var i=0;i<elementIdentifiers.length;i++) {
var identifiedElement = new IdentifiedElement(elementIdentifiers[i]);
if (elementsByModelId[identifiedElement.getModelId()]===undefined) {
elementsByModelId[identifiedElement.getModelId()] = [];
}
elementsByModelId[identifiedElement.getModelId()].push(identifiedElement);
identifiedElements.push(identifiedElement);
}
var modelScopePromises = [];
for (var key in elementsByModelId) {
if (elementsByModelId.hasOwnProperty(key)) {
var model = customMap.getModel().getSubmodelById(parseInt(key));
modelScopePromises.push(model.getByIdentifiedElements(elementsByModelId[key], true));
}
}
//first promise fetch all data
return Promise.all(modelScopePromises).then(function(){
//this promise return result in the right order
var elementPromises = [];
for (var i=0;i<identifiedElements.length;i++) {
var element = identifiedElements[i];
var model = customMap.getModel().getSubmodelById(element.getModelId());
var promise = model.getByIdentifiedElement(element, true);
elementPromises.push(promise);
}
return Promise.all(elementPromises);
});
}
function createResult(customMap) {
return {
getVisibleDataOverlays : function() {
......@@ -212,8 +246,30 @@ function createResult(customMap) {
dbOverlayName = "user";
}
var dbOverlay = getOverlayByName(customMap, dbOverlayName);
return dbOverlay.getIdentifiedElements().then(function(identifiedElements) {
var identifiedElements;
return dbOverlay.getIdentifiedElements().then(function(result) {
identifiedElements = result;
return getFullElements(customMap, identifiedElements);
}).then(function(fullElements) {
var result = [];
for (var i = 0; i < identifiedElements.length; i++) {
var type;
if (identifiedElements[i].getIcon() !== undefined) {
type = "ICON";
} else {
type = "SURFACE";
}
var row = {
element : fullElements[i],
type : type,
options : {
icon : identifiedElements[i].getIcon(),
color : identifiedElements[i].getColor()
}
}
result.push(row);
}
return result;
});
},
getProject : function() {
......@@ -223,9 +279,20 @@ function createResult(customMap) {
return ServerConnector.getConfiguration();
},
getBioEntityById : function(param) {
var identifiedElement = new IdentifiedElement(param);
var model = customMap.getModel().getSubmodelById(identifiedElement.getModelId());
return model.getByIdentifiedElement(identifiedElement, true);
var isArray = true;
if (param.length === undefined) {
param = [ param ];
isArray = false;
}
return getElements(param, customMap).then(function(result) {
if (!isArray) {
return result[0];
} else {
return result;
}
});
},
getReactionsWithElement : function(param) {
var identifiedElement = new IdentifiedElement(param);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment