Commit ffa9b004 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

gson upgraded

parent b89495f3
......@@ -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) {
StringMap<?> descriptorTag = (StringMap<?>) gsonObject.get("DescriptorName");
Map<?, ?> descriptorTag = (Map<?, ?>) gsonObject.get("DescriptorName");
if (descriptorTag == null) {
descriptorTag = (StringMap<?>) gsonObject.get("SupplementalRecordName");
descriptorTag = (Map<?, ?>) gsonObject.get("SupplementalRecordName");
}
return (String) (((StringMap<?>) 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) {
StringMap<?> descriptorTag = (StringMap<?>) gsonObject.get("DescriptorUI");
Map<?, ?> descriptorTag = (Map<?, ?>) gsonObject.get("DescriptorUI");
if (descriptorTag == null) {
descriptorTag = (StringMap<?>) 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) {
StringMap<?> concepts = (StringMap<?>) 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<>();
StringMap<?> concepts = (StringMap<?>) gsonObject.get("ConceptList");
Map<?, ?> concepts = (Map<?, ?>) gsonObject.get("ConceptList");
ArrayList<?> conceptList = (ArrayList<?>) concepts.get("Concept");
for (Object object : conceptList) {
StringMap<?> concept = (StringMap<?>) object;
ArrayList<?> termList = (ArrayList<?>) ((StringMap<?>) concept.get("TermList")).get("Term");
Map<?, ?> concept = (Map<?, ?>) object;
ArrayList<?> termList = (ArrayList<?>) ((Map<?, ?>) concept.get("TermList")).get("Term");
for (Object object2 : termList) {
StringMap<?> term = (StringMap<?>) object2;
StringMap<?> synonym = (StringMap<?>) 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<>();
StringMap<?> hits = (StringMap<?>) gsonObject.get("hits");
Map<?, ?> hits = (Map<?, ?>) gsonObject.get("hits");
ArrayList<?> hitsList = (ArrayList<?>) hits.get("hits");
for (Object object : hitsList) {
StringMap<?> hit = (StringMap<?>) 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;
......
......@@ -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");
StringMap<?> object = (StringMap<?>) objects.get(0);
Map<?, ?> object = (Map<?, ?>) objects.get(0);
result.setGoTerm((String) object.get("id"));
result.setCommonName((String) object.get("name"));
StringMap<?> descr = (StringMap<?>) 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("")) {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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>
......
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