Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
0a1b7b08
Commit
0a1b7b08
authored
Jan 28, 2019
by
Piotr Gawron
Browse files
sometimes there are issues with pubmed annotations (they have whitespaces)
parent
13fa24eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/services/PubmedParser.java
View file @
0a1b7b08
...
...
@@ -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).
...
...
rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java
View file @
0a1b7b08
...
...
@@ -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
;
}
}
rest-api/src/test/java/lcsb/mapviewer/api/BaseRestImplTest.java
View file @
0a1b7b08
...
...
@@ -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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment