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

JS uses new api for search

parent 714f6d59
......@@ -205,9 +205,12 @@ ServerConnector.createGetParams = function(params) {
for (var i = 0; i < sorted.length; i++) {
var key = sorted[i];
var value = params[key];
if (Object.prototype.toString.call(value) === '[object Array]') {
if (value instanceof google.maps.Point) {
value = this.pointToString(value);
} else if (Object.prototype.toString.call(value) === '[object Array]') {
value = this.idsToString(value);
}
if (value !== undefined && value !== "") {
result += key + "=" + value + "&";
}
......@@ -443,9 +446,9 @@ ServerConnector.getModelsUrl = function(params) {
});
};
ServerConnector.getBioEntitiesUrl = function(params) {
ServerConnector.getBioEntitiesUrl = function(queryParams) {
return this.getApiUrl({
url : this.getModelsUrl(params) + "bioEntities/",
url : this.getModelsUrl(queryParams) + "bioEntities/",
});
};
......@@ -482,41 +485,10 @@ ServerConnector.getConfigurationUrl = function(token) {
return result;
};
ServerConnector.getClosestElementsByCoordinatesUrl = function(params) {
var coordinates = this.pointToString(params.coordinates);
var projectId = params.projectId;
var modelId = params.modelId;
var token = params.token;
var count = params.count;
ServerConnector.getSearchUrl = function(queryParams, filterParams) {
return this.getApiUrl({
type : "project",
method : "getClosestElementsByCoordinates",
params : {
projectId : projectId,
coordinates : coordinates,
modelId : modelId,
count : count,
token : token
},
});
};
ServerConnector.getElementsByQueryUrl = function(params) {
var query = params.query;
var projectId = params.projectId;
var token = params.token;
var perfectMatch = params.perfectMatch;
return this.getApiUrl({
type : "project",
method : "getElementsByQuery",
params : {
projectId : projectId,
query : query,
perfectMatch : perfectMatch,
token : token
},
url : this.getModelsUrl(queryParams) + "bioEntities:search",
params : filterParams,
});
};
......@@ -1020,12 +992,19 @@ ServerConnector.getSessionData = function(project) {
ServerConnector.getClosestElementsByCoordinates = function(params) {
var self = this;
var queryParams = {
modelId : params.modelId
};
var filterParams = {
coordinates : params.coordinates,
count : params.count,
};
return self.getProjectId(params.projectId).then(function(result) {
params.projectId = result;
queryParams.projectId = result;
return self.getToken();
}).then(function(token) {
params.token = token;
return self.readFile(self.getClosestElementsByCoordinatesUrl(params));
filterParams.token = token;
return self.readFile(self.getSearchUrl(queryParams, filterParams));
}).then(function(content) {
var array = JSON.parse(content);
var result = [];
......@@ -1079,12 +1058,20 @@ ServerConnector.logout = function() {
ServerConnector.getElementsByQuery = function(params) {
var self = this;
var queryParams = {
modelId : params.modelId
};
var filterParams = {
query : params.query,
perfectMatch : params.perfectMatch,
};
return self.getProjectId(params.projectId).then(function(result) {
params.projectId = result;
queryParams.projectId = result;
return self.getToken();
}).then(function(token) {
params.token = token;
return self.readFile(self.getElementsByQueryUrl(params));
filterParams.token = token;
return self.readFile(self.getSearchUrl(queryParams, filterParams));
}).then(function(content) {
var array = JSON.parse(content);
var result = [];
......
......@@ -22,8 +22,9 @@ ServerConnectorMock.init = function() {
ServerConnectorMock.init();
function replaceAsterisk(str) {
return str.replace(/\*/g,"all");
return str.replace(/\*/g,"all").replace(/\:/g,".");
}
ServerConnectorMock._readFile = function(url) {
return new Promise(function(resolve, reject) {
if (url.indexOf("http") === 0) {
......
Markdown is supported
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