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
ffa9b004
Commit
ffa9b004
authored
Oct 15, 2018
by
Piotr Gawron
Browse files
gson upgraded
parent
b89495f3
Changes
5
Hide whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java
View file @
ffa9b004
...
...
@@ -14,7 +14,6 @@ import org.apache.log4j.Logger;
import
org.w3c.dom.Node
;
import
com.google.gson.Gson
;
import
com.google.gson.internal.StringMap
;
import
lcsb.mapviewer.annotation.cache.CachableInterface
;
import
lcsb.mapviewer.annotation.cache.GeneralCacheInterface
;
...
...
@@ -191,11 +190,11 @@ public class MeSHParser extends CachableInterface implements IExternalService {
* @return name of {@link MeSH} entry
*/
private
String
getName
(
Map
<?,
?>
gsonObject
)
{
String
Map
<?>
descriptorTag
=
(
String
Map
<?>)
gsonObject
.
get
(
"DescriptorName"
);
Map
<
?,
?>
descriptorTag
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"DescriptorName"
);
if
(
descriptorTag
==
null
)
{
descriptorTag
=
(
String
Map
<?>)
gsonObject
.
get
(
"SupplementalRecordName"
);
descriptorTag
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"SupplementalRecordName"
);
}
return
(
String
)
(((
String
Map
<?>)
descriptorTag
.
get
(
"String"
)).
get
(
"t"
));
return
(
String
)
(((
Map
<
?,
?>)
descriptorTag
.
get
(
"String"
)).
get
(
"t"
));
}
/**
...
...
@@ -206,9 +205,9 @@ public class MeSHParser extends CachableInterface implements IExternalService {
* @return id of {@link MeSH} entry
*/
private
String
getId
(
Map
<?,
?>
gsonObject
)
{
String
Map
<?>
descriptorTag
=
(
String
Map
<?>)
gsonObject
.
get
(
"DescriptorUI"
);
Map
<
?,
?>
descriptorTag
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"DescriptorUI"
);
if
(
descriptorTag
==
null
)
{
descriptorTag
=
(
String
Map
<?>)
gsonObject
.
get
(
"SupplementalRecordUI"
);
descriptorTag
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"SupplementalRecordUI"
);
}
return
(
String
)
descriptorTag
.
get
(
"t"
);
}
...
...
@@ -221,7 +220,7 @@ public class MeSHParser extends CachableInterface implements IExternalService {
* @return description of {@link MeSH} entry
*/
private
String
getDescription
(
Map
<?,
?>
gsonObject
)
{
String
Map
<?>
concepts
=
(
String
Map
<?>)
gsonObject
.
get
(
"_generated"
);
Map
<
?,
?>
concepts
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"_generated"
);
return
(
String
)
concepts
.
get
(
"PreferredConceptScopeNote"
);
}
...
...
@@ -234,14 +233,14 @@ public class MeSHParser extends CachableInterface implements IExternalService {
*/
private
Set
<
String
>
getSynonyms
(
Map
<?,
?>
gsonObject
)
{
Set
<
String
>
synonyms
=
new
HashSet
<>();
String
Map
<?>
concepts
=
(
String
Map
<?>)
gsonObject
.
get
(
"ConceptList"
);
Map
<
?,
?>
concepts
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"ConceptList"
);
ArrayList
<?>
conceptList
=
(
ArrayList
<?>)
concepts
.
get
(
"Concept"
);
for
(
Object
object
:
conceptList
)
{
String
Map
<?>
concept
=
(
String
Map
<?>)
object
;
ArrayList
<?>
termList
=
(
ArrayList
<?>)
((
String
Map
<?>)
concept
.
get
(
"TermList"
)).
get
(
"Term"
);
Map
<
?,
?>
concept
=
(
Map
<
?,
?>)
object
;
ArrayList
<?>
termList
=
(
ArrayList
<?>)
((
Map
<
?,
?>)
concept
.
get
(
"TermList"
)).
get
(
"Term"
);
for
(
Object
object2
:
termList
)
{
String
Map
<?>
term
=
(
String
Map
<?>)
object2
;
String
Map
<?>
synonym
=
(
String
Map
<?>)
term
.
get
(
"String"
);
Map
<
?,
?>
term
=
(
Map
<
?,
?>)
object2
;
Map
<
?,
?>
synonym
=
(
Map
<
?,
?>)
term
.
get
(
"String"
);
synonyms
.
add
((
String
)
synonym
.
get
(
"t"
));
}
...
...
@@ -317,11 +316,11 @@ public class MeSHParser extends CachableInterface implements IExternalService {
private
Set
<
MiriamData
>
getIdsBySynonymQuery
(
Map
<?,
?>
gsonObject
)
{
Set
<
MiriamData
>
result
=
new
HashSet
<>();
String
Map
<?>
hits
=
(
String
Map
<?>)
gsonObject
.
get
(
"hits"
);
Map
<
?,
?>
hits
=
(
Map
<
?,
?>)
gsonObject
.
get
(
"hits"
);
ArrayList
<?>
hitsList
=
(
ArrayList
<?>)
hits
.
get
(
"hits"
);
for
(
Object
object
:
hitsList
)
{
String
Map
<?>
hit
=
(
String
Map
<?>)
object
;
String
id
=
(
String
)
hit
.
get
(
"_id"
);
Map
<
?,
?>
hit
=
(
Map
<
?,
?>)
object
;
String
id
=
(
String
)
hit
.
get
(
"_id"
);
result
.
add
(
new
MiriamData
(
MiriamType
.
MESH_2012
,
id
));
}
return
result
;
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java
View file @
ffa9b004
...
...
@@ -9,7 +9,6 @@ import org.apache.log4j.Logger;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.google.gson.Gson
;
import
com.google.gson.internal.StringMap
;
import
lcsb.mapviewer.annotation.cache.GeneralCacheInterface
;
import
lcsb.mapviewer.annotation.cache.SourceNotAvailable
;
...
...
@@ -61,29 +60,29 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService {
*/
private
XmlSerializer
<
Go
>
goSerializer
;
@Override
public
String
refreshCacheQuery
(
Object
query
)
throws
SourceNotAvailable
{
String
result
=
null
;
try
{
if
(
query
instanceof
String
)
{
String
name
=
(
String
)
query
;
if
(
name
.
startsWith
(
GO_TERM_CACHE_PREFIX
))
{
String
term
=
name
.
substring
(
GO_TERM_CACHE_PREFIX
.
length
());
MiriamData
md
=
createMiriamData
(
MiriamRelationType
.
BQ_BIOL_IS_DESCRIBED_BY
,
MiriamType
.
GO
,
term
);
result
=
goSerializer
.
objectToString
(
getGoElement
(
md
));
}
else
if
(
name
.
startsWith
(
"http"
))
{
result
=
getWebPageContent
(
name
);
}
else
{
throw
new
InvalidArgumentException
(
"Don't know what to do with query: "
+
query
);
}
}
else
{
throw
new
InvalidArgumentException
(
"Don't know what to do with class: "
+
query
.
getClass
());
}
}
catch
(
IOException
|
GoSearchException
e
)
{
throw
new
SourceNotAvailable
(
e
);
}
return
result
;
}
@Override
public
String
refreshCacheQuery
(
Object
query
)
throws
SourceNotAvailable
{
String
result
=
null
;
try
{
if
(
query
instanceof
String
)
{
String
name
=
(
String
)
query
;
if
(
name
.
startsWith
(
GO_TERM_CACHE_PREFIX
))
{
String
term
=
name
.
substring
(
GO_TERM_CACHE_PREFIX
.
length
());
MiriamData
md
=
createMiriamData
(
MiriamRelationType
.
BQ_BIOL_IS_DESCRIBED_BY
,
MiriamType
.
GO
,
term
);
result
=
goSerializer
.
objectToString
(
getGoElement
(
md
));
}
else
if
(
name
.
startsWith
(
"http"
))
{
result
=
getWebPageContent
(
name
);
}
else
{
throw
new
InvalidArgumentException
(
"Don't know what to do with query: "
+
query
);
}
}
else
{
throw
new
InvalidArgumentException
(
"Don't know what to do with class: "
+
query
.
getClass
());
}
}
catch
(
IOException
|
GoSearchException
e
)
{
throw
new
SourceNotAvailable
(
e
);
}
return
result
;
}
/**
* Default constructor. Initializes structures used for transforming {@link Go}
...
...
@@ -150,11 +149,11 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService {
}
List
<?>
objects
=
(
List
<?>)
gsonObject
.
get
(
"results"
);
String
Map
<?>
object
=
(
String
Map
<?>)
objects
.
get
(
0
);
Map
<
?,
?>
object
=
(
Map
<
?,
?>)
objects
.
get
(
0
);
result
.
setGoTerm
((
String
)
object
.
get
(
"id"
));
result
.
setCommonName
((
String
)
object
.
get
(
"name"
));
String
Map
<?>
descr
=
(
String
Map
<?>)
object
.
get
(
"definition"
);
Map
<
?,
?>
descr
=
(
Map
<
?,
?>)
object
.
get
(
"definition"
);
if
(
descr
!=
null
)
{
result
.
setDescription
((
String
)
descr
.
get
(
"text"
));
}
...
...
@@ -174,7 +173,8 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService {
try
{
Compartment
compartment
=
new
Compartment
(
"some_id"
);
compartment
.
addMiriamData
(
createMiriamData
(
MiriamRelationType
.
BQ_BIOL_IS_DESCRIBED_BY
,
MiriamType
.
GO
,
"GO:0046902"
));
compartment
.
addMiriamData
(
createMiriamData
(
MiriamRelationType
.
BQ_BIOL_IS_DESCRIBED_BY
,
MiriamType
.
GO
,
"GO:0046902"
));
annotateElement
(
compartment
);
if
(
compartment
.
getFullName
()
==
null
||
compartment
.
getFullName
().
equals
(
""
))
{
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java
View file @
ffa9b004
...
...
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
lcsb.mapviewer.annotation.AnnotationTestFunctions
;
import
lcsb.mapviewer.annotation.cache.GeneralCacheInterface
;
import
lcsb.mapviewer.annotation.cache.PermanentDatabaseLevelCache
;
import
lcsb.mapviewer.annotation.cache.PermanentDatabaseLevelCacheInterface
;
import
lcsb.mapviewer.annotation.cache.SourceNotAvailable
;
import
lcsb.mapviewer.annotation.cache.WebPageDownloader
;
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotatorTest.java
View file @
ffa9b004
...
...
@@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
lcsb.mapviewer.annotation.AnnotationTestFunctions
;
import
lcsb.mapviewer.annotation.cache.GeneralCacheInterface
;
import
lcsb.mapviewer.annotation.cache.PermanentDatabaseLevelCache
;
import
lcsb.mapviewer.annotation.cache.PermanentDatabaseLevelCacheInterface
;
import
lcsb.mapviewer.annotation.cache.SourceNotAvailable
;
import
lcsb.mapviewer.annotation.cache.WebPageDownloader
;
...
...
pom.xml
View file @
ffa9b004
...
...
@@ -65,6 +65,9 @@
<cglib.version>
3.2.8
</cglib.version>
<gson.version>
2.8.5
</gson.version>
<primafaces.version>
4.0
</primafaces.version>
<primafaces.themes.version>
1.0.8
</primafaces.themes.version>
...
...
@@ -92,8 +95,6 @@
<jsbml.version>
1.4
</jsbml.version>
<gson.version>
2.2.2
</gson.version>
<chebi-ws.version>
2.3.2
</chebi-ws.version>
...
...
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