From dbab29aefe57bf2bb25413331ec69b2bdf0e2e64 Mon Sep 17 00:00:00 2001 From: "piotr.gawron" <piotr.gawron@uni-new> Date: Wed, 21 Sep 2016 12:59:16 +0200 Subject: [PATCH] clicking on reaction in submaps didn't work --- CHANGELOG | 3 +- .../services/search/data/FullAliasView.java | 1281 ++++++++--------- .../search/data/FullAliasViewFactory.java | 604 ++++---- .../java/lcsb/mapviewer/bean/SearchBean.java | 25 +- .../resources/pfcomp/aliasSearchElement.xhtml | 9 +- 5 files changed, 935 insertions(+), 987 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 316bded663..2840325170 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,8 +3,9 @@ minerva (10.0.1) unstable; urgency=medium * Bug fix: export to image * Bug fix: trigger reaction and physical stimulation reactions are no longer allowed (CellDesigner data model issue) + * Bug fix: clicking on reactions in submaps - -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 16 Sep 2016 13:01:16 +0200 + -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 21 Sep 2016 13:01:16 +0200 minerva (10) stable; urgency=medium diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java index 3c828f6ed2..8268fbbb96 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java @@ -1,663 +1,618 @@ -package lcsb.mapviewer.services.search.data; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.model.map.Element; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.species.Species; -import lcsb.mapviewer.services.search.IHeavyView; -import lcsb.mapviewer.services.view.AnnotationView; -import lcsb.mapviewer.services.view.DataMiningView; - -/** - * Heavy {@link LightAliasView view} for alias representing data that should be - * sent to client. - * - * @author Piotr Gawron - * - */ -public class FullAliasView extends LightAliasView implements IHeavyView { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(FullAliasView.class); - - /** - * This class represents posttransational modification of the element. - * - * @author Piotr Gawron - * - */ - public static class PosttransationalModification implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Name of the modification. - */ - private String name; - - /** - * Position where the modification occurred. - */ - private String position; - - /** - * @return the name - * @see #name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - * @see #name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the position - * @see #position - */ - public String getPosition() { - return position; - } - - /** - * @param position - * the position to set - * @see #position - */ - public void setPosition(String position) { - this.position = position; - } - } - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Description. - * - * @see Element#notes - */ - private String notes; - - /** - * Type of the alias. - * - * @see Element#getStringType() - */ - private String type; - - /** - * Symbol of the element. - * - * @see Element#symbol - */ - private String symbol; - - /** - * Full name of the element. - * - * @see Element#fullName - */ - private String fullName; - - /** - * Abbreviation of the element. - * - * @see Element#abbreviation - */ - private String abbreviation; - - /** - * Formula describing the element. - * - * @see Element#formula - */ - private String formula; - - /** - * Charge of the element. - * - * @see Species#charge - */ - private Integer charge; - - /** - * Initial amount of species. - * - * @see Species#initialAmount - */ - private Integer initialAmount = null; - - /** - * Initial concentration of species. - * - * @see Species#initialConcentration - */ - private Integer initialConcentration = null; - - /** - * Is only substance units allowed in a species. - * - * @see Species#onlySubstanceUnits - */ - private Boolean onlySubstanceUnits = null; - - /** - * Name of the element. - * - * @see Element#name - */ - private String name = ""; - - /** - * Name of the {@link Element#model}. - */ - private String modelName; - - /** - * Name of the {@link Alias#submodel}. - */ - private String submodelName; - - /** - * Id of the {@link Alias#submodel}. - */ - private String submodelId; - - /** - * List of synonyms of the element. - * - * @see Element#synonyms - */ - private List<String> synonyms = new ArrayList<>(); - - /** - * List of former symbols used by the entity represented by this element. - * - * @see Element#formerSymbols - */ - private List<String> formerSymbols = new ArrayList<>(); - - /** - * List of references for this element. - * - * @see Element#miriamData - */ - private List<AnnotationView> references = new ArrayList<>(); - - /** - * List of other unstructurized feuters, specific for some subclases of Alias. - * - */ - private Map<String, Object> other = new HashMap<>(); - - /** - * Array with data mining entries. - */ - private List<List<DataMiningView>> dataMining = new ArrayList<>(); - - /** - * List of data mining types. - */ - private List<AnnotationView> dataMiningColumns = new ArrayList<>(); - - /** - * Default constructor. - * - * @param alias - * original object from which this element is created - * @param icon - * string with icon that should be used to visualize this alias - */ - protected FullAliasView(Alias alias, String icon) { - super(alias, icon); - setModelName(alias.getModel().getName()); - if (alias instanceof CompartmentAlias) { - setName(((CompartmentAlias) alias).getTitle()); - } - Element element = alias.getElement(); - if (element != null) { - setAbbreviation(element.getAbbreviation()); - addFormerSymbols(element.getFormerSymbols()); - setFormula(element.getFormula()); - setFullName(element.getFullName()); - setName(element.getName()); - setNotes(element.getNotes()); - setSymbol(element.getSymbol()); - addSynonyms(element.getSynonyms()); - setType(element.getStringType()); - if (element instanceof Species) { - Species species = (Species) element; - setCharge(species.getCharge()); - setInitialAmount(species.getInitialAmount()); - setInitialConcentration(species.getInitialConcentration()); - setOnlySubstanceUnits(species.getOnlySubstanceUnits()); - if (alias.getSubmodel() != null && alias.getSubmodel().getSubmodel() != null) { - setSubmodelName(alias.getSubmodel().getSubmodel().getName()); - setSubmodelId(alias.getSubmodel().getSubmodel().getId() + ""); - } - } - } - } - - /** - * Constructor that should be used only by the deserialization method. - */ - protected FullAliasView() { - } - - /** - * Adds elements to {@link #synonyms} list. - * - * @param synonyms2 - * list of elements to add - */ - private void addSynonyms(List<String> synonyms2) { - synonyms.addAll(synonyms2); - } - - /** - * Adds elements to {@link #formerSymbols} list. - * - * @param formerSymbols2 - * list of elements to add - */ - private void addFormerSymbols(List<String> formerSymbols2) { - formerSymbols.addAll(formerSymbols2); - } - - /** - * @return the notes - * @see #notes - */ - public String getNotes() { - return notes; - } - - /** - * @param notes - * the notes to set - * @see #notes - */ - public void setNotes(String notes) { - this.notes = notes; - } - - /** - * @return the symbol - * @see #symbol - */ - public String getSymbol() { - return symbol; - } - - /** - * @param symbol - * the symbol to set - * @see #symbol - */ - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - /** - * @return the fullName - * @see #fullName - */ - public String getFullName() { - return fullName; - } - - /** - * @param fullName - * the fullName to set - * @see #fullName - */ - public void setFullName(String fullName) { - this.fullName = fullName; - } - - /** - * @return the abbreviation - * @see #abbreviation - */ - public String getAbbreviation() { - return abbreviation; - } - - /** - * @param abbreviation - * the abbreviation to set - * @see #abbreviation - */ - public void setAbbreviation(String abbreviation) { - this.abbreviation = abbreviation; - } - - /** - * @return the formula - * @see #formula - */ - public String getFormula() { - return formula; - } - - /** - * @param formula - * the formula to set - * @see #formula - */ - public void setFormula(String formula) { - this.formula = formula; - } - - /** - * @return the name - * @see #name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - * @see #name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the synonyms - * @see #synonyms - */ - public List<String> getSynonyms() { - return synonyms; - } - - /** - * @param synonyms - * the synonyms to set - * @see #synonyms - */ - public void setSynonyms(List<String> synonyms) { - this.synonyms = synonyms; - } - - /** - * @return the formerSymbols - * @see #formerSymbols - */ - public List<String> getFormerSymbols() { - return formerSymbols; - } - - /** - * @param formerSymbols - * the formerSymbols to set - * @see #formerSymbols - */ - public void setFormerSymbols(List<String> formerSymbols) { - this.formerSymbols = formerSymbols; - } - - /** - * @return the references - * @see #references - */ - public List<AnnotationView> getReferences() { - return references; - } - - /** - * @param references - * the references to set - * @see #references - */ - public void setReferences(List<AnnotationView> references) { - this.references = references; - } - - /** - * @return the other - * @see #other - */ - public Map<String, Object> getOther() { - return other; - } - - /** - * Returns other (additional element) by the name. - * - * @param key - * key identifing the feature. - * @return other (additional element) by the name - */ - public Object getOther(String key) { - return other.get(key); - } - - /** - * @param other - * the other to set - * @see #other - */ - public void setOther(Map<String, Object> other) { - this.other = other; - } - - /** - * @return the type - * @see #type - */ - public String getType() { - return type; - } - - /** - * @param type - * the type to set - * @see #type - */ - public void setType(String type) { - this.type = type; - } - - /** - * Adds elements to {@link #references} list. - * - * @param newReferences - * list of elements to add - */ - public void addReferences(List<AnnotationView> newReferences) { - references.addAll(newReferences); - } - - /** - * @return the dataMining - * @see #dataMining - */ - public List<List<DataMiningView>> getDataMining() { - return dataMining; - } - - /** - * @param dataMining - * the dataMining to set - * @see #dataMining - */ - public void setDataMining(List<List<DataMiningView>> dataMining) { - this.dataMining = dataMining; - } - - /** - * @return the dataMiningColumns - * @see #dataMiningColumns - */ - public List<AnnotationView> getDataMiningColumns() { - return dataMiningColumns; - } - - /** - * @param dataMiningColumns - * the dataMiningColumns to set - * @see #dataMiningColumns - */ - public void setDataMiningColumns(List<AnnotationView> dataMiningColumns) { - this.dataMiningColumns = dataMiningColumns; - } - - /** - * Addsother (additional element) by the name. - * - * @param key - * name of the feature - * @param value - * object representing data of the feature - */ - public void addOther(String key, Object value) { - other.put(key, value); - } - - /** - * @return the modelName - * @see #modelName - */ - public String getModelName() { - return modelName; - } - - /** - * @param modelName - * the modelName to set - * @see #modelName - */ - public void setModelName(String modelName) { - this.modelName = modelName; - } - - /** - * @return the charge - * @see #charge - */ - public Integer getCharge() { - return charge; - } - - /** - * @param charge - * the charge to set - * @see #charge - */ - public void setCharge(Integer charge) { - this.charge = charge; - } - - /** - * @return the initialAmount - * @see #initialAmount - */ - public Integer getInitialAmount() { - return initialAmount; - } - - /** - * @param initialAmount - * the initialAmount to set - * @see #initialAmount - */ - public void setInitialAmount(Integer initialAmount) { - this.initialAmount = initialAmount; - } - - /** - * @return the initialConcentration - * @see #initialConcentration - */ - public Integer getInitialConcentration() { - return initialConcentration; - } - - /** - * @param initialConcentration - * the initialConcentration to set - * @see #initialConcentration - */ - public void setInitialConcentration(Integer initialConcentration) { - this.initialConcentration = initialConcentration; - } - - /** - * @return the onlySubstanceUnits - * @see #onlySubstanceUnits - */ - public Boolean getOnlySubstanceUnits() { - return onlySubstanceUnits; - } - - /** - * @param onlySubstanceUnits - * the onlySubstanceUnits to set - * @see #onlySubstanceUnits - */ - public void setOnlySubstanceUnits(Boolean onlySubstanceUnits) { - this.onlySubstanceUnits = onlySubstanceUnits; - } - - /** - * @return the submodelName - * @see #submodelName - */ - public String getSubmodelName() { - return submodelName; - } - - /** - * @param submodelName - * the submodelName to set - * @see #submodelName - */ - public void setSubmodelName(String submodelName) { - this.submodelName = submodelName; - } - - /** - * @return the submodelId - * @see #submodelId - */ - public String getSubmodelId() { - return submodelId; - } - - /** - * @param submodelId - * the submodelId to set - * @see #submodelId - */ - public void setSubmodelId(String submodelId) { - this.submodelId = submodelId; - } -} +package lcsb.mapviewer.services.search.data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import lcsb.mapviewer.model.map.Element; +import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.services.search.IHeavyView; +import lcsb.mapviewer.services.view.AnnotationView; + +/** + * Heavy {@link LightAliasView view} for alias representing data that should be + * sent to client. + * + * @author Piotr Gawron + * + */ +public class FullAliasView extends LightAliasView implements IHeavyView { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(FullAliasView.class); + + /** + * This class represents posttransational modification of the element. + * + * @author Piotr Gawron + * + */ + public static class PosttransationalModification implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Name of the modification. + */ + private String name; + + /** + * Position where the modification occurred. + */ + private String position; + + /** + * @return the name + * @see #name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + * @see #name + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the position + * @see #position + */ + public String getPosition() { + return position; + } + + /** + * @param position + * the position to set + * @see #position + */ + public void setPosition(String position) { + this.position = position; + } + } + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Description. + * + * @see Element#notes + */ + private String notes; + + /** + * Type of the alias. + * + * @see Element#getStringType() + */ + private String type; + + /** + * Symbol of the element. + * + * @see Element#symbol + */ + private String symbol; + + /** + * Full name of the element. + * + * @see Element#fullName + */ + private String fullName; + + /** + * Abbreviation of the element. + * + * @see Element#abbreviation + */ + private String abbreviation; + + /** + * Formula describing the element. + * + * @see Element#formula + */ + private String formula; + + /** + * Charge of the element. + * + * @see Species#charge + */ + private Integer charge; + + /** + * Initial amount of species. + * + * @see Species#initialAmount + */ + private Integer initialAmount = null; + + /** + * Initial concentration of species. + * + * @see Species#initialConcentration + */ + private Integer initialConcentration = null; + + /** + * Is only substance units allowed in a species. + * + * @see Species#onlySubstanceUnits + */ + private Boolean onlySubstanceUnits = null; + + /** + * Name of the element. + * + * @see Element#name + */ + private String name = ""; + + /** + * Name of the {@link Element#model}. + */ + private String modelName; + + /** + * Name of the {@link Alias#submodel}. + */ + private String submodelName; + + /** + * Id of the {@link Alias#submodel}. + */ + private String submodelId; + + /** + * List of synonyms of the element. + * + * @see Element#synonyms + */ + private List<String> synonyms = new ArrayList<>(); + + /** + * List of former symbols used by the entity represented by this element. + * + * @see Element#formerSymbols + */ + private List<String> formerSymbols = new ArrayList<>(); + + /** + * List of references for this element. + * + * @see Element#miriamData + */ + private List<AnnotationView> references = new ArrayList<>(); + + /** + * List of other unstructurized feuters, specific for some subclases of Alias. + * + */ + private Map<String, Object> other = new HashMap<>(); + + /** + * Default constructor. + * + * @param alias + * original object from which this element is created + * @param icon + * string with icon that should be used to visualize this alias + */ + protected FullAliasView(Alias alias, String icon) { + super(alias, icon); + setModelName(alias.getModel().getName()); + if (alias instanceof CompartmentAlias) { + setName(((CompartmentAlias) alias).getTitle()); + } + Element element = alias.getElement(); + if (element != null) { + setAbbreviation(element.getAbbreviation()); + addFormerSymbols(element.getFormerSymbols()); + setFormula(element.getFormula()); + setFullName(element.getFullName()); + setName(element.getName()); + setNotes(element.getNotes()); + setSymbol(element.getSymbol()); + addSynonyms(element.getSynonyms()); + setType(element.getStringType()); + if (element instanceof Species) { + Species species = (Species) element; + setCharge(species.getCharge()); + setInitialAmount(species.getInitialAmount()); + setInitialConcentration(species.getInitialConcentration()); + setOnlySubstanceUnits(species.getOnlySubstanceUnits()); + if (alias.getSubmodel() != null && alias.getSubmodel().getSubmodel() != null) { + setSubmodelName(alias.getSubmodel().getSubmodel().getName()); + setSubmodelId(alias.getSubmodel().getSubmodel().getId() + ""); + } + } + } + } + + /** + * Constructor that should be used only by the deserialization method. + */ + protected FullAliasView() { + } + + /** + * Adds elements to {@link #synonyms} list. + * + * @param synonyms2 + * list of elements to add + */ + private void addSynonyms(List<String> synonyms2) { + synonyms.addAll(synonyms2); + } + + /** + * Adds elements to {@link #formerSymbols} list. + * + * @param formerSymbols2 + * list of elements to add + */ + private void addFormerSymbols(List<String> formerSymbols2) { + formerSymbols.addAll(formerSymbols2); + } + + /** + * @return the notes + * @see #notes + */ + public String getNotes() { + return notes; + } + + /** + * @param notes + * the notes to set + * @see #notes + */ + public void setNotes(String notes) { + this.notes = notes; + } + + /** + * @return the symbol + * @see #symbol + */ + public String getSymbol() { + return symbol; + } + + /** + * @param symbol + * the symbol to set + * @see #symbol + */ + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + /** + * @return the fullName + * @see #fullName + */ + public String getFullName() { + return fullName; + } + + /** + * @param fullName + * the fullName to set + * @see #fullName + */ + public void setFullName(String fullName) { + this.fullName = fullName; + } + + /** + * @return the abbreviation + * @see #abbreviation + */ + public String getAbbreviation() { + return abbreviation; + } + + /** + * @param abbreviation + * the abbreviation to set + * @see #abbreviation + */ + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + + /** + * @return the formula + * @see #formula + */ + public String getFormula() { + return formula; + } + + /** + * @param formula + * the formula to set + * @see #formula + */ + public void setFormula(String formula) { + this.formula = formula; + } + + /** + * @return the name + * @see #name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + * @see #name + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the synonyms + * @see #synonyms + */ + public List<String> getSynonyms() { + return synonyms; + } + + /** + * @param synonyms + * the synonyms to set + * @see #synonyms + */ + public void setSynonyms(List<String> synonyms) { + this.synonyms = synonyms; + } + + /** + * @return the formerSymbols + * @see #formerSymbols + */ + public List<String> getFormerSymbols() { + return formerSymbols; + } + + /** + * @param formerSymbols + * the formerSymbols to set + * @see #formerSymbols + */ + public void setFormerSymbols(List<String> formerSymbols) { + this.formerSymbols = formerSymbols; + } + + /** + * @return the references + * @see #references + */ + public List<AnnotationView> getReferences() { + return references; + } + + /** + * @param references + * the references to set + * @see #references + */ + public void setReferences(List<AnnotationView> references) { + this.references = references; + } + + /** + * @return the other + * @see #other + */ + public Map<String, Object> getOther() { + return other; + } + + /** + * Returns other (additional element) by the name. + * + * @param key + * key identifing the feature. + * @return other (additional element) by the name + */ + public Object getOther(String key) { + return other.get(key); + } + + /** + * @param other + * the other to set + * @see #other + */ + public void setOther(Map<String, Object> other) { + this.other = other; + } + + /** + * @return the type + * @see #type + */ + public String getType() { + return type; + } + + /** + * @param type + * the type to set + * @see #type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Adds elements to {@link #references} list. + * + * @param newReferences + * list of elements to add + */ + public void addReferences(List<AnnotationView> newReferences) { + references.addAll(newReferences); + } + + /** + * Addsother (additional element) by the name. + * + * @param key + * name of the feature + * @param value + * object representing data of the feature + */ + public void addOther(String key, Object value) { + other.put(key, value); + } + + /** + * @return the modelName + * @see #modelName + */ + public String getModelName() { + return modelName; + } + + /** + * @param modelName + * the modelName to set + * @see #modelName + */ + public void setModelName(String modelName) { + this.modelName = modelName; + } + + /** + * @return the charge + * @see #charge + */ + public Integer getCharge() { + return charge; + } + + /** + * @param charge + * the charge to set + * @see #charge + */ + public void setCharge(Integer charge) { + this.charge = charge; + } + + /** + * @return the initialAmount + * @see #initialAmount + */ + public Integer getInitialAmount() { + return initialAmount; + } + + /** + * @param initialAmount + * the initialAmount to set + * @see #initialAmount + */ + public void setInitialAmount(Integer initialAmount) { + this.initialAmount = initialAmount; + } + + /** + * @return the initialConcentration + * @see #initialConcentration + */ + public Integer getInitialConcentration() { + return initialConcentration; + } + + /** + * @param initialConcentration + * the initialConcentration to set + * @see #initialConcentration + */ + public void setInitialConcentration(Integer initialConcentration) { + this.initialConcentration = initialConcentration; + } + + /** + * @return the onlySubstanceUnits + * @see #onlySubstanceUnits + */ + public Boolean getOnlySubstanceUnits() { + return onlySubstanceUnits; + } + + /** + * @param onlySubstanceUnits + * the onlySubstanceUnits to set + * @see #onlySubstanceUnits + */ + public void setOnlySubstanceUnits(Boolean onlySubstanceUnits) { + this.onlySubstanceUnits = onlySubstanceUnits; + } + + /** + * @return the submodelName + * @see #submodelName + */ + public String getSubmodelName() { + return submodelName; + } + + /** + * @param submodelName + * the submodelName to set + * @see #submodelName + */ + public void setSubmodelName(String submodelName) { + this.submodelName = submodelName; + } + + /** + * @return the submodelId + * @see #submodelId + */ + public String getSubmodelId() { + return submodelId; + } + + /** + * @param submodelId + * the submodelId to set + * @see #submodelId + */ + public void setSubmodelId(String submodelId) { + this.submodelId = submodelId; + } +} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java index 23e02dfe95..7fd70377fc 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java @@ -1,299 +1,305 @@ -package lcsb.mapviewer.services.search.data; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.log4j.Logger; -import org.primefaces.model.DefaultTreeNode; -import org.primefaces.model.TreeNode; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.gson.Gson; - -import lcsb.mapviewer.annotation.data.Chebi; -import lcsb.mapviewer.annotation.data.ChebiRelation; -import lcsb.mapviewer.annotation.services.MiriamConnector; -import lcsb.mapviewer.annotation.services.annotators.ChebiAnnotator; -import lcsb.mapviewer.annotation.services.annotators.ChebiSearchException; -import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.Element; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.MiriamRelationType; -import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.graph.DataMining; -import lcsb.mapviewer.model.map.graph.DataMiningSet; -import lcsb.mapviewer.model.map.graph.DataMiningType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.species.Protein; -import lcsb.mapviewer.model.map.species.Species; -import lcsb.mapviewer.model.map.species.fields.ModificationResidue; -import lcsb.mapviewer.services.interfaces.IDataMiningService; -import lcsb.mapviewer.services.overlay.ChebiTreeRow; -import lcsb.mapviewer.services.search.ElementViewFactory; -import lcsb.mapviewer.services.search.data.FullAliasView.PosttransationalModification; -import lcsb.mapviewer.services.view.AnnotationView; -import lcsb.mapviewer.services.view.AnnotationViewFactory; -import lcsb.mapviewer.services.view.DataMiningView; -import lcsb.mapviewer.services.view.DataMiningViewFactory; - -/** - * Factory class for {@link LightAliasView} class. - * - * @author Piotr Gawron - * - */ -public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasView> { - - /** - * How many rows with data mining information should be presented to the user. - */ - private static final int MAX_MISSING_CONNECTIONS = 100; - - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(FullAliasViewFactory.class); - - /** - * Factory used to create {@link AnnotationView} elements. - */ - @Autowired - private AnnotationViewFactory annotationViewFactory; - - /** - * Connector used for accessing data from miriam registry. - */ - @Autowired - private MiriamConnector mc; - - /** - * Factory object used for creation of {@link DataMiningView} elements. - */ - @Autowired - private DataMiningViewFactory dataMiningViewFactory; - - /** - * Service that manages data mining information. - */ - @Autowired - private IDataMiningService dataMiningService; - - /** - * Service accessing chebi database. - */ - @Autowired - private ChebiAnnotator chebiBackend; - - @Override - public FullAliasView create(Alias alias) { - return create(alias, null); - } - - /** - * Creates {@link FullAliasView} from given {@link Alias}. - * - * @param alias - * alias for which view is created - * @param icon - * icon that should be assigned to the view - * @return {@link FullAliasView} for given alias - */ - public FullAliasView create(Alias alias, String icon) { - FullAliasView result = new FullAliasView(alias, icon); - Element element = alias.getElement(); - if (element != null) { - result.addReferences(annotationViewFactory.createList(element.getMiriamData())); - result.setDataMining(getDataMiningInformation(alias, MAX_MISSING_CONNECTIONS)); - AnnotationView structureView = annotationViewFactory.create(DataMiningType.STRUCTURE_ANALYSIS); - result.getDataMiningColumns().add(structureView); - - AnnotationView textMiningView = annotationViewFactory.create(DataMiningType.TEXT_MINING); - result.getDataMiningColumns().add(textMiningView); - if (alias.getModel() != null) { - for (DataMiningSet dms : alias.getModel().getDataMiningSets()) { - if (DataMiningType.STRUCTURE_ANALYSIS.equals(dms.getType())) { - if (dms.getSource() != null && !dms.getSource().isEmpty()) { - structureView.setLink(dms.getSource()); - } - if (dms.getName() != null && !dms.getName().isEmpty()) { - structureView.setName(dms.getName()); - } - structureView.setSummary(dms.getDescription()); - - } else if (DataMiningType.TEXT_MINING.equals(dms.getType())) { - if (dms.getSource() != null && !dms.getSource().isEmpty()) { - textMiningView.setLink(dms.getSource()); - } - if (dms.getName() != null && !dms.getName().isEmpty()) { - textMiningView.setName(dms.getName()); - } - textMiningView.setSummary(dms.getDescription()); - } else { - throw new NotImplementedException(dms.getType() + " is not implemented."); - } - } - } - for (MiriamData md : element.getMiriamData()) { - if (MiriamType.CHEBI.equals(md.getDataType())) { - try { - Chebi chebi = chebiBackend.getChebiElementForChebiId(md); - if (chebi != null) { - result.addOther("chebiTree", chebi); - } else { - logger.warn("Invalid chebi identifier: " + md.getResource()); - } - } catch (ChebiSearchException e) { - logger.warn("Problem with accesing data about chebi: " + md.getResource(), e); - } - } - } - if (element instanceof Protein) { - result.addOther("posttranslationalModifications", getPosttransationalModifications(alias)); - } - - } - return result; - } - - /** - * Creates list of {@link PosttransationalModification} objects for object - * alias. - * - * @param alias - * alias of the object - * @return list of {@link PosttransationalModification} objects for object - * alias - */ - private List<PosttransationalModification> getPosttransationalModifications(Alias alias) { - List<PosttransationalModification> result = new ArrayList<PosttransationalModification>(); - Element species = alias.getElement(); - if (species instanceof Protein) { - List<ModificationResidue> modifications = ((Protein) species).getModificationResidues(); - if (modifications.size() > 0) { - for (ModificationResidue residue : modifications) { - if (residue.getState() != null) { - PosttransationalModification modification = new PosttransationalModification(); - modification.setName(residue.getState().getFullName()); - modification.setPosition(residue.getName()); - result.add(modification); - } - } - } - } - return result; - } - - @Override - public String createGson(FullAliasView object) { - return new Gson().toJson(object); - } - - /** - * Creates table for data mining information for given alias. - * - * @param alias - * alias for which data mining information is added - * @param maxMissingConnections - * max elements that should be presented - * @return html table with data mining information - */ - protected List<List<DataMiningView>> getDataMiningInformation(Alias alias, int maxMissingConnections) { - List<List<DataMiningView>> result = new ArrayList<List<DataMiningView>>(); - List<DataMiningView> enricoList = new ArrayList<DataMiningView>(); - List<DataMiningView> mariaList = new ArrayList<DataMiningView>(); - if (alias.getElement() == null || !(alias.getElement() instanceof Species)) { - return result; - } - Species species = (Species) alias.getElement(); - - if (dataMiningService != null) { - Collection<DataMining> connections = dataMiningService.getMissingConnections(species); - if (connections.size() > 0) { - for (DataMining missingConnection : connections) { - if (missingConnection.getType().equals(DataMiningType.STRUCTURE_ANALYSIS)) { - if (enricoList.size() < maxMissingConnections) { - DataMiningView view = dataMiningViewFactory.create(missingConnection); - enricoList.add(view); - } - } else if (missingConnection.getType().equals(DataMiningType.TEXT_MINING)) { - if (mariaList.size() < maxMissingConnections) { - DataMiningView view = dataMiningViewFactory.create(missingConnection); - mariaList.add(view); - } - } else { - throw new InvalidArgumentException("Unknown type of missing connection: " + missingConnection.getType()); - } - } - } - } - int size = Math.max(mariaList.size(), enricoList.size()); - for (int i = 0; i < size; i++) { - List<DataMiningView> row = new ArrayList<DataMiningView>(); - if (i < enricoList.size()) { - row.add(enricoList.get(i)); - } else { - row.add(null); - } - if (i < mariaList.size()) { - row.add(mariaList.get(i)); - } else { - row.add(null); - } - result.add(row); - } - return result; - } - - /** - * Creates empty {@link FullAliasView}. - * - * @return empty {@link FullAliasView} - */ - public FullAliasView createEmpty() { - return new FullAliasView(); - } - - /** - * Creates {@link TreeNode} representing {@link Chebi} object. This object is - * used by client side to represent data as a tree. - * - * @param chebi - * object to be transforem - * @return tree representing chebi element - */ - - protected TreeNode createTreeForChebi(Chebi chebi) { - // create artificial root - - TreeNode root = new DefaultTreeNode(new ChebiTreeRow("root", "unknown", MiriamType.CHEBI.getDbHomepage(), ""), null); - root.setExpanded(true); - TreeNode lastElement = root; - // create parents - for (ChebiRelation relation : chebi.getIncomingChebi()) { - MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, relation.getId()); - ChebiTreeRow row = new ChebiTreeRow(relation.getName(), relation.getId(), mc.getUrlString(md), relation.getType()); - lastElement = new DefaultTreeNode(row, root); - lastElement.setExpanded(true); - } - - // create main chebi element - MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, chebi.getChebiId()); - ChebiTreeRow row = new ChebiTreeRow(chebi.getName(), chebi.getChebiId(), mc.getUrlString(md), ""); - - TreeNode element = new DefaultTreeNode(row, lastElement); - element.setExpanded(true); - - // create children - - for (ChebiRelation relation : chebi.getOutgoingChebi()) { - md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, relation.getId()); - row = new ChebiTreeRow(relation.getName(), relation.getId(), mc.getUrlString(md), relation.getType()); - new DefaultTreeNode(row, element); - } - - return root; - } - -} +package lcsb.mapviewer.services.search.data; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.log4j.Logger; +import org.primefaces.model.DefaultTreeNode; +import org.primefaces.model.TreeNode; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.gson.Gson; + +import lcsb.mapviewer.annotation.data.Chebi; +import lcsb.mapviewer.annotation.data.ChebiRelation; +import lcsb.mapviewer.annotation.services.MiriamConnector; +import lcsb.mapviewer.annotation.services.annotators.ChebiAnnotator; +import lcsb.mapviewer.annotation.services.annotators.ChebiSearchException; +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.Element; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamRelationType; +import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.graph.DataMining; +import lcsb.mapviewer.model.map.graph.DataMiningSet; +import lcsb.mapviewer.model.map.graph.DataMiningType; +import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.fields.ModificationResidue; +import lcsb.mapviewer.services.interfaces.IDataMiningService; +import lcsb.mapviewer.services.overlay.ChebiTreeRow; +import lcsb.mapviewer.services.search.ElementViewFactory; +import lcsb.mapviewer.services.search.data.FullAliasView.PosttransationalModification; +import lcsb.mapviewer.services.view.AnnotationView; +import lcsb.mapviewer.services.view.AnnotationViewFactory; +import lcsb.mapviewer.services.view.DataMiningView; +import lcsb.mapviewer.services.view.DataMiningViewFactory; + +/** + * Factory class for {@link LightAliasView} class. + * + * @author Piotr Gawron + * + */ +public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasView> { + + /** + * How many rows with data mining information should be presented to the user. + */ + private static final int MAX_MISSING_CONNECTIONS = 100; + + /** + * Default class logger. + */ + private static Logger logger = Logger.getLogger(FullAliasViewFactory.class); + + /** + * Factory used to create {@link AnnotationView} elements. + */ + @Autowired + private AnnotationViewFactory annotationViewFactory; + + /** + * Connector used for accessing data from miriam registry. + */ + @Autowired + private MiriamConnector mc; + + /** + * Factory object used for creation of {@link DataMiningView} elements. + */ + @Autowired + private DataMiningViewFactory dataMiningViewFactory; + + /** + * Service that manages data mining information. + */ + @Autowired + private IDataMiningService dataMiningService; + + /** + * Service accessing chebi database. + */ + @Autowired + private ChebiAnnotator chebiBackend; + + @Override + public FullAliasView create(Alias alias) { + return create(alias, null); + } + + /** + * Creates {@link FullAliasView} from given {@link Alias}. + * + * @param alias + * alias for which view is created + * @param icon + * icon that should be assigned to the view + * @return {@link FullAliasView} for given alias + */ + public FullAliasView create(Alias alias, String icon) { + FullAliasView result = new FullAliasView(alias, icon); + Element element = alias.getElement(); + if (element != null) { + result.addReferences(annotationViewFactory.createList(element.getMiriamData())); + result.addOther("dataMining", getDataMiningInformation(alias, MAX_MISSING_CONNECTIONS)); + + List<AnnotationView> columns = new ArrayList<>(); + AnnotationView structureView = annotationViewFactory.create(DataMiningType.STRUCTURE_ANALYSIS); + + AnnotationView textMiningView = annotationViewFactory.create(DataMiningType.TEXT_MINING); + + columns.add(structureView); + columns.add(textMiningView); + + result.addOther("dataMiningColumns", columns); + + if (alias.getModel() != null) { + for (DataMiningSet dms : alias.getModel().getDataMiningSets()) { + if (DataMiningType.STRUCTURE_ANALYSIS.equals(dms.getType())) { + if (dms.getSource() != null && !dms.getSource().isEmpty()) { + structureView.setLink(dms.getSource()); + } + if (dms.getName() != null && !dms.getName().isEmpty()) { + structureView.setName(dms.getName()); + } + structureView.setSummary(dms.getDescription()); + + } else if (DataMiningType.TEXT_MINING.equals(dms.getType())) { + if (dms.getSource() != null && !dms.getSource().isEmpty()) { + textMiningView.setLink(dms.getSource()); + } + if (dms.getName() != null && !dms.getName().isEmpty()) { + textMiningView.setName(dms.getName()); + } + textMiningView.setSummary(dms.getDescription()); + } else { + throw new NotImplementedException(dms.getType() + " is not implemented."); + } + } + } + for (MiriamData md : element.getMiriamData()) { + if (MiriamType.CHEBI.equals(md.getDataType())) { + try { + Chebi chebi = chebiBackend.getChebiElementForChebiId(md); + if (chebi != null) { + result.addOther("chebiTree", chebi); + } else { + logger.warn("Invalid chebi identifier: " + md.getResource()); + } + } catch (ChebiSearchException e) { + logger.warn("Problem with accesing data about chebi: " + md.getResource(), e); + } + } + } + if (element instanceof Protein) { + result.addOther("posttranslationalModifications", getPosttransationalModifications(alias)); + } + + } + return result; + } + + /** + * Creates list of {@link PosttransationalModification} objects for object + * alias. + * + * @param alias + * alias of the object + * @return list of {@link PosttransationalModification} objects for object + * alias + */ + private List<PosttransationalModification> getPosttransationalModifications(Alias alias) { + List<PosttransationalModification> result = new ArrayList<PosttransationalModification>(); + Element species = alias.getElement(); + if (species instanceof Protein) { + List<ModificationResidue> modifications = ((Protein) species).getModificationResidues(); + if (modifications.size() > 0) { + for (ModificationResidue residue : modifications) { + if (residue.getState() != null) { + PosttransationalModification modification = new PosttransationalModification(); + modification.setName(residue.getState().getFullName()); + modification.setPosition(residue.getName()); + result.add(modification); + } + } + } + } + return result; + } + + @Override + public String createGson(FullAliasView object) { + return new Gson().toJson(object); + } + + /** + * Creates table for data mining information for given alias. + * + * @param alias + * alias for which data mining information is added + * @param maxMissingConnections + * max elements that should be presented + * @return html table with data mining information + */ + protected List<List<DataMiningView>> getDataMiningInformation(Alias alias, int maxMissingConnections) { + List<List<DataMiningView>> result = new ArrayList<List<DataMiningView>>(); + List<DataMiningView> enricoList = new ArrayList<DataMiningView>(); + List<DataMiningView> mariaList = new ArrayList<DataMiningView>(); + if (alias.getElement() == null || !(alias.getElement() instanceof Species)) { + return result; + } + Species species = (Species) alias.getElement(); + + if (dataMiningService != null) { + Collection<DataMining> connections = dataMiningService.getMissingConnections(species); + if (connections.size() > 0) { + for (DataMining missingConnection : connections) { + if (missingConnection.getType().equals(DataMiningType.STRUCTURE_ANALYSIS)) { + if (enricoList.size() < maxMissingConnections) { + DataMiningView view = dataMiningViewFactory.create(missingConnection); + enricoList.add(view); + } + } else if (missingConnection.getType().equals(DataMiningType.TEXT_MINING)) { + if (mariaList.size() < maxMissingConnections) { + DataMiningView view = dataMiningViewFactory.create(missingConnection); + mariaList.add(view); + } + } else { + throw new InvalidArgumentException("Unknown type of missing connection: " + missingConnection.getType()); + } + } + } + } + int size = Math.max(mariaList.size(), enricoList.size()); + for (int i = 0; i < size; i++) { + List<DataMiningView> row = new ArrayList<DataMiningView>(); + if (i < enricoList.size()) { + row.add(enricoList.get(i)); + } else { + row.add(null); + } + if (i < mariaList.size()) { + row.add(mariaList.get(i)); + } else { + row.add(null); + } + result.add(row); + } + return result; + } + + /** + * Creates empty {@link FullAliasView}. + * + * @return empty {@link FullAliasView} + */ + public FullAliasView createEmpty() { + return new FullAliasView(); + } + + /** + * Creates {@link TreeNode} representing {@link Chebi} object. This object is + * used by client side to represent data as a tree. + * + * @param chebi + * object to be transforem + * @return tree representing chebi element + */ + + protected TreeNode createTreeForChebi(Chebi chebi) { + // create artificial root + + TreeNode root = new DefaultTreeNode(new ChebiTreeRow("root", "unknown", MiriamType.CHEBI.getDbHomepage(), ""), null); + root.setExpanded(true); + TreeNode lastElement = root; + // create parents + for (ChebiRelation relation : chebi.getIncomingChebi()) { + MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, relation.getId()); + ChebiTreeRow row = new ChebiTreeRow(relation.getName(), relation.getId(), mc.getUrlString(md), relation.getType()); + lastElement = new DefaultTreeNode(row, root); + lastElement.setExpanded(true); + } + + // create main chebi element + MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, chebi.getChebiId()); + ChebiTreeRow row = new ChebiTreeRow(chebi.getName(), chebi.getChebiId(), mc.getUrlString(md), ""); + + TreeNode element = new DefaultTreeNode(row, lastElement); + element.setExpanded(true); + + // create children + + for (ChebiRelation relation : chebi.getOutgoingChebi()) { + md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, relation.getId()); + row = new ChebiTreeRow(relation.getName(), relation.getId(), mc.getUrlString(md), relation.getType()); + new DefaultTreeNode(row, element); + } + + return root; + } + +} diff --git a/web/src/main/java/lcsb/mapviewer/bean/SearchBean.java b/web/src/main/java/lcsb/mapviewer/bean/SearchBean.java index 6deb513adb..ccb0e1397f 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/SearchBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/SearchBean.java @@ -12,7 +12,6 @@ import javax.faces.event.ActionEvent; import org.apache.log4j.Logger; import org.primefaces.event.SelectEvent; -import org.primefaces.event.map.PointSelectEvent; import org.primefaces.model.map.LatLng; import lcsb.mapviewer.bean.MapBean.ClientMapData; @@ -235,23 +234,6 @@ public class SearchBean extends AbstractMarkerManagerBean<SearchElementResult> i /** * This method is invoked by client when map is clicked. * - * @param event - * click event with coordinates - */ - public void mapClicked(final PointSelectEvent event) { - logger.debug("Map clicked"); - addSessionParam(STRING_SEARCH_SESSION_PARAM + getCurrentMapId(), null); - Point2D coord = mapBean.getTopModelMapData().getcConverter().toPoint(event.getLatLng()); - addSessionParam(COORDINATE_SEARCH_SESSION_PARAM + getCurrentMapId(), coord); - addSessionParam(COORDINATE_SEARCH_MODEL_ID_SESSION_PARAM + getCurrentMapId(), getCurrentTopModel().getId()); - - searchByCoordinates(coord, getCurrentTopModel()); - } - - /** - * This method is invoked by client when map is clicked (any map except of the - * main). - * * @param actionEvent * event data */ @@ -327,7 +309,7 @@ public class SearchBean extends AbstractMarkerManagerBean<SearchElementResult> i // find objects on the map SearchElementResult result = searchService.searchByCoordinates(searchParams); searchService.assignIcons(result, 0); - super.addResult(result); + addResult(result); // send markers to the map refreshDataInJavascript(false); @@ -415,6 +397,9 @@ public class SearchBean extends AbstractMarkerManagerBean<SearchElementResult> i * @see #mapBean */ public MapBean getMapBean() { + if (mapBean == null) { + mapBean = findBean(MapBean.class); + } return mapBean; } @@ -614,7 +599,7 @@ public class SearchBean extends AbstractMarkerManagerBean<SearchElementResult> i * @return currently browsed map */ private Model getCurrentTopModel() { - return mapBean.getCurrentTopModel(); + return getMapBean().getCurrentTopModel(); } /** diff --git a/web/src/main/webapp/resources/pfcomp/aliasSearchElement.xhtml b/web/src/main/webapp/resources/pfcomp/aliasSearchElement.xhtml index dc79b4d0bc..131d68e83d 100644 --- a/web/src/main/webapp/resources/pfcomp/aliasSearchElement.xhtml +++ b/web/src/main/webapp/resources/pfcomp/aliasSearchElement.xhtml @@ -106,11 +106,12 @@ </div> </h:panelGroup> - <p:panel header="Candidates" toggleable="true" rendered="#{((not empty cc.attrs.element.dataMining[0]) or (not empty cc.attrs.element.dataMining[1]))}" collapsed="true" style="font-size: 100%;width:100%" > - <h:dataTable value="#{cc.attrs.element.dataMining}" var="candidateRow"> + <p:panel header="Candidates" toggleable="true" rendered="#{not empty cc.attrs.element.other['dataMining']}" collapsed="true" style="font-size: 100%;width:100%" > + + <h:dataTable value="#{cc.attrs.element.other['dataMining']}" var="candidateRow"> <h:column> <f:facet name="header"> - <a href="#{cc.attrs.element.dataMiningColumns[0].link}" target="_blank">#{cc.attrs.element.dataMiningColumns[0].name}</a> + <a href="#{cc.attrs.element.other['dataMiningColumns'][0].link}" target="_blank">#{cc.attrs.element.other['dataMiningColumns'][0].name}</a> </f:facet> <ui:repeat var="suggestedElement" value="#{candidateRow[0].suggestedElements}"> @@ -124,7 +125,7 @@ </h:column> <h:column> - <f:facet name="header">#{cc.attrs.element.dataMiningColumns[1].name}</f:facet> + <f:facet name="header">#{cc.attrs.element.other['dataMiningColumns'][1].name}</f:facet> <ui:repeat var="suggestedElement" value="#{candidateRow[1].suggestedElements}"> <h:panelGroup layout="block" rendered="#{empty suggestedElement.link}"> <h:outputText value="#{suggestedElement.name}" />, -- GitLab