Skip to content
Snippets Groups Projects
Commit 1b678cd3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

new implementation for resolving miriam resources fixed

parent 1ea7b8df
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!386Resolve "Continous integration tests"
package lcsb.mapviewer.annotation.services; package lcsb.mapviewer.annotation.services;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.w3c.dom.Document;
import com.google.gson.Gson; import org.w3c.dom.Node;
import lcsb.mapviewer.annotation.cache.CachableInterface; import lcsb.mapviewer.annotation.cache.CachableInterface;
import lcsb.mapviewer.annotation.cache.GeneralCacheInterface; import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
...@@ -219,19 +216,13 @@ public final class MiriamConnector extends CachableInterface implements IExterna ...@@ -219,19 +216,13 @@ public final class MiriamConnector extends CachableInterface implements IExterna
*/ */
protected String getUrlString2(MiriamData md) throws AnnotationException { protected String getUrlString2(MiriamData md) throws AnnotationException {
try { try {
String result = null;
String queryUri = md.getDataType().getUris().get(0) + ":" + md.getResource(); String queryUri = md.getDataType().getUris().get(0) + ":" + md.getResource();
String query = "https://www.ebi.ac.uk/miriamws/main/rest/resolve/" + queryUri; String query = "https://www.ebi.ac.uk/miriamws/main/rest/resolve/" + queryUri;
String page = getWebPageContent(query); String page = getWebPageContent(query);
Gson gson = new Gson(); Document document = getXmlDocumentFromString(page);
Node uri = getNode("uri", document.getChildNodes());
Map<?, ?> gsonObject = new HashMap<String, Object>(); return getNodeValue(uri);
gsonObject = (Map<?, ?>) gson.fromJson(page, gsonObject.getClass());
Object uris = gsonObject.get("uri");
Map<?, ?> entry = (Map<?, ?>) ((List<?>) uris).get(0);
result = (String) entry.get("$");
return result;
} catch (Exception e) { } catch (Exception e) {
throw new AnnotationException("Problem with accessing miriam REST API", e); throw new AnnotationException("Problem with accessing miriam REST API", e);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment