From 6dbb911d0147e511b9d51a0162b7b5af698a4881 Mon Sep 17 00:00:00 2001 From: David Hoksza <david.hoksza@uni.lu> Date: Tue, 23 Jan 2018 22:19:44 +0100 Subject: [PATCH] MiriamData description propagated to API --- .../services/annotators/ElementAnnotator.java | 4 ++-- .../java/lcsb/mapviewer/api/BaseRestImpl.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java index 26a8389a2f..763241dd96 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java @@ -162,7 +162,7 @@ public abstract class ElementAnnotator extends CachableInterface { * the description */ public String getDescription(MiriamType mt){ - return ""; + return getCommonName(); } /** @@ -176,7 +176,7 @@ public abstract class ElementAnnotator extends CachableInterface { * the description */ public String getDescription(MiriamType mt, MiriamRelationType relationType){ - return ""; + return getCommonName(); } /** diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java index caf4cbe87d..16b031af4c 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java @@ -31,6 +31,7 @@ import lcsb.mapviewer.annotation.data.Target; import lcsb.mapviewer.annotation.services.MiriamConnector; import lcsb.mapviewer.annotation.services.PubmedParser; import lcsb.mapviewer.annotation.services.PubmedSearchException; +import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; @@ -125,6 +126,22 @@ public abstract class BaseRestImpl { result.put("type", annotation.getDataType().name()); result.put("resource", annotation.getResource()); result.put("id", annotation.getId()); + + if (annotation.getAnnotator() != null) { + try { + result.put("description", + ((ElementAnnotator) annotation.getAnnotator().getConstructor().newInstance()).getDescription( + annotation.getDataType(), + annotation.getRelationType()) + ); + }catch(Exception e) { //TODO + logger.error("Problem with retrieving description from annotator", e); + result.put("description", ""); + } + } else { + result.put("description", ""); + } + return result; } else { throw new InvalidArgumentException("invalid miriam data: " + annotation); -- GitLab