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

Merge branch 'drug-issue' into 'devel_12.1.x'

Drug issue

See merge request minerva/core!602
parents 148531c7 c4d7bc22
......@@ -4,8 +4,11 @@ minerva (12.1.6) stable; urgency=medium
properly
* Bug fix: upload of data overlays without privileges triggers proper
error message also in situation when user cannot create projects
* Bug fix: first login on website when there is Term of use to accept
raised error for regular users
* Bug fix: fetching some drugs via API could cause 500
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 22 Jan 2019 14:00:00 +0200
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 28 Jan 2019 16:00:00 +0200
minerva (12.1.5) stable; urgency=medium
* Bug fix: Drugbank changed output format which crashed drug connector
......
......@@ -205,6 +205,13 @@ public class PubmedParser extends CachableInterface implements IExternalService
return result;
}
public Article getPubmedArticleById(String id) throws PubmedSearchException {
if (id==null) {
return null;
}
return getPubmedArticleById(Integer.valueOf(id.trim()));
}
/**
* This method return html \< a\ > tag with link for pubmed id (with some
* additional information).
......
......@@ -58,7 +58,7 @@ public abstract class BaseRestImpl {
/**
* Default class logger.
*/
private Logger logger = Logger.getLogger(BaseRestImpl.class);
private static Logger logger = Logger.getLogger(BaseRestImpl.class);
@Autowired
private IModelService modelService;
......@@ -118,7 +118,7 @@ public abstract class BaseRestImpl {
}
if (MiriamType.PUBMED.equals(annotation.getDataType())) {
try {
Article article = pubmedParser.getPubmedArticleById(Integer.valueOf(annotation.getResource()));
Article article = pubmedParser.getPubmedArticleById(annotation.getResource());
result.put("article", article);
} catch (PubmedSearchException e) {
logger.error("Problem with accessing info about pubmed", e);
......@@ -387,4 +387,20 @@ public abstract class BaseRestImpl {
this.configurationService = configurationService;
}
public MiriamConnector getMiriamConnector() {
return miriamConnector;
}
public void setMiriamConnector(MiriamConnector miriamConnector) {
this.miriamConnector = miriamConnector;
}
public PubmedParser getPubmedParser() {
return pubmedParser;
}
public void setPubmedParser(PubmedParser pubmedParser) {
this.pubmedParser = pubmedParser;
}
}
......@@ -6,12 +6,26 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import java.util.Map;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.services.MiriamConnector;
import lcsb.mapviewer.annotation.services.PubmedParser;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
public class BaseRestImplTest extends RestTestFunctions {
Logger logger = Logger.getLogger(BaseRestImplTest.class);
@Autowired
MiriamConnector mc;
@Autowired
PubmedParser pubmedParser;
@Test
public void testMathMLToPresentationML() throws Exception {
......@@ -39,6 +53,15 @@ public class BaseRestImplTest extends RestTestFunctions {
assertFalse(presentationXml.startsWith("<?xml"));
}
@Test
public void testCreateAnnotationWithWhitespace() throws Exception {
BaseRestImpl controller = Mockito.mock(BaseRestImpl.class, CALLS_REAL_METHODS);
controller.setMiriamConnector(mc);
controller.setPubmedParser(pubmedParser);
Map<String, Object> response = controller.createAnnotation(new MiriamData(MiriamType.PUBMED,"28255955 "));
assertNotNull(response);
}
}
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