Commit 6dbb911d authored by David Hoksza's avatar David Hoksza
Browse files

MiriamData description propagated to API

parent a5578611
......@@ -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();
}
/**
......
......@@ -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);
......
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