From 62d0566867e0f5435970f5272043b44778302eb4 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 16 May 2019 17:12:36 +0200
Subject: [PATCH] Biocompendium annotator removed

---
 CHANGELOG                                     |   4 +
 .../annotators/BiocompendiumAnnotator.java    | 389 ------------------
 .../annotators/AllAnnotatorTests.java         |   1 -
 .../BiocompendiumAnnotatorTest.java           | 363 ----------------
 .../annotators/MultipleAnnotatorsTest.java    |   3 -
 ...V14.0.0.20190515__remove_biocompendium.sql |   2 +
 .../impl/ExternalServicesService.java         | 187 ---------
 .../services/ServiceTestFunctions.java        |   9 +-
 8 files changed, 8 insertions(+), 950 deletions(-)
 delete mode 100644 annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java
 delete mode 100644 annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotatorTest.java
 create mode 100644 persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190515__remove_biocompendium.sql
 delete mode 100644 service/src/main/java/lcsb/mapviewer/services/impl/ExternalServicesService.java

diff --git a/CHANGELOG b/CHANGELOG
index f758efea90..a70f238e18 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+minerva (14.0.0~alpha.0) unstable; urgency=low
+  * Feature: log4j is replaced with log4j2 logging mechanism (#291)
+  * Feature removal: BioCompendium annotator removed (#32)
+
 minerva (13.1.0~alpha.0) unstable; urgency=low
   * Feature: annotators are more flexible - you can define set of input and
     outputs used by annotator (#617)
diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java
deleted file mode 100644
index 1d84a47976..0000000000
--- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java
+++ /dev/null
@@ -1,389 +0,0 @@
-package lcsb.mapviewer.annotation.services.annotators;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-
-import lcsb.mapviewer.common.XmlParser;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.logging.log4j.*;
-import org.springframework.stereotype.Service;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
-import lcsb.mapviewer.annotation.cache.SourceNotAvailable;
-import lcsb.mapviewer.annotation.services.ExternalServiceStatus;
-import lcsb.mapviewer.annotation.services.ExternalServiceStatusType;
-import lcsb.mapviewer.annotation.services.IExternalService;
-import lcsb.mapviewer.common.exception.InvalidArgumentException;
-import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
-import lcsb.mapviewer.converter.model.celldesigner.annotation.NoteField;
-import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
-import lcsb.mapviewer.model.map.MiriamData;
-import lcsb.mapviewer.model.map.MiriamType;
-import lcsb.mapviewer.model.map.species.Gene;
-import lcsb.mapviewer.model.map.species.Protein;
-import lcsb.mapviewer.model.map.species.Rna;
-import lcsb.mapviewer.model.user.annotator.AnnotatorData;
-import lcsb.mapviewer.model.user.annotator.AnnotatorInputParameter;
-import lcsb.mapviewer.model.user.annotator.AnnotatorOutputParameter;
-import lcsb.mapviewer.model.user.annotator.BioEntityField;
-
-/**
- * This class is responsible for connection to Vencata annotation service. The
- * service is available on
- * http://biocompendium.embl.de/map_annotator/REST/GetAnnotation/. This service
- * is RESTful service. To query for an annotation one need to send a POST
- * message with two parameters:<br>
- * Method - this parameter should be set to GetAnnotation <br>
- * File - this parameter should bo connected to a file with a request<br>
- * 
- * Request file should looks like the one in testFiles/sampleRequest.xml.<br>
- * As a result the xml file is received. An example of a xml response is in
- * testFiles/sampleResponse.xml
- * 
- * 
- * @author Piotr Gawron
- * 
- */
-@Service
-public class BiocompendiumAnnotator extends ElementAnnotator implements IExternalService {
-
-  /**
-   * Address of the restfull API for biocompendium.
-   */
-  private static final String SERVICE_ADDRESS = "http://biocompendium.embl.de/map_annotator/REST/GetAnnotation/";
-
-  /**
-   * Standard class logger.
-   */
-  private final Logger logger = LogManager.getLogger(BiocompendiumAnnotator.class);
-
-  /**
-   * Xml parser used for processing notes into structured data.
-   */
-  private RestAnnotationParser rap = new RestAnnotationParser();
-
-  /**
-   * Default constructor.
-   */
-  public BiocompendiumAnnotator() {
-    super(BiocompendiumAnnotator.class, new Class[] { Protein.class, Gene.class, Rna.class }, true);
-  }
-
-  @Override
-  public String refreshCacheQuery(Object query) throws SourceNotAvailable {
-    String result = null;
-    try {
-      if (query instanceof String) {
-        String name = (String) query;
-        result = getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, name));
-      } else {
-        throw new InvalidArgumentException("Don't know what to do with class: " + query.getClass());
-      }
-    } catch (IOException e) {
-      throw new SourceNotAvailable(e);
-    }
-    return result;
-  }
-
-  /**
-   * Returns String with annotations for species described by {@link MiriamData}
-   * with {@link MiriamType#HGNC_SYMBOL} entry.
-   *
-   * @param md
-   *          description of the element by {@link MiriamData} with
-   *          {@link MiriamType#HGNC_SYMBOL} entry
-   * @return annotation for species with given name and type from Venkata server
-   * @throws IOException
-   *           thrown when there is a problem with connection to the server
-   */
-  protected String getAnnotation(MiriamData md) throws IOException {
-    if (!MiriamType.HGNC_SYMBOL.equals(md.getDataType())) {
-      throw new InvalidArgumentException(
-          "Only " + MiriamType.HGNC_SYMBOL.getCommonName() + " miriam registry is supported.");
-    }
-
-    MiriamData miriamData = new MiriamData(md);
-    miriamData.setResource(miriamData.getResource().replaceAll("[\n\r]+", " "));
-
-    String annotation = getCacheValue(miriamData.getResource());
-    if (annotation != null) {
-      return annotation;
-    }
-
-    CloseableHttpClient httpClient = HttpClients.createDefault();
-
-    HttpPost httppost = new HttpPost(SERVICE_ADDRESS);
-    MultipartEntityBuilder builder = MultipartEntityBuilder.create();
-
-    // prepare a query
-    String requestXml = dataToString(miriamData);
-
-    // save query to a temporary file
-    File tmp = File.createTempFile("annotation-plugin", "xml");
-    BufferedWriter out = new BufferedWriter(new FileWriter(tmp));
-    out.write(requestXml);
-    out.close();
-
-    builder.addBinaryBody("File", tmp, ContentType.APPLICATION_OCTET_STREAM, tmp.getName());
-    HttpEntity multipart = builder.build();
-    httppost.setEntity(multipart);
-    CloseableHttpResponse response = httpClient.execute(httppost);
-
-    HttpEntity entity2 = response.getEntity();
-    if (entity2 != null) {
-      InputStream instream = entity2.getContent();
-      Scanner scanner = new Scanner(instream);
-      try {
-        Scanner s = scanner.useDelimiter("\\A");
-        // get results
-        String responseXml = "";
-        if (s.hasNext()) {
-          responseXml = s.next();
-        }
-        try {
-          annotation = getAnnotationsFromXml(responseXml).get(miriamData.getResource());
-        } catch (InvalidXmlSchemaException e) {
-          throw new IOException(e);
-        }
-
-      } finally {
-        scanner.close();
-        instream.close();
-      }
-    }
-    if (annotation != null) {
-      setCacheValue(miriamData.getResource(), annotation);
-    }
-    return annotation;
-  }
-
-  /**
-   * This method convert a hgnc symbol in miriam data into xml request.
-   *
-   * @param miriamData
-   *          - {@link MiriamData} with {@link MiriamType#HGNC_SYMBOL}
-   * @return xml string that represent a request to RESTful service
-   */
-  String dataToString(MiriamData miriamData) {
-    if (!MiriamType.HGNC_SYMBOL.equals(miriamData.getDataType())) {
-      throw new InvalidArgumentException(
-          "Only " + MiriamType.HGNC_SYMBOL.getCommonName() + " miriam registry is supported.");
-    }
-    String requestXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-    requestXml += "<request>\n";
-    requestXml += "  <species name=\"" + miriamData.getResource() + "\" type=\"PROTEIN\"/>\n";
-    requestXml += "</request>\n";
-    return requestXml;
-  }
-
-  /**
-   * This method parse a response xml from annotation service into a map. A key in
-   * the map is a name of species and value is a annotation received from the
-   * service.
-   *
-   * @param xml
-   *          - xml string to be parsed
-   * @return a map with information about annotations. A key in the map is a name
-   *         of species and value is a annotation received from the service.
-   * @throws InvalidXmlSchemaException
-   *           thrown when there is a problem with xml
-   */
-  Map<String, String> getAnnotationsFromXml(String xml) throws InvalidXmlSchemaException {
-    Map<String, String> result = new HashMap<String, String>();
-    // if xml is null or empty string then return empty map
-    if (xml == null) {
-      return result;
-    }
-    if (xml.isEmpty()) {
-      return result;
-    }
-    // there is a bug in annotation service that create incorrect xml, therefore
-    // we need to alter the xml
-    xml = correctInvalidXml(xml);
-
-		Document doc = XmlParser.getXmlDocumentFromString(xml);
-		result = getAnnotationsFromXmlNode(doc);
-		return result;
-
-  }
-
-	/**
-	 * Transforms xml retrieved from Venkata server into map of annotations. A key
-	 * in the map is a name of species and value is a annotation received from the
-	 * service.
-	 * 
-	 * @param doc
-	 *          - xml node
-	 * @return a map with information about annotations. A key in the map is a
-	 *         name of species and value is a annotation received from the
-	 *         service.
-	 */
-	private Map<String, String> getAnnotationsFromXmlNode(Node doc) {
-		Map<String, String> result = new HashMap<String, String>();
-		NodeList root = doc.getChildNodes();
-		Node responseNode = XmlParser.getNode("response", root);
-		// root node is called "response"
-		if (responseNode == null) {
-			throw new InvalidArgumentException("Invalid xml returned by annotation service. No response root node");
-		}
-		NodeList list = responseNode.getChildNodes();
-		for (int i = 0; i < list.getLength(); i++) {
-			Node node = list.item(i);
-			// all nodes in response are species
-			if (node.getNodeType() == Node.ELEMENT_NODE) {
-				if (node.getNodeName().equalsIgnoreCase("species")) {
-					String name = XmlParser.getNodeAttr("name", node).replaceAll("%0A", "\n");
-					String annotation = XmlParser.getNodeValue(node);
-					if (annotation.contains("Symbol: " + name.split(" ")[0].toUpperCase())) {
-						result.put(name, annotation);
-					} else {
-						logger.warn("Problem with annotation for: " + name);
-						result.put(name, "");
-					}
-				} else {
-					throw new InvalidArgumentException("Unknown node in xml response: " + node.getNodeName());
-				}
-			}
-		}
-		return result;
-	}
-
-  /**
-   * Corrects invalid xml retrieved from Venkata server.
-   *
-   * @param xml
-   *          xml to correct
-   * @return corrected xml
-   */
-  private String correctInvalidXml(String xml) {
-    int size = 0;
-    int size2 = 0;
-    do {
-      size = xml.length();
-      xml = xml.replaceAll("<species name=\"[^\"]*\" type=\"[^\"]*\">(\\s)*<species", "<species");
-      xml = xml.replaceAll("<species name=\"[^\"]*\" type=\"[^\"]*\">(\\s)*</response", "</response");
-      size2 = xml.length();
-    } while (size != size2);
-    return xml;
-  }
-
-  @Override
-  public ExternalServiceStatus getServiceStatus() {
-    ExternalServiceStatus status = new ExternalServiceStatus(getCommonName(), getUrl());
-
-    GeneralCacheInterface cacheCopy = getCache();
-    this.setCache(null);
-
-    try {
-      String annotations = getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"));
-
-      status.setStatus(ExternalServiceStatusType.OK);
-      if (annotations == null) {
-        status.setStatus(ExternalServiceStatusType.DOWN);
-      } else if (!annotations.contains("ymbol")) {
-        status.setStatus(ExternalServiceStatusType.CHANGED);
-      }
-    } catch (Exception e) {
-      logger.error(status.getName() + " is down", e);
-      status.setStatus(ExternalServiceStatusType.DOWN);
-    }
-    this.setCache(cacheCopy);
-    return status;
-  }
-
-  @Override
-  public boolean annotateElement(BioEntityProxy element, MiriamData identifier, AnnotatorData parameters)
-      throws AnnotatorException {
-    try {
-      String annotationString = getAnnotation(identifier);
-      if (annotationString != null) {
-        element.addMiriamData(rap.getMiriamData(annotationString));
-
-        String annotations = "";
-
-        String[] string = annotationString.split("\n");
-        boolean remove = false;
-        for (String string2 : string) {
-          if (string2.startsWith("Symbol:")) {
-            remove = true;
-          }
-          if (remove) {
-            annotations += string2 + "\n";
-          }
-          if (string2.startsWith("Synonyms:")) {
-            remove = false;
-          }
-        }
-        element.setDescription(rap.getDescription(annotations));
-        element.setSymbol(rap.getSymbol(annotations));
-        element.setSynonyms(rap.getSynonyms(annotations));
-        element.setAbbreviation(rap.getAbbreviation(annotations));
-        element.setFormula(rap.getFormula(annotations));
-        element.setFullName(rap.getFullName(annotations));
-        element.setFormerSymbols(rap.getFormerSymbols(annotations));
-
-        return true;
-      }
-      return false;
-
-    } catch (IOException e) {
-      throw new AnnotatorException(e);
-    }
-
-  }
-
-  @Override
-  public String getCommonName() {
-    return "Biocompendium";
-  }
-
-  @Override
-  public String getUrl() {
-    return "http://biocompendium.embl.de/";
-  }
-
-  @Override
-  public List<AnnotatorInputParameter> getAvailableInputParameters() {
-    return Arrays.asList(new AnnotatorInputParameter(BioEntityField.NAME, MiriamType.HGNC_SYMBOL));
-  }
-
-  @Override
-  public List<AnnotatorOutputParameter> getAvailableOuputProperties() {
-    List<AnnotatorOutputParameter> result = new ArrayList<>();
-    for (NoteField field : NoteField.values()) {
-      if (field.getMiriamType() != null) {
-        result.add(new AnnotatorOutputParameter(field.getMiriamType()));
-      }
-    }
-    result.add(new AnnotatorOutputParameter(BioEntityField.SYMBOL));
-    result.add(new AnnotatorOutputParameter(BioEntityField.DESCRIPTION));
-    result.add(new AnnotatorOutputParameter(BioEntityField.PREVIOUS_SYMBOLS));
-    result.add(new AnnotatorOutputParameter(BioEntityField.SYNONYMS));
-
-    return result;
-  }
-
-  @Override
-  public MiriamData getExampleValidAnnotation() {
-    //we don't provide example because this annotator is unstable
-    return null;
-  }
-}
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AllAnnotatorTests.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AllAnnotatorTests.java
index e68e714fdb..5c3ae3a0b5 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AllAnnotatorTests.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AllAnnotatorTests.java
@@ -8,7 +8,6 @@ import org.junit.runners.Suite.SuiteClasses;
 @SuiteClasses({ AnnotatorExceptionTest.class,
     AnnotatorExceptionTest.class,
     BrendaAnnotatorTest.class,
-    BiocompendiumAnnotatorTest.class,
     CazyAnnotatorTest.class,
     ChebiAnnotatorTest.class,
     ElementAnnotatorTest.class,
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotatorTest.java
deleted file mode 100644
index 490032e67e..0000000000
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotatorTest.java
+++ /dev/null
@@ -1,363 +0,0 @@
-package lcsb.mapviewer.annotation.services.annotators;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.apache.logging.log4j.*;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import lcsb.mapviewer.annotation.AnnotationTestFunctions;
-import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
-import lcsb.mapviewer.annotation.cache.PermanentDatabaseLevelCacheInterface;
-import lcsb.mapviewer.annotation.cache.SourceNotAvailable;
-import lcsb.mapviewer.common.exception.InvalidArgumentException;
-import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
-import lcsb.mapviewer.model.map.MiriamData;
-import lcsb.mapviewer.model.map.MiriamType;
-
-public class BiocompendiumAnnotatorTest extends AnnotationTestFunctions {
-  Logger logger = LogManager.getLogger(BiocompendiumAnnotatorTest.class);
-
-  MiriamData camk4 = new MiriamData(MiriamType.HGNC_SYMBOL, "CAMK4");
-  MiriamData slc25a27 = new MiriamData(MiriamType.HGNC_SYMBOL, "SLC25A27");
-  MiriamData nsmf = new MiriamData(MiriamType.HGNC_SYMBOL, "NSMF");
-  MiriamData mir449a = new MiriamData(MiriamType.HGNC_SYMBOL, "MIR449A");
-
-  @Autowired
-  private GeneralCacheInterface cache;
-
-  @Autowired
-  private PermanentDatabaseLevelCacheInterface permanentDatabaseLevelCache;
-
-  @Autowired
-  private BiocompendiumAnnotator restService;
-
-  @Before
-  public void setUp() {
-  }
-
-  @After
-  public void tearDown() throws Exception {
-  }
-
-  @Test
-  @Ignore("Bug 32")
-  public void testGetAnnotationsForSpecies() throws Exception {
-    try {
-      String response = restService.getAnnotation(camk4);
-      assertNotNull(response);
-      assertTrue(response.contains("Symbol: CAMK4"));
-
-      response = restService.getAnnotation(slc25a27);
-      assertNotNull(response);
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testGetters() throws Exception {
-    try {
-      assertNotNull(restService.getCommonName());
-      assertNotNull(restService.getUrl());
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testGetAnnotationsForInvalidMiriam() throws Exception {
-    try {
-      restService.getAnnotation(new MiriamData());
-      fail("Exception expected");
-
-    } catch (InvalidArgumentException e) {
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testParseXml() throws Exception {
-    BufferedReader reader;
-    try {
-      reader = new BufferedReader(new FileReader("testFiles/annotation/sampleResponse.xml"));
-      String line = null;
-      StringBuilder stringBuilder = new StringBuilder();
-      String ls = System.getProperty("line.separator");
-
-      while ((line = reader.readLine()) != null) {
-        stringBuilder.append(line);
-        stringBuilder.append(ls);
-      }
-      reader.close();
-
-      Map<String, String> res = restService.getAnnotationsFromXml(stringBuilder.toString());
-
-      assertEquals(2, res.keySet().size());
-      String response = res.get("CAMK4");
-      assertNotNull(response);
-      assertTrue(response.contains("Symbol: CAMK4"));
-
-      assertNotNull(res.get("SLC25A27"));
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test(timeout = 10000)
-  @Ignore("Bug 32")
-  public void testGetAnnotationsForMiceSpecies() throws Exception {
-    ArrayList<String> names = new ArrayList<String>();
-
-    names.add("Fmo3");
-    names.add("Nqo1");
-    names.add("Abcc12");
-    names.add("Mgst3");
-    names.add("Txnrd1");
-    names.add("Cbr3");
-    names.add("Hspa1b");
-    names.add("Prdx1");
-    names.add("Ppard");
-    names.add("Tgfb2");
-    names.add("Fth1");
-    names.add("Prdx6");
-    names.add("Nr4a1");
-    names.add("Tgfb1");
-    names.add("Abcc4");
-    names.add("Ager");
-    names.add("Gsr");
-    names.add("Sod3");
-    names.add("Maff");
-    names.add("Eif2ak3");
-    names.add("Tgfa");
-    names.add("Hbegf");
-    names.add("Mafg");
-    names.add("Adh7");
-    names.add("Slc7a11");
-    names.add("Epha3");
-    names.add("Blvrb");
-    // problematic one
-    // names.add("Me1");
-    names.add("Csnk2a2");
-    names.add("Gpx3");
-    names.add("Mapk8");
-    names.add("Gclm");
-    names.add("Epha2");
-    names.add("Bdnf");
-    // problematic one
-    // names.add("ACC2");
-    names.add("Ptgr1");
-    names.add("Pdgfb");
-    names.add("Mapk7");
-    names.add("Cbr1");
-    names.add("Hsp90aa1");
-    names.add("Pgd");
-    names.add("Sqstm1");
-    names.add("Aldh9a1");
-    names.add("Txn");
-    names.add("Txnrd3");
-    names.add("Srxn1");
-    names.add("Gpx2");
-    names.add("Npas4");
-    names.add("Mapk1");
-    names.add("Nrg1");
-    names.add("Cbr");
-    names.add("Hspa1a");
-    names.add("Mgst2");
-    names.add("Tgfbr2");
-    names.add("Ephx1");
-    names.add("Dnajb1");
-    names.add("Abcc2");
-    names.add("Gclc");
-    names.add("Abcc5");
-    names.add("Ggt1");
-    names.add("Ftl");
-    names.add("Egr1");
-    names.add("Fgf13");
-    // problematic one
-    // names.add("Hgf");
-    // problematic one
-    // names.add("UbcH7");
-    names.add("Abcc3");
-    names.add("Nfe2l2");
-    // problematic one
-    // names.add("Hsp70");
-    names.add("Hsp90ab1");
-
-    try {
-      for (int i = 0; i < names.size(); i++) {
-        String geneName = names.get(i);
-        String annotation = restService.getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, geneName));
-        assertNotNull("Problem with annotation of mouse gene: " + geneName, annotation);
-        assertTrue("Problem with annotation of mouse gene: " + geneName, !annotation.trim().equals(""));
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  @Ignore("Bug 451")
-  public void testGetAnnotationsForNSMF() throws Exception {
-    try {
-      String response = restService.getAnnotation(nsmf);
-      assertNotNull(response);
-      assertFalse(response.trim().equals(""));
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  @Ignore("Bug 451")
-  public void testGetAnnotationsForMIR449A() throws Exception {
-    try {
-      String response = restService.getAnnotation(mir449a);
-      assertNotNull(response);
-      assertFalse(response.trim().equals(""));
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test(timeout = 15000)
-  public void testCachableInterfaceInvalidate() throws Exception {
-    String query = "GLUD1";
-    try {
-      String newRes = "hello";
-
-      cache.setCachedQuery(query, restService.getCacheType(), newRes);
-      String res = cache.getStringByQuery(query, restService.getCacheType());
-      assertEquals(newRes, res);
-      cache.invalidateByQuery(query, restService.getCacheType());
-
-      permanentDatabaseLevelCache.waitToFinishTasks();
-
-      res = cache.getStringByQuery(query, restService.getCacheType());
-
-      assertNotNull(res);
-
-      assertFalse("Value wasn't refreshed from db", newRes.equals(res));
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testNameWithNewLine() throws Exception {
-    try {
-      String response = restService.getAnnotation(new MiriamData(MiriamType.HGNC_SYMBOL, "some\nname"));
-      assertNotNull(response);
-
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testRefreshInvalidValue() throws Exception {
-    try {
-      restService.refreshCacheQuery(new Object());
-      fail("Exception expected");
-    } catch (InvalidArgumentException e) {
-      assertTrue(e.getMessage().contains("Don't know what to do "));
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testRefreshValueWhenProblemWithSource() throws Exception {
-    try {
-      BiocompendiumAnnotator annotatorUnderTest = Mockito.mock(BiocompendiumAnnotator.class,
-          Mockito.CALLS_REAL_METHODS);
-      when(annotatorUnderTest.getAnnotationsFromXml(anyString())).thenThrow(InvalidXmlSchemaException.class);
-      annotatorUnderTest.refreshCacheQuery(camk4.getResource());
-      fail("Exception expected");
-    } catch (SourceNotAvailable e) {
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testGetInvalidAnnotations() throws Exception {
-    try {
-      restService.getAnnotation(new MiriamData(MiriamType.WIKIPEDIA, "world"));
-      fail("Exception expected");
-    } catch (InvalidArgumentException e) {
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-
-  }
-
-  @Test
-  public void testInvalidDataToStrubg() throws Exception {
-    try {
-      restService.dataToString(new MiriamData(MiriamType.WIKIPEDIA, "world"));
-      fail("Exception expected");
-    } catch (InvalidArgumentException e) {
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testGetAnnotationsFromInvaldXml() throws Exception {
-    try {
-      Map<String, String> map = restService.getAnnotationsFromXml("");
-      assertEquals(0, map.size());
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-  @Test
-  public void testGetAnnotationsFromInvaldXml2() throws Exception {
-    try {
-      Map<String, String> map = restService.getAnnotationsFromXml(null);
-      assertEquals(0, map.size());
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
-}
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/MultipleAnnotatorsTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/MultipleAnnotatorsTest.java
index b5be651fd1..56fbb37765 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/MultipleAnnotatorsTest.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/MultipleAnnotatorsTest.java
@@ -24,9 +24,6 @@ public class MultipleAnnotatorsTest extends AnnotationTestFunctions {
   @Autowired
   HgncAnnotator hgncAnnotator;
 
-  @Autowired
-  BiocompendiumAnnotator biocompendiumAnnotator;
-
   @Before
   public void setUp() throws Exception {
   }
diff --git a/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190515__remove_biocompendium.sql b/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190515__remove_biocompendium.sql
new file mode 100644
index 0000000000..e586291725
--- /dev/null
+++ b/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190515__remove_biocompendium.sql
@@ -0,0 +1,2 @@
+delete from cache_query_table where type in (select id from cache_type_table where class_name ='lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator');
+delete from cache_type_table where class_name ='lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator';
diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ExternalServicesService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ExternalServicesService.java
deleted file mode 100644
index 06cc9a768d..0000000000
--- a/service/src/main/java/lcsb/mapviewer/services/impl/ExternalServicesService.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package lcsb.mapviewer.services.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import lcsb.mapviewer.annotation.services.ChEMBLParser;
-import lcsb.mapviewer.annotation.services.DrugbankHTMLParser;
-import lcsb.mapviewer.annotation.services.ExternalServiceStatus;
-import lcsb.mapviewer.annotation.services.IExternalService;
-import lcsb.mapviewer.annotation.services.MiriamConnector;
-import lcsb.mapviewer.annotation.services.PubmedParser;
-import lcsb.mapviewer.annotation.services.ChemicalParser;
-import lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.ChebiAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.EnsemblAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.EntrezAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.GoAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator;
-import lcsb.mapviewer.persist.DbUtils;
-import lcsb.mapviewer.services.interfaces.IExternalServicesService;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * Implementation of the service that retrieves information about services that
- * access external resources (like chebi, chembl, etc.).
- * 
- * @author Piotr Gawron
- * 
- */
-@Service
-public class ExternalServicesService implements IExternalServicesService {
-
-	/**
-	 * List of services that should be checked for status.
-	 */
-	private List<IExternalService>	services				= new ArrayList<IExternalService>();
-
-	/**
-	 * Service accessing <a href="http://www.drugbank.ca/">drugbank</a>.
-	 */
-	private DrugbankHTMLParser			drugbankHTMLParser;
-	
-	
-	/**
-	 * Service accessing <a href="http://ctdbase.org/">ctd</a>.
-	 */
-	private ChemicalParser			ctdParser;
-
-	/**
-	 * Service accessing <a
-	 * href="https://www.ebi.ac.uk/chembl/compound/inspect/">chembl</a>.
-	 */
-	private ChEMBLParser						chEMBLParser;
-
-	/**
-	 * Service accessing <a
-	 * href="http://www.ebi.ac.uk/chebi/webServices.do">chebi</a>.
-	 */
-	private ChebiAnnotator					chebiBackend;
-
-	/**
-	 * Service accessing <a
-	 * href="http://europepmc.org/RestfulWebService">pubmed</a>.
-	 */
-	private PubmedParser						pubmedParser;
-
-	/**
-	 * Service accessing <a href= "http://www.ebi.ac.uk/miriam/main/" >miriam
-	 * registry</a>.
-	 */
-	private MiriamConnector					miriamConnector;
-
-	/**
-	 * Service accessing <a href= "http://biocompendium.embl.de/" >internal
-	 * annotating service</a>.
-	 */
-	private BiocompendiumAnnotator	annotationRestService;
-
-	/**
-	 * Service accessing <a href= "http://www.uniprot.org/" >uniprot</a>.
-	 */
-	private UniprotAnnotator				uniprotAnnotator;
-
-	/**
-	 * Service accessing Ensembl database.
-	 */
-	private EnsemblAnnotator				ensemblAnnotator;
-
-	/**
-	 * Service accessing Entrez database.
-	 */
-	private EntrezAnnotator					entrezAnnotator;
-
-	/**
-	 * Service accessing <a href= "http://www.ebi.ac.uk/QuickGO/" >Gene
-	 * Ontology</a>.
-	 */
-	private GoAnnotator							goBackend;
-	
-	/**
-	 * Service accessing HGNC restfull API .
-	 */
-	private HgncAnnotator						hgncBackend;
-
-	/**
-	 * Utils that help to manage the sessions in custom multithreaded
-	 * implementation.
-	 */
-	private DbUtils									dbUtils;
-
-	@Autowired
-	public ExternalServicesService(DrugbankHTMLParser drugbankHTMLParser,
-								   ChemicalParser ctdParser,
-								   ChEMBLParser chEMBLParser,
-								   ChebiAnnotator chebiBackend,
-								   PubmedParser pubmedParser,
-								   MiriamConnector miriamConnector,
-								   BiocompendiumAnnotator annotationRestService,
-								   UniprotAnnotator uniprotAnnotator,
-								   EnsemblAnnotator ensemblAnnotator,
-								   EntrezAnnotator entrezAnnotator,
-								   GoAnnotator goBackend,
-								   HgncAnnotator hgncBackend,
-								   DbUtils dbUtils) {
-		this.drugbankHTMLParser = drugbankHTMLParser;
-		this.ctdParser = ctdParser;
-		this.chEMBLParser = chEMBLParser;
-		this.chebiBackend = chebiBackend;
-		this.pubmedParser = pubmedParser;
-		this.miriamConnector = miriamConnector;
-		this.annotationRestService = annotationRestService;
-		this.uniprotAnnotator = uniprotAnnotator;
-		this.ensemblAnnotator = ensemblAnnotator;
-		this.entrezAnnotator = entrezAnnotator;
-		this.goBackend = goBackend;
-		this.hgncBackend = hgncBackend;
-		this.dbUtils = dbUtils;
-	}
-
-	@Override
-	public List<ExternalServiceStatus> getExternalServiceStatuses() {
-		List<ExternalServiceStatus> result = new ArrayList<ExternalServiceStatus>();
-		for (IExternalService service : services) {
-			boolean sessionOpened = false;
-			if (!dbUtils.isCustomSessionForCurrentThread()) {
-				sessionOpened = true;
-				dbUtils.createSessionForCurrentThread();
-			}
-			result.add(service.getServiceStatus());
-			if (sessionOpened) {
-				dbUtils.closeSessionForCurrentThread();
-			}
-		}
-		return result;
-	}
-
-	@Override
-	public void registerService(IExternalService service) {
-		services.add(service);
-
-	}
-
-	@Override
-	public void registerDefaultServices() {
-		registerService(drugbankHTMLParser);
-		registerService(chEMBLParser);
-		registerService(chebiBackend);
-		registerService(pubmedParser);
-		registerService(miriamConnector);
-		registerService(annotationRestService);
-		registerService(ensemblAnnotator);
-		registerService(entrezAnnotator);
-		registerService(goBackend);
-		registerService(ctdParser);
-		registerService(hgncBackend);
-		registerService(uniprotAnnotator);
-	}
-
-	@Override
-	public void clearServices() {
-		services.clear();
-
-	}
-}
diff --git a/service/src/test/java/lcsb/mapviewer/services/ServiceTestFunctions.java b/service/src/test/java/lcsb/mapviewer/services/ServiceTestFunctions.java
index ebc58a093a..fdc74c0f97 100644
--- a/service/src/test/java/lcsb/mapviewer/services/ServiceTestFunctions.java
+++ b/service/src/test/java/lcsb/mapviewer/services/ServiceTestFunctions.java
@@ -28,9 +28,9 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
-import org.apache.logging.log4j.*;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runner.RunWith;
@@ -49,8 +49,6 @@ import org.xml.sax.SAXException;
 import lcsb.mapviewer.annotation.services.ChEMBLParser;
 import lcsb.mapviewer.annotation.services.DrugbankHTMLParser;
 import lcsb.mapviewer.annotation.services.ModelAnnotator;
-import lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator;
-
 import lcsb.mapviewer.common.MinervaLoggerAppender;
 import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
 import lcsb.mapviewer.converter.ConverterParams;
@@ -96,9 +94,6 @@ public abstract class ServiceTestFunctions {
   @Autowired
   protected ModelAnnotator modelAnnotator;
 
-  @Autowired
-  protected BiocompendiumAnnotator restService;
-
   public double EPSILON = 1e-6;
 
   @Autowired
-- 
GitLab