Commit 0ed86847 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

types are serialized by jackson

parent 93508b07
......@@ -24,11 +24,11 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lcsb.mapviewer.api.BaseController;
import lcsb.mapviewer.api.SerializationUtils;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.cache.FileEntry;
import lcsb.mapviewer.model.overlay.DataOverlay;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.modelutils.serializer.model.map.ElementIdentifierType;
import lcsb.mapviewer.services.ObjectNotFoundException;
import lcsb.mapviewer.services.QueryException;
import lcsb.mapviewer.services.interfaces.IDataOverlayService;
......@@ -98,11 +98,12 @@ 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, SerializationUtils.parseInteger(overlayId, "overlayId"),
columns);
if (overlayId == null) {
throw new QueryException("Invalid overlayId");
}
return overlayRestImp.getOverlayElements(projectId, overlayId, columns);
}
@PreAuthorize("hasAuthority('IS_ADMIN')" +
......@@ -112,17 +113,17 @@ public class OverlayController extends BaseController {
@GetMapping(value = "/{overlayId}/models/{modelId}/bioEntities/reactions/{reactionId}/")
public List<Map<String, Object>> getFullReaction(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "modelId") String modelId,
@PathVariable(value = "modelId") Integer modelId,
@PathVariable(value = "overlayId") Integer overlayId,
@PathVariable(value = "reactionId") String reactionId,
@PathVariable(value = "reactionId") Integer reactionId,
@RequestParam(value = "columns", defaultValue = "") String columns)
throws QueryException, NumberFormatException, ObjectNotFoundException {
throws QueryException {
return overlayRestImp.getOverlayElement(projectId,
SerializationUtils.parseInteger(modelId, "modelId"),
SerializationUtils.parseInteger(overlayId, "overlayId"),
SerializationUtils.parseInteger(reactionId, "reactionId"),
"REACTION", columns);
modelId,
overlayId,
reactionId,
ElementIdentifierType.REACTION, columns);
}
@PreAuthorize("hasAuthority('IS_ADMIN')" +
......@@ -132,16 +133,16 @@ public class OverlayController extends BaseController {
@GetMapping(value = "/{overlayId}/models/{modelId}/bioEntities/elements/{elementId}/")
public List<Map<String, Object>> getFullSpecies(
@PathVariable(value = "projectId") String projectId,
@PathVariable(value = "modelId") String modelId,
@PathVariable(value = "modelId") Integer modelId,
@PathVariable(value = "overlayId") Integer overlayId,
@PathVariable(value = "elementId") String reactionId,
@PathVariable(value = "elementId") Integer elementId,
@RequestParam(value = "columns", defaultValue = "") String columns)
throws QueryException, NumberFormatException, ObjectNotFoundException {
throws QueryException {
return overlayRestImp.getOverlayElement(projectId,
SerializationUtils.parseInteger(modelId, "modelId"),
SerializationUtils.parseInteger(overlayId, "overlayId"),
SerializationUtils.parseInteger(reactionId, "reactionId"),
"ALIAS", columns);
modelId,
overlayId,
elementId,
ElementIdentifierType.ALIAS, columns);
}
@PreAuthorize("hasAuthority('IS_ADMIN')" +
......
......@@ -61,7 +61,7 @@ public class OverlayRestImpl extends BaseRestImpl {
this.dataOverlayService = dataOverlayService;
}
public List<Map<String, Object>> getOverlayElements(String projectId, int overlayId, String columns)
public List<Map<String, Object>> getOverlayElements(String projectId, Integer overlayId, String columns)
throws QueryException {
String[] columnSet;
......@@ -72,8 +72,7 @@ public class OverlayRestImpl extends BaseRestImpl {
}
List<Map<String, Object>> result = new ArrayList<>();
List<Pair<Element, DataOverlayEntry>> speciesList = dataOverlayService.getElementsForDataOverlay(projectId,
overlayId);
List<Pair<Element, DataOverlayEntry>> speciesList = dataOverlayService.getElementsForDataOverlay(projectId, overlayId);
for (Pair<Element, DataOverlayEntry> elementDataOverlay : speciesList) {
Map<String, Object> element = new TreeMap<>();
element.put("type", ElementIdentifierType.ALIAS);
......@@ -247,7 +246,7 @@ public class OverlayRestImpl extends BaseRestImpl {
}
public List<Map<String, Object>> getOverlayElement(String projectId, Integer modelId, Integer overlayId,
Integer elementId, String elementType, String columns) throws QueryException {
Integer elementId, ElementIdentifierType elementType, String columns) throws QueryException {
dataOverlayService.getDataOverlayById(projectId, overlayId);
String[] columnSet;
if (columns != null && !columns.trim().isEmpty()) {
......@@ -258,40 +257,44 @@ public class OverlayRestImpl extends BaseRestImpl {
"uniqueId" };
}
List<Map<String, Object>> result = new ArrayList<>();
if (ElementIdentifierType.ALIAS.getJsName().equals(elementType)) {
List<Pair<Element, DataOverlayEntry>> elementDataOverlay = dataOverlayService
.getFullElementForDataOverlay(
projectId,
modelId,
elementId,
overlayId);
if (elementDataOverlay.size() == 0) {
throw new ObjectNotFoundException("Element data cannot be found");
}
for (Pair<Element, DataOverlayEntry> pair : elementDataOverlay) {
Map<String, Object> entry = new HashMap<>();
entry.put("type", ElementIdentifierType.ALIAS);
entry.put("overlayContent", overlayContentToMap(pair, columnSet));
result.add(entry);
switch (elementType) {
case ALIAS: {
List<Pair<Element, DataOverlayEntry>> elementDataOverlay = dataOverlayService
.getFullElementForDataOverlay(
projectId,
modelId,
elementId,
overlayId);
if (elementDataOverlay.size() == 0) {
throw new ObjectNotFoundException("Element data cannot be found");
}
for (Pair<Element, DataOverlayEntry> pair : elementDataOverlay) {
Map<String, Object> entry = new HashMap<>();
entry.put("type", ElementIdentifierType.ALIAS);
entry.put("overlayContent", overlayContentToMap(pair, columnSet));
result.add(entry);
}
return result;
}
return result;
} else if (ElementIdentifierType.REACTION.getJsName().equals(elementType)) {
List<Pair<Reaction, DataOverlayEntry>> reactionDataOverlay = dataOverlayService
.getFullReactionForDataOverlay(projectId,
modelId,
elementId, overlayId);
if (reactionDataOverlay.size() == 0) {
throw new ObjectNotFoundException("Reaction data cannot be found");
case REACTION: {
List<Pair<Reaction, DataOverlayEntry>> reactionDataOverlay = dataOverlayService
.getFullReactionForDataOverlay(projectId,
modelId,
elementId, overlayId);
if (reactionDataOverlay.size() == 0) {
throw new ObjectNotFoundException("Reaction data cannot be found");
}
for (Pair<Reaction, DataOverlayEntry> pair : reactionDataOverlay) {
Map<String, Object> entry = new HashMap<>();
entry.put("type", ElementIdentifierType.REACTION);
entry.put("overlayContent", overlayContentToMap(pair, columnSet));
result.add(entry);
}
return result;
}
for (Pair<Reaction, DataOverlayEntry> pair : reactionDataOverlay) {
Map<String, Object> entry = new HashMap<>();
entry.put("type", ElementIdentifierType.REACTION);
entry.put("overlayContent", overlayContentToMap(pair, columnSet));
result.add(entry);
default: {
throw new QueryException("Unknown element type: " + elementType);
}
return result;
} else {
throw new QueryException("Unknown element type: " + elementType);
}
}
......
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