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

JS api for returning all elements on the map

parent 6572b43c
No related branches found
No related tags found
2 merge requests!115Resolve "admin panel should use API",!114Resolve "admin panel should use API"
......@@ -523,6 +523,12 @@ customMap.getProject()
```
customMap.getConfiguration().then(function(configuration){console.log(configuration);});
```
* `getAllBioEntities()`
* Arguments: NONE
* Example:
```
customMap.getAllBioEntities().then(function(bioEntities){console.log(bioEntities);});
```
* `getBioEntityById({id, modelId, type})`
* Arguments: TODO
* Example:
......
......@@ -323,6 +323,37 @@ function createResult(customMap) {
}
});
},
getAllBioEntities : function() {
var models = [ customMap.getModel() ];
var result = [];
for (var i = 0; i < customMap.getModel().getSubmodels().length; i++) {
models.push(customMap.getModel().getSubmodels()[i]);
}
var promises = [];
for (var i = 0; i < models.length; i++) {
promises.push(models[i].getAliases({
type : customMap.getConfiguration().getElementTypes(),
complete : true,
}));
}
return Promise.all(promises).then(function(aliasesByModel) {
var promises = [];
for (var i = 0; i < models.length; i++) {
promises.push(models[i].getReactionsForElements(aliasesByModel[i], true));
for (var j = 0; j < aliasesByModel[i].length; j++) {
result.push(aliasesByModel[i][j]);
}
}
return Promise.all(promises);
}).then(function(reactionsByModel) {
for (var i = 0; i < models.length; i++) {
for (var j = 0; j < reactionsByModel[i].length; j++) {
result.push(reactionsByModel[i][j]);
}
}
return result;
});
},
getReactionsWithElement : function(param) {
if (param.length === undefined) {
param = [ param ];
......
......@@ -496,4 +496,21 @@ describe('minerva global', function() {
});
});
it("getAllBioEntities", function() {
var options = {
projectId : "sample",
element : testDiv
};
var globalResult;
return minerva.create(options).then(function(result) {
globalResult = result;
return result.getAllBioEntities();
}).then(function(result) {
assert.ok(result);
assert.ok(result.length > 0);
}).then(function() {
globalResult.destroy();
});
});
});
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