From ad9c2a5cb5d5c4f310d4618ff91b0f9bfd8a69eb Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 8 Feb 2018 13:05:45 +0100 Subject: [PATCH] configuration returns information about unit types --- .../mapviewer/model/map/kinetics/SbmlUnitType.java | 6 +++++- .../api/configuration/ConfigurationController.java | 2 +- .../api/configuration/ConfigurationRestImpl.java | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/model/src/main/java/lcsb/mapviewer/model/map/kinetics/SbmlUnitType.java b/model/src/main/java/lcsb/mapviewer/model/map/kinetics/SbmlUnitType.java index 9cee1416c9..f25f03401c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/kinetics/SbmlUnitType.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/kinetics/SbmlUnitType.java @@ -32,5 +32,9 @@ public enum SbmlUnitType { TESLA, VOLT, WATT, - WEBER, + WEBER,; + + public String getCommonName() { + return this.name().toLowerCase(); + } } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationController.java b/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationController.java index 7c3fb78b35..b036c514cb 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationController.java @@ -9,7 +9,6 @@ import javax.servlet.ServletContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; -import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -53,6 +52,7 @@ public class ConfigurationController extends BaseController { result.put("reactionTypes", configurationController.getReactionTypes(token)); result.put("miriamTypes", configurationController.getMiriamTypes(token)); result.put("mapTypes", configurationController.getMapTypes(token)); + result.put("unitTypes", configurationController.getUnitTypes(token)); result.put("modificationStateTypes", configurationController.getModificationStateTypes(token)); result.put("privilegeTypes", configurationController.getPrivilegeTypes(token)); result.put("version", configurationService.getSystemSvnVersion(context.getRealPath("/"))); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java index 7c41b7d650..30d3f17139 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java @@ -22,6 +22,7 @@ import lcsb.mapviewer.converter.IConverter; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator; import lcsb.mapviewer.converter.graphics.ImageGenerators; import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.kinetics.SbmlUnitType; import lcsb.mapviewer.model.map.model.SubmodelType; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Element; @@ -291,4 +292,15 @@ public class ConfigurationRestImpl extends BaseRestImpl { return result; } + public List<Map<String, Object>> getUnitTypes(String token) { + List<Map<String, Object>> result = new ArrayList<>(); + for (SbmlUnitType type : SbmlUnitType.values()) { + Map<String, Object> row = new HashMap<>(); + row.put("id", type.name()); + row.put("name", type.getCommonName()); + result.add(row); + } + return result; + } + } -- GitLab