diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java index 088c6eee2d084f3626756bd91ec2998ae912f0f3..529119fac3badd2aef3e36048596aa9352d62a3e 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java @@ -14,7 +14,9 @@ import javax.annotation.PostConstruct; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import lcsb.mapviewer.annotation.services.annotators.AnnotationParameters; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.annotation.services.annotators.BiocompendiumAnnotator; import lcsb.mapviewer.annotation.services.annotators.BrendaAnnotator; @@ -44,7 +46,6 @@ import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.user.UserAnnotatorsParam; import lcsb.mapviewer.modelutils.map.ClassTreeNode; import lcsb.mapviewer.modelutils.map.ElementUtils; -import org.springframework.stereotype.Service; /** * This class annotates all elements in the model. @@ -169,21 +170,21 @@ public class ModelAnnotator { */ @Autowired public ModelAnnotator(MiriamConnector miriamConnector, - BrendaAnnotator brendaAnnotator, - BiocompendiumAnnotator biocompendiumAnnotator, - CazyAnnotator cazyAnnotator, - ChebiAnnotator chebiBackend, - UniprotAnnotator uniprotAnnotator, - PdbAnnotator pdbAnnotator, - ReconAnnotator reconAnnotator, - GoAnnotator goAnnotator, - HgncAnnotator hgncAnnotator, - KeggAnnotator keggAnnotator, - EntrezAnnotator entrezAnnotator, - EnsemblAnnotator ensemblAnnotator, - StitchAnnotator stitchAnnotator, - StringAnnotator stringAnnotator, - TairAnnotator tairAnnotator) { + BrendaAnnotator brendaAnnotator, + BiocompendiumAnnotator biocompendiumAnnotator, + CazyAnnotator cazyAnnotator, + ChebiAnnotator chebiBackend, + UniprotAnnotator uniprotAnnotator, + PdbAnnotator pdbAnnotator, + ReconAnnotator reconAnnotator, + GoAnnotator goAnnotator, + HgncAnnotator hgncAnnotator, + KeggAnnotator keggAnnotator, + EntrezAnnotator entrezAnnotator, + EnsemblAnnotator ensemblAnnotator, + StitchAnnotator stitchAnnotator, + StringAnnotator stringAnnotator, + TairAnnotator tairAnnotator) { this.miriamConnector = miriamConnector; this.brendaAnnotator = brendaAnnotator; this.biocompendiumAnnotator = biocompendiumAnnotator; @@ -249,7 +250,7 @@ public class ModelAnnotator { * @param progressUpdater * callback function used for updating progress of the function */ - public void performAnnotations(Model model, final IProgressUpdater progressUpdater) { + public void performAnnotations(Model model, final IProgressUpdater progressUpdater) { performAnnotations(model, progressUpdater, null, null); } @@ -265,7 +266,7 @@ public class ModelAnnotator { * callback function used for updating progress of the function */ public void performAnnotations(Model model, final IProgressUpdater progressUpdater, - Map<Class<?>, List<ElementAnnotator>> annotators, Map<Class<?>, List<UserAnnotatorsParam>> annotatorsParams) { + Map<Class<?>, List<ElementAnnotator>> annotators, Map<Class<?>, List<UserAnnotatorsParam>> annotatorsParams) { progressUpdater.setProgress(0); List<Model> models = new ArrayList<Model>(); models.add(model); @@ -362,8 +363,8 @@ public class ModelAnnotator { * callback function used to refresh progress of function execution */ protected void annotateModel(Model model, IProgressUpdater progressUpdater, - Map<Class<?>, List<ElementAnnotator>> annotators, Map<Class<?>, List<UserAnnotatorsParam>> annotatorsParams) { - + Map<Class<?>, List<ElementAnnotator>> annotators, Map<Class<?>, List<UserAnnotatorsParam>> annotatorsParams) { + ElementUtils elementUtils = new ElementUtils(); progressUpdater.setProgress(0); @@ -380,19 +381,14 @@ public class ModelAnnotator { if (list == null) { list = getDefaultAnnotators(); } - - for (ElementAnnotator elementAnnotator : list) { + + for (ElementAnnotator elementAnnotator : list) { try { + AnnotationParameters parameters = new AnnotationParameters(); if (annotatorsParams != null) { - List<UserAnnotatorsParam> params = annotatorsParams.get(elementAnnotator.getClass()); - if (params != null) { - elementAnnotator.annotateElement(element, params); - } else { - elementAnnotator.annotateElement(element); - } - } else { - elementAnnotator.annotateElement(element); + parameters.addAnnotatorParameters(annotatorsParams.get(elementAnnotator.getClass())); } + elementAnnotator.annotateElement(element, parameters); } catch (AnnotatorException e) { logger.warn(elementUtils.getElementTag(element) + " " + elementAnnotator.getCommonName() + " annotation problem: " + e.getMessage()); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotationParameters.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotationParameters.java new file mode 100644 index 0000000000000000000000000000000000000000..cc25744fe65a17b061c2747b68d2ef18735cc6b3 --- /dev/null +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotationParameters.java @@ -0,0 +1,42 @@ +package lcsb.mapviewer.annotation.services.annotators; + +import java.util.ArrayList; +import java.util.List; + +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; +import lcsb.mapviewer.model.user.UserAnnotatorsParam; + +public class AnnotationParameters { + private List<AnnotatorParameter> annotatorParameters = new ArrayList<>(); + + public AnnotationParameters addAnnotatorParameter(AnnotatorParamDefinition type, String value) { + annotatorParameters.add(new AnnotatorParameter(type, value)); + return this; + } + + public AnnotationParameters addAnnotatorParameter(AnnotatorParameter parameter) { + annotatorParameters.add(parameter); + return this; + } + + public AnnotationParameters addAnnotatorParameters(List<?> parameters) { + for (Object object : parameters) { + if (object instanceof AnnotatorParameter) { + addAnnotatorParameter((AnnotatorParameter)object); + } else if (object instanceof UserAnnotatorsParam) { + addAnnotatorParameter(((UserAnnotatorsParam) object).getParameterType(), + ((UserAnnotatorsParam) object).getParamValue()); + } + } + return this; + } + + public String getValue(AnnotatorParamDefinition type) { + for (AnnotatorParameter annotatorParameter : annotatorParameters) { + if (annotatorParameter.getType().equals(type)) { + return annotatorParameter.getValue(); + } + } + return null; + } +} diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorInput.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorInput.java new file mode 100644 index 0000000000000000000000000000000000000000..4a25dd98a4166ff9f6a577cf11c8d4c530e21c6b --- /dev/null +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorInput.java @@ -0,0 +1,33 @@ +package lcsb.mapviewer.annotation.services.annotators; + +import lcsb.mapviewer.model.map.MiriamType; + +/** + * Definition of annotator input. It describes which property/identifier should + * be used to identify element in the external database. + * + * @author Piotr Gawron + * + */ +public class AnnotatorInput{ + private BioEntityField field; + + private MiriamType identifierType; + + public AnnotatorInput(BioEntityField field) { + this(field, null); + } + + public AnnotatorInput(BioEntityField field, MiriamType identifierType) { + this.field = field; + this.identifierType = identifierType; + } + + public BioEntityField getField() { + return field; + } + + public MiriamType getIdentifierType() { + return identifierType; + } +} diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParamDefinition.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParamDefinition.java deleted file mode 100644 index 9559952e60378f012e6be87c251c6d5435ccb813..0000000000000000000000000000000000000000 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParamDefinition.java +++ /dev/null @@ -1,35 +0,0 @@ -package lcsb.mapviewer.annotation.services.annotators; - -/** - * Definition of a single parameter of an annotator. - * - * @author David Hoksza - * - */ -public class AnnotatorParamDefinition { - private String name; - - private String description; - - private Class<?> type; - - public AnnotatorParamDefinition(String name, Class<?> type, String description) { - super(); - this.name = name; - this.description = description; - this.type = type; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public Class<?> getType() { - return type; - } - -} diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParameter.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..258ca66252174fd4502f98cba60294abf25c6543 --- /dev/null +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParameter.java @@ -0,0 +1,23 @@ +package lcsb.mapviewer.annotation.services.annotators; + +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; + +public class AnnotatorParameter { + + private String value; + + private AnnotatorParamDefinition type; + + public AnnotatorParameter(AnnotatorParamDefinition type, String value) { + this.type = type; + this.value = value; + } + + public String getValue() { + return value; + } + + public AnnotatorParamDefinition getType() { + return type; + } +} diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BioEntityField.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BioEntityField.java new file mode 100644 index 0000000000000000000000000000000000000000..e2a7fa9ceee48d37578688e7b2753c0f2b86b6c9 --- /dev/null +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BioEntityField.java @@ -0,0 +1,13 @@ +package lcsb.mapviewer.annotation.services.annotators; + +import lcsb.mapviewer.model.map.BioEntity; + +/** + * This enum identifies field of the {@link BioEntity}. + * @author Piotr Gawron + * + */ +public enum BioEntityField { + NAME, + +} 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 index 2e2478f7f2f8642123d095372c9fc38e1d0b8533..85dd092ed07b6a017f495c1a7d971864fcbdf68b 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java @@ -301,7 +301,7 @@ public class BiocompendiumAnnotator extends ElementAnnotator implements IExterna } @Override - public void annotateElement(BioEntity element) throws AnnotatorException { + public void annotateElement(BioEntity element, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(element)) { try { String annotationString = getAnnotation(createMiriamData(MiriamType.HGNC_SYMBOL, element.getName())); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BrendaAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BrendaAnnotator.java index 403923f80bee148bbb92e976de5fa64b163dedfe..3dcac98d6ad61b3f0bb1f19c1f8ab3bdc2a66bc6 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BrendaAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BrendaAnnotator.java @@ -81,7 +81,7 @@ public class BrendaAnnotator extends ElementAnnotator implements IExternalServic } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { MiriamData mdTair = null; diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/CazyAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/CazyAnnotator.java index c9c4da932548b0cedb275b2cb579328b86b7b4dc..d88aa508c4e1bf2dc22b0b026815ba61ddc296d8 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/CazyAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/CazyAnnotator.java @@ -81,7 +81,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { MiriamData mdTair = null; diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java index 1d7aa61420d0d8791f479a26d77f2fb9d5cfbb26..72c89e1f29beb5e25bbbc6f2d1671356639fa6f8 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java @@ -439,7 +439,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService } @Override - public void annotateElement(BioEntity element) throws AnnotatorException { + public void annotateElement(BioEntity element, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(element)) { try { String warnPrefix = elementUtils.getElementTag(element, this); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java index a3764c3c9ef6b96e57fa8924d5a379962e107209..f7fe0a423b151f5571674d0d93747774260f60ff 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java @@ -18,6 +18,7 @@ import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Chemical; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; import lcsb.mapviewer.model.user.UserAnnotatorsParam; /** @@ -84,7 +85,9 @@ public abstract class ElementAnnotator extends CachableInterface { * @throws AnnotatorException * thrown when there is a problem with annotating not related to data */ - public abstract void annotateElement(BioEntity element) throws AnnotatorException; + public final void annotateElement(BioEntity element) throws AnnotatorException { + annotateElement(element, new AnnotationParameters()); + }; /** * Annotate element using parameters. @@ -97,9 +100,7 @@ public abstract class ElementAnnotator extends CachableInterface { * @throws AnnotatorException * thrown when there is a problem with annotating not related to data */ - public void annotateElement(BioEntity element, List<UserAnnotatorsParam> parameters) throws AnnotatorException { - annotateElement(element); - } + public abstract void annotateElement(BioEntity element, AnnotationParameters parameters) throws AnnotatorException; /** * Returns a list of all classes that can be annotated using this annotator. diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java index fcd26ed5bf32ef26f7bb7c1c831ae7ff3d4f17c9..13199592294af41c76c39ecc90e0de57c124dc94 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java @@ -155,7 +155,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi } @Override - public void annotateElement(BioEntity element) throws AnnotatorException { + public void annotateElement(BioEntity element, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(element)) { ElementUtils eu = new ElementUtils(); String prefix = eu.getElementTag(element); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java index 5cbcfd99e74c8fc5bda5215008e14380019833fc..b80028ddbe85ae53f50f8d44988da9c9372cef26 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java @@ -156,7 +156,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic } @Override - public void annotateElement(BioEntity element) throws AnnotatorException { + public void annotateElement(BioEntity element, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(element)) { ElementUtils eu = new ElementUtils(); String prefix = eu.getElementTag(element); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java index 3991e7c9f44c0f337710ebaa018d0d9d1d4647d7..f09ba41b0a777c26198343e21c706bc4deb59149 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java @@ -97,7 +97,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService { } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { MiriamData goTerm = null; for (MiriamData md : object.getMiriamData()) { diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java index 53ef651748eea2b3a1b901a723f8a49e07c9d4ec..627f94dc5d48f34bd905cbe1430a64ec21860164 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java @@ -119,7 +119,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService } @Override - public void annotateElement(BioEntity element) throws AnnotatorException { + public void annotateElement(BioEntity element, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(element)) { ElementUtils eu = new ElementUtils(); String prefix = eu.getElementTag(element); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotator.java index 0f92d1576d77d3018f8a96b588c3afdb7632a02d..a8929f06a07f55558e3a55e59edf8009b548b8bb 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotator.java @@ -4,13 +4,12 @@ package lcsb.mapviewer.annotation.services.annotators; import java.io.IOException; import java.util.Collection; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import lcsb.mapviewer.annotation.cache.GeneralCacheInterface; import lcsb.mapviewer.annotation.cache.SourceNotAvailable; @@ -28,8 +27,8 @@ import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; import lcsb.mapviewer.model.user.UserAnnotatorsParam; -import org.springframework.stereotype.Service; /** * This is a class that implements KEGG annotator which extract from KEGG @@ -73,13 +72,7 @@ public class KeggAnnotator extends ElementAnnotator implements IExternalService */ public KeggAnnotator(TairAnnotator tairAnnotator, UniprotAnnotator uniprotAnnotator) { super(KeggAnnotator.class, new Class[] { Protein.class, Gene.class, Rna.class }, false); - AnnotatorParamDefinition paramDef = new AnnotatorParamDefinition( - "KEGG organism identifier", - String.class, - "Space-delimited list of organisms codes for which homologous genes" - + " (GENE section in the KEGG enzyme record) should be imported." - + " Currently only ATH (Arabidopsis Thaliana) is supported."); - this.addParameterDefinition(paramDef); + this.addParameterDefinition(AnnotatorParamDefinition .KEGG_ORGANISM_IDENTIFIER); this.tairAnnotator = tairAnnotator; this.uniprotAnnotator = uniprotAnnotator; } @@ -123,7 +116,7 @@ public class KeggAnnotator extends ElementAnnotator implements IExternalService @Override - public void annotateElement(BioEntity object, List<UserAnnotatorsParam> params) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters params) throws AnnotatorException { if (!isAnnotatable(object)) { return; } @@ -180,11 +173,6 @@ public class KeggAnnotator extends ElementAnnotator implements IExternalService object.addMiriamData(annotations); } - @Override - public void annotateElement(BioEntity object) throws AnnotatorException { - this.annotateElement(object, null); - } - /** * Returns url to KEGG restful API about enzyme classification. * @@ -211,7 +199,7 @@ public class KeggAnnotator extends ElementAnnotator implements IExternalService * @return * {@link MiriamType#PUBMED}s found on the page */ - private Collection<MiriamData> parseKegg(String pageContent, List<UserAnnotatorsParam> params) { + private Collection<MiriamData> parseKegg(String pageContent, AnnotationParameters params) { //Retrieve Pubmeds Collection<MiriamData> result = new HashSet<MiriamData>(); @@ -220,9 +208,10 @@ public class KeggAnnotator extends ElementAnnotator implements IExternalService result.add(createMiriamData(MiriamType.PUBMED, m.group(1))); } + String organismParameter = params.getValue(AnnotatorParamDefinition.KEGG_ORGANISM_IDENTIFIER); //Retrieve homologous organisms based on parameterization - if (params != null) { - String[] keggOrgnismCodes = params.get(0).getParamValue().trim().split(" +"); + if (organismParameter != null) { + String[] keggOrgnismCodes = organismParameter.trim().split(" +"); for (String code: keggOrgnismCodes) { if (!code.equalsIgnoreCase("ATH")) { logger.warn("KEGG annotator currently supports only ATH (" + code + " passed)" ); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/PdbAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/PdbAnnotator.java index 0b9e8500275f6debfbbae765b6fd850ed6752b32..db62422078e18566bf888a42e5684578a2080bed 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/PdbAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/PdbAnnotator.java @@ -109,7 +109,7 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService { } @Override - public void annotateElement(BioEntity bioEntity) throws AnnotatorException { + public void annotateElement(BioEntity bioEntity, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(bioEntity)) { Set<MiriamData> mds = getUnitProts(bioEntity); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java index b41ee984effc76035b637aa4cb5a80f3b1deb11c..7db2b7b84b89fb9f31bc05aeb189ce28ca6bd5ae 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java @@ -114,7 +114,7 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService } @Override - public void annotateElement(BioEntity annotatedObject) throws AnnotatorException { + public void annotateElement(BioEntity annotatedObject, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(annotatedObject)) { String id = annotatedObject.getAbbreviation(); if (id == null || id.isEmpty()) { diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StitchAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StitchAnnotator.java index a5eaa3ffe96afa1d09763348e529482ee072e90c..1f76633264037f7e6fbeaca70f04c55c6f557988 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StitchAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StitchAnnotator.java @@ -58,7 +58,7 @@ public class StitchAnnotator extends ElementAnnotator implements IExternalServic } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { MiriamData mdChebi = null; diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StringAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StringAnnotator.java index 3893a948b9e24f06fc4cd51f8236359e373ad9f2..b331dc036870189d1e9fde6fce5b274e8383c3b7 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StringAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/StringAnnotator.java @@ -46,7 +46,7 @@ public class StringAnnotator extends ElementAnnotator implements IExternalServic } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { MiriamData mdTair = null; diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/TairAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/TairAnnotator.java index 66a49c98ed069145ee0d575e8beef7cdbcf193dd..89efd6e01ab1aa54701399c22dd5b8e1914d9062 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/TairAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/TairAnnotator.java @@ -75,7 +75,7 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { // boolean uniprotFound = false; List<MiriamData> mdUniProts = new ArrayList<MiriamData>(); //keeps record of existing UniProt annotations which can differ from those retrieved using TAIR diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java index 7eede10e1ad917b5c3ed8b2380e283ada3989335..15144d49cacdf5248e0c59acbe4e0c644c632b4e 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java @@ -93,7 +93,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi } @Override - public void annotateElement(BioEntity object) throws AnnotatorException { + public void annotateElement(BioEntity object, AnnotationParameters parameters) throws AnnotatorException { if (isAnnotatable(object)) { String uniprotId = object.getName(); boolean uniprotFound = false; diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java index b343f67f1db7df65a5a46d67d28dcc489d090d83..7467c92caa46534d503b52a55d8cffcd3fbebd8a 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java @@ -98,7 +98,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { } @Test - public void testAnnotateModelWithGivenAnnotators() { + public void testAnnotateModelWithGivenAnnotators() throws Exception { try { Model model = new ModelFullIndexed(null); GenericProtein species = new GenericProtein("id1"); @@ -117,8 +117,8 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { annotators.put(Reaction.class, annotatorList); annotators.put(GenericProtein.class, new ArrayList<>()); - ReconAnnotator reconMock = Mockito.mock(ReconAnnotator.class); - Mockito.doThrow(new AnnotatorException("")).when(reconMock).annotateElement(any()); + ReconAnnotator reconMock = Mockito.mock(ReconAnnotator.class, Mockito.CALLS_REAL_METHODS); + Mockito.doThrow(AnnotatorException.class).when(reconMock).annotateElement(any(),any()); annotators.get(Reaction.class).add(reconMock); modelAnnotator.annotateModel(model, updater, annotators); @@ -127,7 +127,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { } catch (Exception e) { e.printStackTrace(); - fail("Unknown exception"); + throw e; } } 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 ad8a63731459a40aedc769e86387edd3d43fc779..d30e43ae11d147a1020494813b00cdf72a0a520b 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 @@ -6,7 +6,7 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({ AnnotatorExceptionTest.class, - AnnotatorParamDefTest.class, + AnnotatorExceptionTest.class, BrendaAnnotatorTest.class, BiocompendiumAnnotatorTest.class, CazyAnnotatorTest.class, diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorExceptionTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorExceptionTest.java index 3001461019e5c2d007f7ecc8568b0155e0527c93..68f6a0176587ab7f5e5bdd4b25ba536c77c9b7ad 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorExceptionTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorExceptionTest.java @@ -23,10 +23,8 @@ public class AnnotatorExceptionTest { @Test public void testConstructor() { - AnnotatorParamDefinition d = new AnnotatorParamDefinition("name", String.class, "description"); - assertEquals(d.getName(), "name"); - assertEquals(d.getDescription(), "description"); - assertEquals(d.getType(), String.class); + AnnotatorException e = new AnnotatorException("messss"); + assertEquals("messss",e.getMessage()); } } diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParamDefTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParamDefTest.java deleted file mode 100644 index 90682ba6e3188646ab0fd3ec5a29f45775fbdac2..0000000000000000000000000000000000000000 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/AnnotatorParamDefTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package lcsb.mapviewer.annotation.services.annotators; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class AnnotatorParamDefTest { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testConstructor() { - AnnotatorException e = new AnnotatorException("messss"); - assertEquals("messss",e.getMessage()); - } - -} diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotatorTest.java index 5856154b2ee33753469ac6405ab3becd57b11d8c..7d97f4585b9600991e89e860ab4380f428b18207 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/KeggAnnotatorTest.java @@ -32,6 +32,7 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; import lcsb.mapviewer.model.user.UserAnnotatorsParam; public class KeggAnnotatorTest extends AnnotationTestFunctions { @@ -102,10 +103,9 @@ public class KeggAnnotatorTest extends AnnotationTestFunctions { protein.setName("bla"); protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "Q42561")); - UserAnnotatorsParam ap = new UserAnnotatorsParam(String.class, "KEGG organism identifier", "ATH"); - List<UserAnnotatorsParam> aps = new ArrayList<>(); - aps.add(ap); - keggAnnotator.annotateElement(protein, aps); + AnnotationParameters parameters = new AnnotationParameters() + .addAnnotatorParameter(AnnotatorParamDefinition.KEGG_ORGANISM_IDENTIFIER, "ATH"); + keggAnnotator.annotateElement(protein, parameters); int cntTairs = 0; for (MiriamData md : protein.getMiriamData()) { @@ -130,10 +130,9 @@ public class KeggAnnotatorTest extends AnnotationTestFunctions { protein.setName("bla"); protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "Q42561")); - UserAnnotatorsParam ap = new UserAnnotatorsParam(String.class, "XXX", "XXX"); - List<UserAnnotatorsParam> aps = new ArrayList<>(); - aps.add(ap); - keggAnnotator.annotateElement(protein, aps); + AnnotationParameters parameters = new AnnotationParameters() + .addAnnotatorParameter(AnnotatorParamDefinition.KEGG_ORGANISM_IDENTIFIER, "XXX"); + keggAnnotator.annotateElement(protein, parameters); assertEquals("There should be warning about unsupported parameter", 1, getWarnings().size()); @@ -150,9 +149,9 @@ public class KeggAnnotatorTest extends AnnotationTestFunctions { Species protein = new GenericProtein("id"); protein.setName("bla"); protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "Q42561")); - List<UserAnnotatorsParam> aps = new ArrayList<>(); - aps.add(new UserAnnotatorsParam(String.class, "KEGG organism identifier", "ATH AAA")); - keggAnnotator.annotateElement(protein, aps); + AnnotationParameters parameters = new AnnotationParameters() + .addAnnotatorParameter(AnnotatorParamDefinition.KEGG_ORGANISM_IDENTIFIER, "ATH AAA"); + keggAnnotator.annotateElement(protein, parameters); int cntTairs = 0; for (MiriamData md : protein.getMiriamData()) { @@ -365,7 +364,8 @@ public class KeggAnnotatorTest extends AnnotationTestFunctions { WebPageDownloader downloader = keggAnnotator.getWebPageDownloader(); try { WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); - when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException()); + when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))) + .thenThrow(new IOException()); keggAnnotator.setWebPageDownloader(mockDownloader); assertEquals(ExternalServiceStatusType.DOWN, keggAnnotator.getServiceStatus().getStatus()); } catch (Exception e) { diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/genome/UcscReferenceGenomeConnectorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/genome/UcscReferenceGenomeConnectorTest.java index c54e225ed7bbb125f4430ce8436b5b9a643359c4..ef6138383b8ff2e866f5e8cdfe6551343a8f3574 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/genome/UcscReferenceGenomeConnectorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/genome/UcscReferenceGenomeConnectorTest.java @@ -128,7 +128,7 @@ public class UcscReferenceGenomeConnectorTest extends AnnotationTestFunctions { MiriamData human = new MiriamData(MiriamType.TAXONOMY, "9606"); MiriamData chicken = new MiriamData(MiriamType.TAXONOMY, "9031"); List<MiriamData> list = connector.getAvailableOrganisms(); - assertTrue(list.size() > 40); + assertTrue("At least 40 different organism were expected but found: " + list.size(), list.size() > 40); assertTrue(list.contains(human)); assertTrue(list.contains(chicken)); @@ -148,7 +148,8 @@ public class UcscReferenceGenomeConnectorTest extends AnnotationTestFunctions { connector.setCache(null); WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); - when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException()); + when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))) + .thenThrow(new IOException()); connector.setWebPageDownloader(mockDownloader); connector.getAvailableOrganisms(); fail("Exception expected"); @@ -765,7 +766,8 @@ public class UcscReferenceGenomeConnectorTest extends AnnotationTestFunctions { // exclude first cached value connector.setCache(null); WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); - when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))).thenThrow(new IOException()); + when(mockDownloader.getFromNetwork(anyString(), anyString(), nullable(String.class))) + .thenThrow(new IOException()); connector.setWebPageDownloader(mockDownloader); connector.refreshCacheQuery("http://google.pl/"); fail("Exception expected"); diff --git a/model/src/main/java/lcsb/mapviewer/model/user/AnnotatorParamDefinition.java b/model/src/main/java/lcsb/mapviewer/model/user/AnnotatorParamDefinition.java new file mode 100644 index 0000000000000000000000000000000000000000..7377a7bfdda574209afa2a62e73a4361e43143c6 --- /dev/null +++ b/model/src/main/java/lcsb/mapviewer/model/user/AnnotatorParamDefinition.java @@ -0,0 +1,39 @@ +package lcsb.mapviewer.model.user; + +/** + * Definition of a single parameter of an annotator. + * + * @author David Hoksza + * + */ +public enum AnnotatorParamDefinition { + KEGG_ORGANISM_IDENTIFIER("KEGG organism identifier", + String.class, + "Space-delimited list of organisms codes for which homologous genes" + + " (GENE section in the KEGG enzyme record) should be imported." + + " Currently only ATH (Arabidopsis Thaliana) is supported."); + private String name; + + private String description; + + private Class<?> type; + + AnnotatorParamDefinition(String name, Class<?> type, String description) { + this.name = name; + this.description = description; + this.type = type; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public Class<?> getType() { + return type; + } + +} diff --git a/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotationSchema.java b/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotationSchema.java index 603eeb8d58c0ce8d1f7e72a0c23bb3bc4ef71fc7..cc1f2905218c8b9a8206457cf2d22ea1a189fd5b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotationSchema.java +++ b/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotationSchema.java @@ -238,7 +238,7 @@ public class UserAnnotationSchema implements Serializable { if (ap.getAnnotatorClassName() == null) { throw new InvalidArgumentException("Class name cannot be null"); } - if (ap.getParamName() == null) { + if (ap.getParameterType() == null) { throw new InvalidArgumentException("Parameter name cannot be null"); } if (ap.getParamValue() == null) { @@ -248,7 +248,7 @@ public class UserAnnotationSchema implements Serializable { for (int i = 0; i < this.annotatorsParams.size(); i++) { UserAnnotatorsParam params = this.annotatorsParams.get(i); if (params.getAnnotatorClassName().equals(ap.getAnnotatorClassName()) - && params.getParamName().equals(ap.getParamName())) { + && params.getParameterType().equals(ap.getParameterType())) { this.annotatorsParams.get(i).setParamValue(ap.getParamValue()); return; } diff --git a/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java b/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java index 787ba75e919dfcc69df14b13f4bb4111c9153276..1cd9d1986c9c26e34299dcfa99e2906f99f9350c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java +++ b/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java @@ -4,6 +4,8 @@ import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -38,8 +40,8 @@ public class UserAnnotatorsParam implements Serializable { private UserAnnotationSchema annotationSchema; /** - * Class name of the annotator {@link #paramName parameter} of which is being - * set to the {@link #paramValue value}. + * Class name of the annotator {@link #parameterType parameter} of which is + * being set to the {@link #paramValue value}. */ @Column(nullable = false) private Class<?> annotatorClassName; @@ -48,7 +50,8 @@ public class UserAnnotatorsParam implements Serializable { * Parameter name to be set. */ @Column(nullable = false) - private String paramName; + @Enumerated(EnumType.STRING) + private AnnotatorParamDefinition parameterType; /** * Parameter value to be set. @@ -71,9 +74,9 @@ public class UserAnnotatorsParam implements Serializable { * @param annotators * {@link #annotators} */ - public UserAnnotatorsParam(Class<?> annotatorClassName, String paramName, String paramValue) { + public UserAnnotatorsParam(Class<?> annotatorClassName, AnnotatorParamDefinition parameterType, String paramValue) { setAnnotatorClassName(annotatorClassName); - setParamName(paramName); + setParameterType(parameterType); setParamValue(paramValue); } @@ -129,19 +132,19 @@ public class UserAnnotatorsParam implements Serializable { } /** - * @return the parameter name - * @see #paramName + * @return the parameter type + * @see #parameterType */ - public String getParamName() { - return paramName; + public AnnotatorParamDefinition getParameterType() { + return parameterType; } /** * @param paramName - * the {@link UserAnnotatorsParam#paramName} to set + * the {@link UserAnnotatorsParam#parameterType} to set */ - public void setParamName(String paramName) { - this.paramName = paramName; + public void setParameterType(AnnotatorParamDefinition paramName) { + this.parameterType = paramName; } /** diff --git a/persist/src/main/resources/db/migration/12.3.0~alpha.0/V12.3.0.20190124__annotation_paramteres_refactor.sql b/persist/src/main/resources/db/migration/12.3.0~alpha.0/V12.3.0.20190124__annotation_paramteres_refactor.sql new file mode 100644 index 0000000000000000000000000000000000000000..c54fc9a12d69291a8cc03a7630903a7b2f94436b --- /dev/null +++ b/persist/src/main/resources/db/migration/12.3.0~alpha.0/V12.3.0.20190124__annotation_paramteres_refactor.sql @@ -0,0 +1,3 @@ +--create font color +update user_annotators_param_table set param_name = 'KEGG_ORGANISM_IDENTIFIER' where param_name='KEGG organism identifier'; +alter table user_annotators_param_table rename column param_name to parameter_type; diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java index e35c3001917c347644e50d998bd9c764d46ab07d..8d996cb52e7c272d1df7096b047c79d5feb14160 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java @@ -19,6 +19,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; import lcsb.mapviewer.model.user.Privilege; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; @@ -275,7 +276,7 @@ public class UserDaoTest extends PersistTestFunctions { user.setAnnotationSchema(uas); UserAnnotatorsParam param = new UserAnnotatorsParam(); param.setAnnotatorClassName(String.class); - param.setParamName("nam"); + param.setParameterType(AnnotatorParamDefinition.KEGG_ORGANISM_IDENTIFIER); param.setParamValue("val"); uas.addAnnotatorParam(param); userDao.add(user); diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java index d1c3f427d40e41ca5755eab3a7668fa1387d3478..32f89462a3a5d1e0d8c3352256dc73de1e355336 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/users/UserRestImpl.java @@ -21,6 +21,7 @@ import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.user.AnnotatorParamDefinition; import lcsb.mapviewer.model.user.ConfigurationOption; import lcsb.mapviewer.model.user.ObjectPrivilege; import lcsb.mapviewer.model.user.Privilege; @@ -188,7 +189,7 @@ public class UserRestImpl extends BaseRestImpl { annotatorParams = new TreeMap<>(); result.put(className, annotatorParams); } - annotatorParams.put(param.getParamName(), param.getParamValue()); + annotatorParams.put(param.getParameterType().name(), param.getParamValue()); } return result; } @@ -227,7 +228,7 @@ public class UserRestImpl extends BaseRestImpl { for (String name : nameValueS.keySet()) { String value = (String) nameValueS.get(name); try { - UserAnnotatorsParam param = new UserAnnotatorsParam(Class.forName(annotatorClassname), name, value); + UserAnnotatorsParam param = new UserAnnotatorsParam(Class.forName(annotatorClassname), AnnotatorParamDefinition.valueOf(name), value); schema.addAnnotatorParam(param); } catch (ClassNotFoundException e) { throw new QueryException("Unknown annotator class name: " + annotatorClassname);