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

synonyms are escaped html strings

parent d9cc78db
package lcsb.mapviewer.annotation.services.annotators;
import java.io.IOException;
import java.io.StringReader;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.Collections;
......@@ -9,15 +8,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
import lcsb.mapviewer.annotation.cache.SourceNotAvailable;
......@@ -300,7 +295,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equals("Gene-ref_syn_E")) {
synonyms.add(node.getTextContent());
synonyms.add(StringEscapeUtils.unescapeHtml4(node.getTextContent()));
}
}
}
......
......@@ -343,6 +343,23 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
}
}
@Test
public void testAnnotateElementWithEncodedSynonyms() throws Exception {
try {
Species proteinAlias = new GenericProtein("id");
proteinAlias.addMiriamData(new MiriamData(MiriamType.ENTREZ, "834106"));
entrezAnnotator.annotateElement(proteinAlias);
for (String synonym : proteinAlias.getSynonyms()) {
assertFalse("Invalid character found in synonym: " + synonym, synonym.contains("&"));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testParseEntrezResponse() throws Exception {
WebPageDownloader downloader = entrezAnnotator.getWebPageDownloader();
......
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