Commit 4e3dfb2c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

getElements uses new API call

parent dab203a0
......@@ -215,7 +215,10 @@ ServerConnector.getApiUrl = function(paramObj) {
var method = paramObj.method;
var params = this.createGetParams(paramObj.params);
var result = this.getApiBaseUrl() + "/" + type;
var result = paramObj.url;
if (result === undefined) {
result = this.getApiBaseUrl() + "/" + type;
}
if (method !== undefined) {
result += "/" + method;
}
......@@ -225,12 +228,14 @@ ServerConnector.getApiUrl = function(paramObj) {
return result;
};
ServerConnector.getProjectUrl = function(projectId, token) {
ServerConnector.getProjectsUrl = function(queryParams, filterParams) {
var params = {};
if (filterParams !== undefined) {
params.token = filterParams.token;
}
return this.getApiUrl({
type : "projects/" + projectId,
params : {
token : token,
},
type : "projects/" + queryParams.projectId + "/",
params : params,
});
};
......@@ -437,6 +442,20 @@ ServerConnector.columnsToString = function(columns) {
return columns;
};
ServerConnector.getModelsUrl = function(params) {
var modelId = this.getIdOrAsterisk(params.modelId);
return this.getApiUrl({
url : this.getProjectsUrl(params) + "/models/" + modelId + "/",
});
};
ServerConnector.getBioEntitiesUrl = function(params) {
return this.getApiUrl({
url : this.getModelsUrl(params) + "/bioEntities",
});
};
ServerConnector.getReactionsUrl = function(params) {
var id = this.idsToString(params.ids);
var columns = this.columnsToString(params.columns);
......@@ -455,17 +474,24 @@ ServerConnector.getReactionsUrl = function(params) {
});
};
ServerConnector.getIdOrAsterisk = function(id) {
if (id === undefined || id === "" || id === null) {
return "*";
} else {
return id;
}
}
ServerConnector.getAliasesUrl = function(params) {
var id = this.idsToString(params.ids);
var columns = this.columnsToString(params.columns);
var projectId = params.projectId;
var token = params.token;
var modelId = this.getIdOrAsterisk(params.modelId);
return this.getApiUrl({
type : "project",
method : "getElements",
url : this.getBioEntitiesUrl(params) + "/elements",
params : {
projectId : projectId,
columns : columns,
id : id,
token : token
......@@ -783,13 +809,16 @@ ServerConnector.getConfigurationParam = function(paramId) {
};
ServerConnector.getProject = function(projectId) {
var queryParams = {};
var filterParams = {};
var project;
var self = this;
return self.getProjectId(projectId).then(function(result) {
projectId = result;
queryParams.projectId = result;
return self.getToken();
}).then(function(token) {
return self.readFile(self.getProjectUrl(projectId, token));
filterParams.token = token;
return self.readFile(self.getProjectsUrl(queryParams, filterParams));
}).then(function(content) {
project = new Project(content);
return self.getOverlays(projectId);
......
......@@ -21,6 +21,9 @@ ServerConnectorMock.init = function() {
};
ServerConnectorMock.init();
function replaceAsterisk(str) {
return str.replace(/\*/g,"all");
}
ServerConnectorMock._readFile = function(url) {
return new Promise(function(resolve, reject) {
if (url.indexOf("http") === 0) {
......@@ -34,7 +37,8 @@ ServerConnectorMock._readFile = function(url) {
}
});
} else {
fs.readFile(url, 'utf8', function(err, content) {
fs.readFile(replaceAsterisk(url), 'utf8', function(err, content) {
if (err) {
reject(err);
} else {
......
......@@ -229,20 +229,17 @@ describe('CustomMap', function() {
});
it("openInfoWindowForAlias for incomplete alias", function() {
var map = helper.createCustomMap();
var layout = helper.createLayout();
var alias = helper.createAlias(map);
alias.setId(30001);
alias.setIsComplete(false);
var layoutAlias = helper.createLayoutAlias(alias);
layout.addAlias(layoutAlias);
// create layout
map.getModel().addLayout(layout);
map.getModel().addAlias(alias);
var map, alias;
return ServerConnector.getProject().then(function(project) {
var options = helper.createCustomMapOptions(project);
map = new CustomMap(options);
return map.openInfoWindowForAlias(alias.getId(), map.getId(), function() {
return map.getModel().getAliasById(329171, false);
}).then(function(result) {
alias = result;
assert.notOk(alias.isComplete());
return map.openInfoWindowForAlias(alias.getId(), map.getId());
}).then(function() {
assert.ok(map.getAliasInfoWindowById(alias.getId()));
assert.ok(map.getAliasInfoWindowById(alias.getId()).isOpened());
});
......
[{"formerSymbols":[],"references":[],"modelId":15781,"synonyms":[],"description":"","type":"Unknown","name":"s11","bounds":{"x":105.0,"y":203.5,"width":70.0,"height":25.0},"id":30001}]
\ No newline at end of file
[{"modelId":100,"bounds":{"x":683.0,"y":132.0,"width":70.0,"height":25.0},"id":1021}]
\ No newline at end of file
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