Commit 3fb09925 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '487-custom-images-as-overlay-levels-or-background' into 'master'

Resolve "Custom images as overlay levels  or background"

Closes #487

See merge request !768
parents 4c305a38 cd1ab9fd
Pipeline #10187 passed with stage
in 15 minutes and 55 seconds
......@@ -3,6 +3,9 @@ minerva (13.1.0~alpha.0) unstable; urgency=low
outputs used by annotator (#617)
* Feature: changes in admin panel doesn't require saving - they are saved
automatically (#676)
* Feature: elements can have custom glyphs used for visualization (#487)
* Small improvement: all bio entities have z-index associated with them
(#487)
* Small improvement: validation of the organism and disease id on map upload
added (#618)
* Small improvement: added current username next to logout button in admin
......@@ -48,6 +51,8 @@ minerva (13.1.0~alpha.0) unstable; urgency=low
* Small improvement: allow admin to disable CORS check (#802)
* Small improvement: TransparencyZoomLevelVisibility parameter renamed to
SemanticZoomLevelTransparency (#801)
* Small improvement: export/import from SBML support z-index in LAYOUT
extension
* Bug fix: progress bar of gene genome mapping upload is refreshing properly
(#728)
* Bug fix: when editing project Disease and Organism could not be removed
......
......@@ -8,7 +8,10 @@ import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.NotImplementedException;
public abstract class Comparator<T extends Object> implements java.util.Comparator<T> {
Logger logger = Logger.getLogger(Comparator.class);
/**
* Default class logger.
*/
private static Logger logger = Logger.getLogger(Comparator.class);
private Class<T> comparatorClazz;
private boolean exactClassMatch;
private List<Comparator<? extends T>> subClassComparatorList = new ArrayList<>();
......
......@@ -10,18 +10,18 @@ import java.util.Comparator;
*/
public class IntegerComparator implements Comparator<Integer> {
@Override
public int compare(Integer arg0, Integer arg1) {
if (arg0 == null) {
if (arg1 == null) {
return 0;
} else {
return 1;
}
} else if (arg1 == null) {
return -1;
}
return arg0.compareTo(arg1);
}
@Override
public int compare(Integer arg0, Integer arg1) {
if (arg0 == null) {
if (arg1 == null) {
return 0;
} else {
return 1;
}
} else if (arg1 == null) {
return -1;
}
return arg0.compareTo(arg1);
}
}
......@@ -22,6 +22,7 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.converter.ZIndexPopulator;
import lcsb.mapviewer.converter.annotation.XmlAnnotationParser;
import lcsb.mapviewer.converter.model.celldesigner.alias.AliasCollectionXmlParser;
import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
......@@ -144,7 +145,10 @@ public class CellDesignerXmlParser extends Converter {
}
// we ignore metaid - it's useless and obstruct data model
// model.setMetaId(XmlParser.getNodeAttr("metaId", modelNode));
model.setIdModel(XmlParser.getNodeAttr("id", modelNode));
String modelId = XmlParser.getNodeAttr("id", modelNode);
if (modelId != null && !modelId.isEmpty()) {
model.setIdModel(modelId);
}
Node compartmentNode = XmlParser.getNode("listOfCompartments", modelNode.getChildNodes());
if (compartmentNode != null) {
......@@ -236,6 +240,7 @@ public class CellDesignerXmlParser extends Converter {
model.setWidth(width);
model.setHeight(height);
}
new ZIndexPopulator().populateZIndex(model);
} catch (InvalidXmlSchemaException e) {
throw new InvalidInputDataExecption(e);
} catch (CellDesignerParserException e) {
......@@ -610,7 +615,11 @@ public class CellDesignerXmlParser extends Converter {
+ "xmlns:celldesigner=\"http://www.sbml.org/2001/ns/celldesigner\" level=\"2\" version=\"4\">\n");
// metaid is a string cell designer id, usually it's model id and as far as
// we can tell it's not used at all
result.append("<model metaid=\"" + model.getIdModel() + "\" id=\"" + model.getIdModel() + "\">\n");
result.append("<model ");
if (model.getIdModel() != null) {
result.append("metaid=\"" + model.getIdModel() + "\" id=\"" + model.getIdModel() + "\"");
}
result.append(">\n");
result.append(unitCollectionXmlParser.toXml(model.getUnits()));
result.append(functionCollectionXmlParser.toXml(model.getFunctions()));
......@@ -697,7 +706,8 @@ public class CellDesignerXmlParser extends Converter {
result.append("</celldesigner:extension>\n");
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser();
result.append(xmlAnnotationParser.dataSetToXmlString(model.getMiriamData(), model.getAuthors(), model.getCreationDate(), model.getModificationDates()));
result.append(xmlAnnotationParser.dataSetToXmlString(model.getMiriamData(), model.getAuthors(),
model.getCreationDate(), model.getModificationDates()));
result.append("</annotation>\n");
return result.toString();
}
......
......@@ -3,7 +3,7 @@ package lcsb.mapviewer.converter.model.celldesigner;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
/**
* Exception that shold be thrown when the group in xml schema is invalid.
* Exception that should be thrown when the group in xml schema is invalid.
*
* @author Piotr Gawron
*
......@@ -20,7 +20,7 @@ public class InvalidGroupException extends InvalidXmlSchemaException {
*/
public InvalidGroupException() {
super(); // call superclass constructor
super();
}
/**
......
......@@ -13,6 +13,7 @@ import org.w3c.dom.NodeList;
import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.common.geometry.ColorParser;
import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
import lcsb.mapviewer.model.graphics.ArrowType;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.graphics.PolylineData;
......@@ -522,6 +523,7 @@ public class LayerXmlParser {
}
}
}
new RestAnnotationParser().processNotes(result.getNotes(), result);
return result;
}
......
package lcsb.mapviewer.converter.model.celldesigner.annotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(FIELD)
public @interface ImportOnly {
}
package lcsb.mapviewer.converter.model.celldesigner.annotation;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.Drawable;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Element;
......@@ -15,193 +14,197 @@ import lcsb.mapviewer.model.map.species.Species;
*
*/
public enum NoteField {
/**
* List of {@link MiriamType#HGNC} identifiers.
*/
HGNC("HGNC_ID", BioEntity.class, MiriamType.HGNC),
/**
* List of {@link MiriamType#REFSEQ} identifiers.
*/
REFSEQ("RefSeq_ID", BioEntity.class, MiriamType.REFSEQ),
/**
* List of {@link MiriamType#ENTREZ} identifiers.
*/
ENTREZ("EntrezGene_ID", BioEntity.class, MiriamType.ENTREZ),
/**
* List of {@link MiriamType#REACTOME} identifiers.
*/
REACTOME("Reactome_ID", BioEntity.class, MiriamType.REACTOME),
/**
* List of {@link MiriamType#PUBMED} identifiers.
*/
PUBMED("Pubmed_ID", BioEntity.class, MiriamType.PUBMED),
/**
* List of {@link MiriamType#KEGG_GENES} identifiers.
*/
KEGG_GENES("KEGG_ID", BioEntity.class, MiriamType.KEGG_GENES),
/**
* List of {@link MiriamType#PANTHER} identifiers.
*/
PANTHER("PANTHER", BioEntity.class, MiriamType.PANTHER),
/**
* {@link Element#symbol}.
*/
SYMBOL("Symbol", CellDesignerElement.class, null),
/**
* {@link Element#fullName}.
*/
NAME("Name", CellDesignerElement.class, null),
/**
* {@link Element#notes} or {@link Reaction#notes} .
*/
DESCRIPTION("Description", BioEntity.class, null),
/**
* {@link Element#formerSymbols}.
*/
PREVIOUS_SYMBOLS("Previous Symbols", CellDesignerElement.class, null),
/**
* {@link Element#synonyms} or {@link Reaction#synonyms}.
*/
SYNONYMS("Synonyms", BioEntity.class, null),
/**
* {@link Element#abbreviation} or {@link Reaction#abbreviation}.
*/
ABBREVIATION("Abbreviation", BioEntity.class, null),
/**
* {@link Reaction#formula}.
*/
FORMULA("Formula", Reaction.class, null),
/**
* {@link Reaction#mechanicalConfidenceScore}.
*/
MECHANICAL_CONFIDENCE_SCORE("MechanicalConfidenceScore", Reaction.class, null),
/**
* {@link Reaction#lowerBound}.
*/
LOWER_BOUND("LowerBound", Reaction.class, null),
/**
* {@link Reaction#upperBound}.
*/
UPPER_BOUND("UpperBound", Reaction.class, null),
/**
* {@link Reaction#subsystem}.
*/
SUBSYSTEM("Subsystem", Reaction.class, null),
/**
* {@link Reaction#geneProteinReaction}.
*/
GENE_PROTEIN_REACTION("GeneProteinReaction", Reaction.class, null),
/**
* {@link Element#formula}.
*/
CHARGED_FORMULA("ChargedFormula", CellDesignerElement.class, null),
/**
* {@link Species#charge}.
*/
CHARGE("Charge", CellDesignerSpecies.class, null),
/**
* {@link Element#getSemanticZoomLevelVisibility()}.
*/
SEMANTIC_ZOOM_LEVEL_VISIBILITY("SemanticZoomLevelVisibility", BioEntity.class, null),
/**
* {@link Element#getSemanticZoomLevelVisibility()}.
*/
TRANSPARENCY_ZOOM_LEVEL_VISIBILITY("SemanticZoomLevelTransparency", Element.class, null),
/**
* {@link Element#getSemanticZoomLevelVisibility()}.
*/
@Deprecated
TRANSPARENCY_ZOOM_LEVEL_VISIBILITY_OLD("TransparencyZoomLevelVisibility", Element.class, null),
;
/**
* Name used in the notes to distinguish fields.
*/
private String commonName;
/**
* What object class can have this field.
*/
private Class<?> clazz;
/**
* What {@link MiriamType} is associated with the field.
*/
private MiriamType miriamType;
/**
* Default constructor.
*
* @param name
* {@link #commonName}
* @param clazz
* {@link #clazz}
*/
NoteField(String name, Class<?> clazz) {
this.commonName = name;
this.clazz = clazz;
}
/**
* Default constructor.
*
* @param name
* {@link #commonName}
* @param clazz
* {@link #clazz}
* @param type
* {@link #miriamType}
*/
NoteField(String name, Class<?> clazz, MiriamType type) {
this(name, clazz);
this.miriamType = type;
}
/**
* @return the miriamType
* @see #miriamType
*/
public MiriamType getMiriamType() {
return miriamType;
}
/**
* @return the commonName
* @see #commonName
*/
public String getCommonName() {
return commonName;
}
/**
* @return the clazz
* @see #clazz
*/
public Class<?> getClazz() {
return clazz;
}
/**
* List of {@link MiriamType#HGNC} identifiers.
*/
HGNC("HGNC_ID", BioEntity.class, MiriamType.HGNC),
/**
* List of {@link MiriamType#REFSEQ} identifiers.
*/
REFSEQ("RefSeq_ID", BioEntity.class, MiriamType.REFSEQ),
/**
* List of {@link MiriamType#ENTREZ} identifiers.
*/
ENTREZ("EntrezGene_ID", BioEntity.class, MiriamType.ENTREZ),
/**
* List of {@link MiriamType#REACTOME} identifiers.
*/
REACTOME("Reactome_ID", BioEntity.class, MiriamType.REACTOME),
/**
* List of {@link MiriamType#PUBMED} identifiers.
*/
PUBMED("Pubmed_ID", BioEntity.class, MiriamType.PUBMED),
/**
* List of {@link MiriamType#KEGG_GENES} identifiers.
*/
KEGG_GENES("KEGG_ID", BioEntity.class, MiriamType.KEGG_GENES),
/**
* List of {@link MiriamType#PANTHER} identifiers.
*/
PANTHER("PANTHER", BioEntity.class, MiriamType.PANTHER),
/**
* {@link Element#symbol}.
*/
SYMBOL("Symbol", BioEntity.class, null),
/**
* {@link Element#fullName}.
*/
NAME("Name", BioEntity.class, null),
/**
* {@link Element#notes} or {@link Reaction#notes} .
*/
DESCRIPTION("Description", BioEntity.class, null),
/**
* {@link Element#formerSymbols}.
*/
PREVIOUS_SYMBOLS("Previous Symbols", Element.class, null),
/**
* {@link Element#synonyms} or {@link Reaction#synonyms}.
*/
SYNONYMS("Synonyms", BioEntity.class, null),
/**
* {@link Element#abbreviation} or {@link Reaction#abbreviation}.
*/
ABBREVIATION("Abbreviation", BioEntity.class, null),
/**
* {@link Reaction#formula}.
*/
FORMULA("Formula", Reaction.class, null),
/**
* {@link Reaction#mechanicalConfidenceScore}.
*/
MECHANICAL_CONFIDENCE_SCORE("MechanicalConfidenceScore", Reaction.class, null),
/**
* {@link Reaction#lowerBound}.
*/
LOWER_BOUND("LowerBound", Reaction.class, null),
/**
* {@link Reaction#upperBound}.
*/
UPPER_BOUND("UpperBound", Reaction.class, null),
/**
* {@link Reaction#subsystem}.
*/
SUBSYSTEM("Subsystem", Reaction.class, null),
/**
* {@link Reaction#geneProteinReaction}.
*/
GENE_PROTEIN_REACTION("GeneProteinReaction", Reaction.class, null),
/**
* {@link Element#formula}.
*/
CHARGED_FORMULA("ChargedFormula", Element.class, null),
/**
* {@link Species#charge}.
*/
CHARGE("Charge", Species.class, null),
/**
* {@link Element#getSemanticZoomLevelVisibility()}.
*/
SEMANTIC_ZOOM_LEVEL_VISIBILITY("SemanticZoomLevelVisibility", BioEntity.class, null),
/**
* {@link Element#getSemanticZoomLevelVisibility()}.
*/
TRANSPARENCY_ZOOM_LEVEL_VISIBILITY("SemanticZoomLevelTransparency", Element.class, null),
/**
* {@link Element#getSemanticZoomLevelVisibility()}.
*/
@Deprecated
TRANSPARENCY_ZOOM_LEVEL_VISIBILITY_OLD("TransparencyZoomLevelVisibility", Element.class, null),
@ImportOnly
Z_INDEX("Z-Index", Drawable.class, null),
;
/**
* Name used in the notes to distinguish fields.
*/
private String commonName;
/**
* What object class can have this field.
*/
private Class<? extends Drawable> clazz;
/**
* What {@link MiriamType} is associated with the field.
*/
private MiriamType miriamType;
/**
* Default constructor.
*
* @param name
* {@link #commonName}
* @param clazz
* {@link #clazz}
*/
NoteField(String name, Class<? extends Drawable> clazz) {
this.commonName = name;
this.clazz = clazz;
}
/**
* Default constructor.
*
* @param name
* {@link #commonName}
* @param clazz
* {@link #clazz}
* @param type
* {@link #miriamType}
*/
NoteField(String name, Class<? extends Drawable> clazz, MiriamType type) {
this(name, clazz);
this.miriamType = type;
}
/**
* @return the miriamType
* @see #miriamType
*/