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

Merge branch '192-plugin-api' into 101-admin-panel-should-use-api

parents a6bb7914 9f74e653
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:
......
......@@ -324,6 +324,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 ];
......
......@@ -498,5 +498,22 @@ describe('minerva global', function() {
assert.equal(logger.getWarnings().length, 0);
});
});
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