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

sometimes there are issues with pubmed annotations (they have whitespaces)

parent 13fa24eb
......@@ -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);
}
}
Supports Markdown
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