Commit 5e1475d2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

overlayId is numeric

parent 97cccedb
Pipeline #12085 failed with stage
in 10 minutes and 43 seconds
......@@ -53,7 +53,7 @@ public class OverlayController extends BaseController {
@GetMapping(value = "/{overlayId}/")
public Map<String, Object> getOverlayById(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "overlayId") String overlayId) throws QueryException {
@PathVariable(value = "overlayId") Integer overlayId) throws QueryException {
return overlayRestImp.getOverlayById(projectId, overlayId);
}
......@@ -64,7 +64,7 @@ public class OverlayController extends BaseController {
@GetMapping(value = "/{overlayId}/models/{modelId}/bioEntities/")
public List<Map<String, Object>> getOverlayElements(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "overlayId") String overlayId,
@PathVariable(value = "overlayId") Integer overlayId,
@RequestParam(value = "columns", defaultValue = "") String columns) throws QueryException {
return overlayRestImp.getOverlayElements(projectId, Integer.valueOf(overlayId), columns);
}
......@@ -77,7 +77,7 @@ public class OverlayController extends BaseController {
public Map<String, Object> getFullReaction(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "modelId") String modelId,
@PathVariable(value = "overlayId") String overlayId,
@PathVariable(value = "overlayId") Integer overlayId,
@PathVariable(value = "reactionId") String reactionId,
@RequestParam(value = "columns", defaultValue = "") String columns)
throws QueryException, NumberFormatException, ObjectNotFoundException {
......@@ -93,7 +93,7 @@ public class OverlayController extends BaseController {
public Map<String, Object> getFullSpecies(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "modelId") String modelId,
@PathVariable(value = "overlayId") String overlayId,
@PathVariable(value = "overlayId") Integer overlayId,
@PathVariable(value = "elementId") String reactionId,
@RequestParam(value = "columns", defaultValue = "") String columns)
throws QueryException, NumberFormatException, ObjectNotFoundException {
......@@ -126,7 +126,7 @@ public class OverlayController extends BaseController {
@DeleteMapping(value = "/{overlayId}")
public Map<String, Object> removeOverlay(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "overlayId") String overlayId) throws QueryException, IOException {
@PathVariable(value = "overlayId") Integer overlayId) throws QueryException, IOException {
return overlayRestImp.removeOverlay(projectId, overlayId);
}
......@@ -136,7 +136,7 @@ public class OverlayController extends BaseController {
@PatchMapping(value = "/{overlayId}")
public Map<String, Object> updateOverlay(
@RequestBody String body,
@PathVariable(value = "overlayId") String overlayId,
@PathVariable(value = "overlayId") Integer overlayId,
@PathVariable(value = "projectId") String projectId)
throws QueryException, IOException {
Map<String, Object> node = parseBody(body);
......@@ -151,7 +151,7 @@ public class OverlayController extends BaseController {
@GetMapping(value = "/{overlayId}:downloadSource")
public ResponseEntity<byte[]> getOverlaySource(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "overlayId") String overlayId)
@PathVariable(value = "overlayId") Integer overlayId)
throws QueryException {
FileEntry file = overlayRestImp.getOverlaySource(projectId, overlayId);
......
......@@ -147,28 +147,27 @@ public class OverlayRestImpl extends BaseRestImpl {
return result;
}
public Map<String, Object> getOverlayById(String projectId, String overlayId)
public Map<String, Object> getOverlayById(String projectId, Integer overlayId)
throws QueryException {
Model model = getModelService().getLastModelByProjectId(projectId);
if (model == null) {
throw new QueryException("Project with given id doesn't exist");
}
Layout overlay = layoutService.getLayoutById(Integer.valueOf(overlayId));
Layout overlay = layoutService.getLayoutById(overlayId);
if (overlay == null) {
throw new QueryException("Overlay with given id doesn't exist");
}
return overlayToMap(overlay);
}
public FileEntry getOverlaySource(String projectId, String overlayId)
public FileEntry getOverlaySource(String projectId, Integer overlayId)
throws QueryException {
Model model = getModelService().getLastModelByProjectId(projectId);
if (model == null) {
throw new QueryException("Project with given id doesn't exist");
}
try {
int id = Integer.parseInt(overlayId);
Layout layout = layoutService.getLayoutById(id);
Layout layout = layoutService.getLayoutById(overlayId);
if (layout == null) {
throw new QueryException("Invalid overlay id");
}
......@@ -180,13 +179,12 @@ public class OverlayRestImpl extends BaseRestImpl {
}
}
public Map<String, Object> updateOverlay(String overlayId, Map<String, Object> overlayData) throws QueryException {
public Map<String, Object> updateOverlay(Integer overlayId, Map<String, Object> overlayData) throws QueryException {
if (overlayData == null) {
throw new QueryException("overlay field cannot be undefined");
}
try {
int id = Integer.parseInt(overlayId);
Layout layout = layoutService.getLayoutById(id);
Layout layout = layoutService.getLayoutById(overlayId);
if (layout == null) {
throw new ObjectNotFoundException("overlay doesn't exist");
}
......@@ -232,15 +230,14 @@ public class OverlayRestImpl extends BaseRestImpl {
}
}
public Map<String, Object> removeOverlay(String projectId, String overlayId)
public Map<String, Object> removeOverlay(String projectId, Integer overlayId)
throws QueryException, IOException {
Project project = getProjectService().getProjectByProjectId(projectId);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
try {
int id = Integer.parseInt(overlayId);
Layout layout = layoutService.getLayoutById(id);
Layout layout = layoutService.getLayoutById(overlayId);
if (layout == null) {
throw new ObjectNotFoundException("Overlay doesn't exist");
}
......@@ -321,7 +318,7 @@ public class OverlayRestImpl extends BaseRestImpl {
layout.setOrderIndex(count);
layoutService.updateLayout(layout);
return getOverlayById(projectId, layout.getId() + "");
return getOverlayById(projectId, layout.getId());
} catch (InvalidColorSchemaException e) {
throw new QueryException(e.getMessage(), e);
}
......
......@@ -66,7 +66,7 @@ public class OverlayRestImplTest extends RestTestFunctions {
Map<String, Object> result = overlayRest.addOverlay(projectId, "x", "desc", "s1", null, null,
ColorSchemaType.GENERIC.name(), "true", null);
String id = result.get("idObject").toString();
Integer id = Integer.valueOf(result.get("idObject").toString());
Map<String, Object> data = new HashMap<>();
data.put("name", "xyz");
result = overlayRest.updateOverlay(id, data);
......@@ -84,7 +84,7 @@ public class OverlayRestImplTest extends RestTestFunctions {
Map<String, Object> result = overlayRest.addOverlay(projectId, "x", "desc", "s1", null, null,
ColorSchemaType.GENERIC.name(), "true", null);
String id = result.get("idObject").toString();
Integer id = Integer.valueOf(result.get("idObject").toString());
Map<String, Object> data = new HashMap<>();
data.put("name", "");
result = overlayRest.updateOverlay(id, data);
......
......@@ -469,7 +469,7 @@ public class LayoutService implements ILayoutService {
}
@Override
public Layout getLayoutById(int overlayId) {
public Layout getLayoutById(Integer overlayId) {
return layoutDao.getById(overlayId);
}
......
......@@ -142,7 +142,7 @@ public interface ILayoutService {
*/
List<Layout> getLayoutsByProject(Project project);
Layout getLayoutById(int overlayId);
Layout getLayoutById(Integer overlayId);
void setLayoutDao(LayoutDao layoutDao);
......
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