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

annotators provide information about type and source

parent d231b8bd
...@@ -12,6 +12,7 @@ import lcsb.mapviewer.annotation.cache.*; ...@@ -12,6 +12,7 @@ import lcsb.mapviewer.annotation.cache.*;
import lcsb.mapviewer.annotation.data.Chebi; import lcsb.mapviewer.annotation.data.Chebi;
import lcsb.mapviewer.annotation.services.*; import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.*; import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.species.Chemical; import lcsb.mapviewer.model.map.species.Chemical;
import lcsb.mapviewer.model.user.annotator.*; import lcsb.mapviewer.model.user.annotator.*;
...@@ -449,7 +450,8 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService ...@@ -449,7 +450,8 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
element.addMiriamData(chebi); element.addMiriamData(chebi);
return annotateElement(element, chebi, parameters); return annotateElement(element, chebi, parameters);
} else { } else {
logger.warn(element.getElementTag() + "Chemical name cannot be found in chebi: " + name); logger.warn(element.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
"Chemical name cannot be found in chebi: " + name);
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -10,13 +10,14 @@ import lcsb.mapviewer.common.comparator.StringSetComparator; ...@@ -10,13 +10,14 @@ import lcsb.mapviewer.common.comparator.StringSetComparator;
import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerChemical; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerChemical;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.*; import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.UniprotRecord; import lcsb.mapviewer.model.map.species.field.UniprotRecord;
import lcsb.mapviewer.model.user.AnnotatorParamDefinition; import lcsb.mapviewer.model.user.AnnotatorParamDefinition;
import lcsb.mapviewer.model.user.annotator.*; import lcsb.mapviewer.model.user.annotator.*;
import lcsb.mapviewer.modelutils.map.ElementUtils;
/** /**
* Interface that allows to annotate {@link BioEntity elements} in the system. * Interface that allows to annotate {@link BioEntity elements} in the system.
...@@ -132,12 +133,12 @@ public abstract class ElementAnnotator extends CachableInterface { ...@@ -132,12 +133,12 @@ public abstract class ElementAnnotator extends CachableInterface {
AnnotatorData parameters) AnnotatorData parameters)
throws AnnotatorException; throws AnnotatorException;
public boolean annotateElement(BioEntityProxy element, String name, AnnotatorData parameters) public boolean annotateElement(BioEntityProxy element, String name, AnnotatorData parameters)
throws AnnotatorException { throws AnnotatorException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/** /**
* Returns a list of all classes that can be annotated using this annotator. * Returns a list of all classes that can be annotated using this annotator.
* *
* @return a list of all classes that can be annotated using this annotator * @return a list of all classes that can be annotated using this annotator
...@@ -353,8 +354,10 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat ...@@ -353,8 +354,10 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
return originalBioEntity.getMiriamData().contains(copy) || originalBioEntity.getMiriamData().contains(copy2); return originalBioEntity.getMiriamData().contains(copy) || originalBioEntity.getMiriamData().contains(copy2);
} }
public String getElementTag() { public LogMarker getLogMarker(ProjectLogEntryType type) {
return new ElementUtils().getElementTag(originalBioEntity, ElementAnnotator.this); LogMarker result = new LogMarker(type, originalBioEntity);
result.getEntry().setSource(ElementAnnotator.this.getClass().getSimpleName());
return result;
} }
public boolean isElement() { public boolean isElement() {
...@@ -408,7 +411,8 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat ...@@ -408,7 +411,8 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
set2.addAll(oldCollection); set2.addAll(oldCollection);
if (stringSetComparator.compare(set1, set2) != 0) { if (stringSetComparator.compare(set1, set2) != 0) {
logger.warn(getElementTag() + field.getCommonName() + " don't match: \"" + set1 + "\", \"" + set2 + "\""); logger.warn(getLogMarker(ProjectLogEntryType.ANNOTATION_CONFLICT),
field.getCommonName() + " don't match: \"" + set1 + "\", \"" + set2 + "\"");
return false; return false;
} }
return true; return true;
...@@ -440,7 +444,8 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat ...@@ -440,7 +444,8 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
if (oldValue == null || oldValue.trim().equals("") || oldValue.equals(newValue)) { if (oldValue == null || oldValue.trim().equals("") || oldValue.equals(newValue)) {
return true; return true;
} else { } else {
logger.warn(getElementTag(field) + " doesn't match: \"" + newValue + "\", \"" + oldValue + "\""); logger.warn(getLogMarker(ProjectLogEntryType.ANNOTATION_CONFLICT), field.getCommonName() +
" doesn't match: \"" + newValue + "\", \"" + oldValue + "\"");
return false; return false;
} }
} }
...@@ -455,15 +460,12 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat ...@@ -455,15 +460,12 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
if (oldValue == null || oldValue == 0 || oldValue.toString().equals(newValue)) { if (oldValue == null || oldValue == 0 || oldValue.toString().equals(newValue)) {
return true; return true;
} else { } else {
logger.warn(getElementTag(field) + " doesn't match: \"" + newValue + "\", \"" + oldValue + "\""); logger.warn(getLogMarker(ProjectLogEntryType.ANNOTATION_CONFLICT),
field.getCommonName() + " doesn't match: \"" + newValue + "\", \"" + oldValue + "\"");
return false; return false;
} }
} }
private String getElementTag(BioEntityField field) {
return getElementTag() + " " + field.getCommonName();
}
public void setFormerSymbols(Collection<String> formerSymbols) { public void setFormerSymbols(Collection<String> formerSymbols) {
if (originalBioEntity instanceof Element) { if (originalBioEntity instanceof Element) {
Element element = (Element) originalBioEntity; Element element = (Element) originalBioEntity;
...@@ -521,7 +523,7 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat ...@@ -521,7 +523,7 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
try { try {
md = MiriamType.getMiriamByUri("urn:miriam:" + generalIdentifier); md = MiriamType.getMiriamByUri("urn:miriam:" + generalIdentifier);
} catch (InvalidArgumentException e1) { } catch (InvalidArgumentException e1) {
logger.warn(getElementTag() + "Unknown miriam uri: " + generalIdentifier); logger.warn(getLogMarker(ProjectLogEntryType.INVALID_IDENTIFIER), "Unknown miriam uri: " + generalIdentifier);
} }
} }
addMiriamData(md); addMiriamData(md);
......
...@@ -15,6 +15,7 @@ import lcsb.mapviewer.annotation.services.*; ...@@ -15,6 +15,7 @@ import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
...@@ -134,7 +135,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi ...@@ -134,7 +135,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
if (node.getNodeName().equals("data")) { if (node.getNodeName().equals("data")) {
String error = XmlParser.getNodeAttr("error", node); String error = XmlParser.getNodeAttr("error", node);
if (error != null && !error.isEmpty()) { if (error != null && !error.isEmpty()) {
logger.warn(element.getElementTag() + error); logger.warn(element.getLogMarker(ProjectLogEntryType.OTHER), error);
} }
String dbname = XmlParser.getNodeAttr("dbname", node); String dbname = XmlParser.getNodeAttr("dbname", node);
...@@ -188,8 +189,8 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi ...@@ -188,8 +189,8 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
} }
return true; return true;
} catch (WrongResponseCodeIOException e) { } catch (WrongResponseCodeIOException e) {
logger.warn( logger.warn(element.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
element.getElementTag() + "Cannot find information for ensembl: " + identifier.getResource()); "Cannot find information for ensembl: " + identifier.getResource());
return false; return false;
} catch (Exception e) { } catch (Exception e) {
throw new AnnotatorException(e); throw new AnnotatorException(e);
......
...@@ -16,6 +16,8 @@ import lcsb.mapviewer.annotation.data.EntrezData; ...@@ -16,6 +16,8 @@ import lcsb.mapviewer.annotation.data.EntrezData;
import lcsb.mapviewer.annotation.services.*; import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.*; import lcsb.mapviewer.common.exception.*;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
...@@ -125,8 +127,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic ...@@ -125,8 +127,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
public boolean annotateElement(BioEntityProxy element, MiriamData identifier, AnnotatorData parameters) public boolean annotateElement(BioEntityProxy element, MiriamData identifier, AnnotatorData parameters)
throws AnnotatorException { throws AnnotatorException {
if (identifier.getDataType().equals(MiriamType.ENTREZ)) { if (identifier.getDataType().equals(MiriamType.ENTREZ)) {
String prefix = element.getElementTag(); EntrezData data = getEntrezForMiriamData(identifier, element.getLogMarker(ProjectLogEntryType.OTHER));
EntrezData data = getEntrezForMiriamData(identifier, prefix);
if (data != null) { if (data != null) {
element.setSymbol(data.getSymbol()); element.setSymbol(data.getSymbol());
...@@ -185,7 +186,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic ...@@ -185,7 +186,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
* thrown when there is a problem with obtaining data from entrez * thrown when there is a problem with obtaining data from entrez
* database * database
*/ */
EntrezData getEntrezForMiriamData(MiriamData entrezMiriamData, String prefix) throws AnnotatorException { EntrezData getEntrezForMiriamData(MiriamData entrezMiriamData, LogMarker marker) throws AnnotatorException {
EntrezData result = entrezSerializer EntrezData result = entrezSerializer
.xmlToObject(super.getCacheNode(ENTREZ_DATA_PREFIX + entrezMiriamData.getResource())); .xmlToObject(super.getCacheNode(ENTREZ_DATA_PREFIX + entrezMiriamData.getResource()));
if (result == null) { if (result == null) {
...@@ -199,13 +200,15 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic ...@@ -199,13 +200,15 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
if (response != null) { if (response != null) {
Node errorNode = XmlParser.getNode("Error", response.getChildNodes()); Node errorNode = XmlParser.getNode("Error", response.getChildNodes());
if (errorNode != null) { if (errorNode != null) {
logger.warn( LogMarker m = new LogMarker(marker);
prefix + " Invalid " + MiriamType.ENTREZ + " identifier: \"" + entrezMiriamData.getResource() + "\""); m.getEntry().setType(ProjectLogEntryType.INVALID_IDENTIFIER);
logger.warn(m, " Invalid " + MiriamType.ENTREZ + " identifier: \"" + entrezMiriamData.getResource() + "\"");
return null; return null;
} }
} else { } else {
logger LogMarker m = new LogMarker(marker);
.warn(prefix + "Problematic entrez response for identifier: \"" + entrezMiriamData.getResource() + "\""); m.getEntry().setType(ProjectLogEntryType.OTHER);
logger.warn(m, "Problematic entrez response for identifier: \"" + entrezMiriamData.getResource() + "\"");
return null; return null;
} }
...@@ -294,7 +297,9 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic ...@@ -294,7 +297,9 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
setCacheValue(ENTREZ_DATA_PREFIX + entrezMiriamData.getResource(), entrezSerializer.objectToString(result)); setCacheValue(ENTREZ_DATA_PREFIX + entrezMiriamData.getResource(), entrezSerializer.objectToString(result));
} catch (WrongResponseCodeIOException e) { } catch (WrongResponseCodeIOException e) {
if (e.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST) { if (e.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
logger.warn(prefix + " Invalid " + MiriamType.ENTREZ.getCommonName() + " identifier found"); LogMarker m = new LogMarker(marker);
m.getEntry().setType(ProjectLogEntryType.INVALID_IDENTIFIER);
logger.warn(m, " Invalid " + MiriamType.ENTREZ.getCommonName() + " identifier found");
} else { } else {
throw new AnnotatorException(e); throw new AnnotatorException(e);
} }
......
...@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader; ...@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*; import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.*; import lcsb.mapviewer.common.exception.*;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
...@@ -96,7 +97,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService ...@@ -96,7 +97,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
if (count == null || count.equals("") || count.equals("0")) { if (count == null || count.equals("") || count.equals("0")) {
// print warn info when we have only hgnc identifiers (or no // print warn info when we have only hgnc identifiers (or no
// identifiers at all) // identifiers at all)
logger.warn(element.getElementTag() + "Cannot find information for element."); logger.warn(element.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
"Cannot find information for element.");
return false; return false;
} else { } else {
Node entry = XmlParser.getNode("doc", result.getChildNodes()); Node entry = XmlParser.getNode("doc", result.getChildNodes());
...@@ -173,7 +175,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService ...@@ -173,7 +175,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
return true; return true;
} }
} catch (WrongResponseCodeIOException e) { } catch (WrongResponseCodeIOException e) {
logger.warn(element.getElementTag() + "Cannot find information for element."); logger.warn(element.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
"Cannot find information for element.");
return false; return false;
} catch (Exception e) { } catch (Exception e) {
throw new AnnotatorException(e); throw new AnnotatorException(e);
......
...@@ -16,6 +16,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader; ...@@ -16,6 +16,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*; import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.*; import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.Structure; import lcsb.mapviewer.model.map.species.field.Structure;
...@@ -107,7 +108,8 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService { ...@@ -107,7 +108,8 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService {
try { try {
Collection<Structure> structures = uniProtToPdb(identifier); Collection<Structure> structures = uniProtToPdb(identifier);
if (structures.size() == 0) { if (structures.size() == 0) {
logger.warn(bioEntity.getElementTag() + " No PDB mapping for UniProt ID: " + identifier.getResource()); logger.warn(bioEntity.getLogMarker(ProjectLogEntryType.OTHER),
" No PDB mapping for UniProt ID: " + identifier.getResource());
return false; return false;
} else { } else {
// add the annotations to the set of annotation irrespective on // add the annotations to the set of annotation irrespective on
......
...@@ -15,6 +15,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader; ...@@ -15,6 +15,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*; import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.MinervaLoggerAppender; import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.Reaction;
...@@ -286,17 +287,19 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService ...@@ -286,17 +287,19 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService
unknown = true; unknown = true;
} }
if (unknown) { if (unknown) {
logger.warn(element.getElementTag() + "Unknown field in recon annotation: \"" + key + "\" (value: " logger.warn(element.getLogMarker(ProjectLogEntryType.OTHER),
+ value + ")"); "Unknown field in recon annotation: \"" + key + "\" (value: " + value + ")");
} }
} }
return true; return true;
} else { } else {
logger.warn(element.getElementTag() + "No recon annotations \"" + identifier.getResource() + "\""); logger.warn(element.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
"No recon annotations \"" + identifier.getResource() + "\"");
return false; return false;
} }
} else { } else {
logger.warn(element.getElementTag() + "No recon annotations \"" + identifier.getResource() + "\""); logger.warn(element.getLogMarker(ProjectLogEntryType.CANNOT_FIND_INFORMATION),
"No recon annotations \"" + identifier.getResource() + "\"");
return false; return false;
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -370,8 +373,8 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService ...@@ -370,8 +373,8 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService
} else if (value.startsWith("K")) { } else if (value.startsWith("K")) {
md = new MiriamData(MiriamType.KEGG_ORTHOLOGY, value); md = new MiriamData(MiriamType.KEGG_ORTHOLOGY, value);
} else { } else {
logger.warn(element.getElementTag() logger.warn(element.getLogMarker(ProjectLogEntryType.INVALID_IDENTIFIER),
+ "Unknown Kegg identifier type (only Kegg compounds and reactions are supported): \"" + value + "\""); "Unknown Kegg identifier type (only Kegg compounds and reactions are supported): \"" + value + "\"");
} }
return md; return md;
} }
......
...@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader; ...@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*; import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*; import lcsb.mapviewer.model.map.species.*;
...@@ -106,7 +107,8 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi ...@@ -106,7 +107,8 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
} else { } else {
// this means that entry with a given uniprot id doesn't exist // this means that entry with a given uniprot id doesn't exist
if (object.contains(identifier)) { if (object.contains(identifier)) {
logger.warn(object.getElementTag() + " Invalid uniprot id: " + identifier); logger.warn(object.getLogMarker(ProjectLogEntryType.INVALID_IDENTIFIER),
" Invalid uniprot id: " + identifier);
} }
return false; return false;
} }
......
...@@ -192,7 +192,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { ...@@ -192,7 +192,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn(response); when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn(response);
entrezAnnotator.setWebPageDownloader(mockDownloader); entrezAnnotator.setWebPageDownloader(mockDownloader);
EntrezData data = entrezAnnotator.getEntrezForMiriamData(new MiriamData(), ""); EntrezData data = entrezAnnotator.getEntrezForMiriamData(new MiriamData(), null);
boolean ensembl = false; boolean ensembl = false;
boolean hgnc = false; boolean hgnc = false;
for (MiriamData md : data.getMiriamData()) { for (MiriamData md : data.getMiriamData()) {
...@@ -223,7 +223,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { ...@@ -223,7 +223,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class);
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn(response); when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenReturn(response);
entrezAnnotator.setWebPageDownloader(mockDownloader); entrezAnnotator.setWebPageDownloader(mockDownloader);
entrezAnnotator.getEntrezForMiriamData(new MiriamData(), ""); entrezAnnotator.getEntrezForMiriamData(new MiriamData(), null);
} finally { } finally {
entrezAnnotator.setWebPageDownloader(downloader); entrezAnnotator.setWebPageDownloader(downloader);
entrezAnnotator.setCache(cache); entrezAnnotator.setCache(cache);
...@@ -241,7 +241,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { ...@@ -241,7 +241,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))) when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class)))
.thenThrow(new WrongResponseCodeIOException(null, 404)); .thenThrow(new WrongResponseCodeIOException(null, 404));
entrezAnnotator.setWebPageDownloader(mockDownloader); entrezAnnotator.setWebPageDownloader(mockDownloader);
entrezAnnotator.getEntrezForMiriamData(new MiriamData(), ""); entrezAnnotator.getEntrezForMiriamData(new MiriamData(), null);
} finally { } finally {
entrezAnnotator.setWebPageDownloader(downloader); entrezAnnotator.setWebPageDownloader(downloader);
entrezAnnotator.setCache(cache); entrezAnnotator.setCache(cache);
......
...@@ -3,7 +3,7 @@ package lcsb.mapviewer.common.exception; ...@@ -3,7 +3,7 @@ package lcsb.mapviewer.common.exception;
/** /**
* Exception that should be thrown when application/class/method entered to the * Exception that should be thrown when application/class/method entered to the
* part of code that wasn't implemented (for instance the class is not abstract, * part of code that wasn't implemented (for instance the class is not abstract,
* but method should be considered abstrac...). * but method should be considered abstract...).
* *
* @author Piotr Gawron * @author Piotr Gawron
* *
......
...@@ -14,7 +14,7 @@ public class LogMarker implements Marker { ...@@ -14,7 +14,7 @@ public class LogMarker implements Marker {
private ProjectLogEntry entry; private ProjectLogEntry entry;
public LogMarker(String type, BioEntity bioEntity) { public LogMarker(ProjectLogEntryType type, BioEntity bioEntity) {
entry = new ProjectLogEntry(); entry = new ProjectLogEntry();
entry.setType(type); entry.setType(type);
if (bioEntity != null) { if (bioEntity != null) {
...@@ -26,6 +26,10 @@ public class LogMarker implements Marker { ...@@ -26,6 +26,10 @@ public class LogMarker implements Marker {
} }
} }
public LogMarker(LogMarker marker) {
entry = new ProjectLogEntry(marker.getEntry());
}
@Override @Override
public Marker addParents(Marker... markers) { public Marker addParents(Marker... markers) {
throw new NotImplementedException(); throw new NotImplementedException();
......
...@@ -20,7 +20,8 @@ public class ProjectLogEntry implements Serializable { ...@@ -20,7 +20,8 @@ public class ProjectLogEntry implements Serializable {
private String severity; private String severity;
@Column(nullable = false) @Column(nullable = false)
private String type; @Enumerated(EnumType.STRING)
private ProjectLogEntryType type;
private String objectIdentifier; private String objectIdentifier;
...@@ -28,6 +29,8 @@ public class ProjectLogEntry implements Serializable { ...@@ -28,6 +29,8 @@ public class ProjectLogEntry implements Serializable {