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

new api for downloading overlay data

parent bb552072
No related branches found
No related tags found
1 merge request!11Resolve "Rest API should follow google guidlines"
......@@ -569,19 +569,10 @@ ServerConnector.getMiRnasByQueryUrl = function(params) {
},
});
};
ServerConnector.getOverlaySourceUrl = function(params) {
var overlayId = params.overlayId;
var projectId = params.projectId;
var token = params.token;
ServerConnector.getOverlaySourceUrl = function(queryParams, filterParams) {
return this.getApiUrl({
type : "overlay",
method : "getOverlaySource",
params : {
overlayId : overlayId,
projectId : projectId,
token : token
},
url : this.getOverlaysUrl(queryParams) + queryParams.overlayId + ":downloadSource",
params : filterParams
});
};
......@@ -1182,12 +1173,16 @@ ServerConnector.getChemicalsByQuery = function(params) {
ServerConnector.getOverlaySourceDownloadUrl = function(params) {
var self = this;
var queryParams = {
overlayId : params.overlayId
};
var filterParams = {};
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.getOverlaySourceUrl(params);
filterParams.token = token;
return self.getOverlaySourceUrl(queryParams, filterParams);
});
};
......
......@@ -15,7 +15,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import lcsb.mapviewer.api.BaseController;
import lcsb.mapviewer.api.QueryException;
......@@ -106,11 +107,12 @@ public class OverlayController extends BaseController {
@PathVariable(value = "overlayId") String overlayId //
) throws SecurityException, QueryException, IOException {
Map<String, Object> node = parseBody(body);
return overlayRestImp.removeOverlay((String)node.get("token"), projectId, overlayId);
return overlayRestImp.removeOverlay((String) node.get("token"), projectId, overlayId);
}
@RequestMapping(value = "/projects/{projectId}/overlays/{overlayId}", method = { RequestMethod.PATCH }, produces = { MediaType.APPLICATION_JSON_VALUE })
public LayoutView updateOverlay(@RequestBody String body, //
public LayoutView updateOverlay( //
@RequestBody String body, //
@PathVariable(value = "projectId") String projectId, //
@PathVariable(value = "overlayId") String overlayId //
) throws SecurityException, QueryException, IOException {
......@@ -119,15 +121,13 @@ public class OverlayController extends BaseController {
return overlayRestImp.updateOverlay((String) node.get("token"), projectId, overlayId, data);
}
@RequestMapping(value = "/overlay/getOverlayTypes", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
public List<Map<String, Object>> getOverlayTypes(@RequestParam(value = "token") String token) throws SecurityException, QueryException {
return overlayRestImp.getOverlayTypes(token);
}
@RequestMapping(value = "/overlay/getOverlaySource", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<byte[]> getOverlaySource(@RequestParam(value = "token") String token, @RequestParam(value = "projectId") String projectId,
@RequestParam(value = "overlayId") String overlayId) throws SecurityException, QueryException {
@RequestMapping(value = "/projects/{projectId}/overlays/{overlayId}:downloadSource", method = { RequestMethod.GET },
produces = { MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<byte[]> getOverlaySource( //
@RequestParam(value = "token") String token, //
@PathVariable(value = "projectId") String projectId, //
@PathVariable(value = "overlayId") String overlayId //
) throws SecurityException, QueryException, JsonParseException, JsonMappingException, IOException {
FileEntry file = overlayRestImp.getOverlaySource(token, projectId, overlayId);
MediaType type = MediaType.TEXT_PLAIN;
......@@ -139,6 +139,11 @@ public class OverlayController extends BaseController {
.body(file.getFileContent());
}
@RequestMapping(value = "/overlay/getOverlayTypes", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
public List<Map<String, Object>> getOverlayTypes(@RequestParam(value = "token") String token) throws SecurityException, QueryException {
return overlayRestImp.getOverlayTypes(token);
}
/**
* @return the overlayRestImp
* @see #overlayRestImp
......
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