From f4e370375df3d78318f2caf71d7061f06e75eaf1 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 10 Apr 2017 15:36:23 +0200 Subject: [PATCH] number of publication should be in project scope --- .../mapviewer/api/project/ModelMetaData.java | 49 ------------------- .../api/project/ProjectMetaData.java | 28 +++++++---- .../api/project/ProjectRestImpl.java | 32 +++++++++++- 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/project/ModelMetaData.java b/rest-api/src/main/java/lcsb/mapviewer/api/project/ModelMetaData.java index a771a5e150..3fc4c467e5 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/project/ModelMetaData.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/project/ModelMetaData.java @@ -3,21 +3,15 @@ package lcsb.mapviewer.api.project; import java.awt.geom.Point2D; import java.io.Serializable; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.primefaces.model.map.LatLng; import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; -import lcsb.mapviewer.model.map.reaction.Reaction; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.utils.gmap.CoordinationConverter; import lcsb.mapviewer.services.view.LayoutView; import lcsb.mapviewer.services.view.LayoutViewFactory; @@ -41,8 +35,6 @@ public class ModelMetaData implements Serializable { private Integer idObject; - private Integer publicationCount; - /** * Size in pixels of the single square tile (small image used for graphical * representation). @@ -119,31 +111,6 @@ public class ModelMetaData implements Serializable { } this.setSubmodels(submodels); - Set<MiriamData> publications = new HashSet<>(); - List<ModelData> models = new ArrayList<>(); - for (ModelSubmodelConnection connection : model.getSubmodels()) { - models.add(connection.getSubmodel()); - } - models.add(model); - for (ModelData modelData : models) { - for (Element element : modelData.getElements()) { - for (MiriamData md : element.getMiriamData()) { - if (md.getDataType().equals(MiriamType.PUBMED)) { - publications.add(md); - } - } - } - for (Reaction reaction : modelData.getReactions()) { - for (MiriamData md : reaction.getMiriamData()) { - if (md.getDataType().equals(MiriamType.PUBMED)) { - publications.add(md); - } - } - - } - } - - this.setPublicationCount(publications.size()); } protected ModelMetaData() { @@ -370,20 +337,4 @@ public class ModelMetaData implements Serializable { this.idObject = idObject; } - /** - * @return the publicationCount - * @see #publicationCount - */ - public Integer getPublicationCount() { - return publicationCount; - } - - /** - * @param publicationCount - * the publicationCount to set - * @see #publicationCount - */ - public void setPublicationCount(Integer publicationCount) { - this.publicationCount = publicationCount; - } } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectMetaData.java b/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectMetaData.java index 090b6d0dc1..6c946ee3d0 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectMetaData.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectMetaData.java @@ -1,20 +1,12 @@ package lcsb.mapviewer.api.project; import java.io.Serializable; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.OverviewImage; -import lcsb.mapviewer.model.map.OverviewImageLink; -import lcsb.mapviewer.model.map.OverviewLink; -import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.services.view.AnnotationView; import lcsb.mapviewer.services.view.OverviewImageView; -import lcsb.mapviewer.services.view.OverviewImageViewFactory; public class ProjectMetaData implements Serializable { @@ -53,6 +45,8 @@ public class ProjectMetaData implements Serializable { private ModelMetaData map; + private Integer publicationCount; + /** * List of overview images attached to this model. */ @@ -69,7 +63,6 @@ public class ProjectMetaData implements Serializable { protected ProjectMetaData() { } - /** * @return the version * @see #version @@ -240,4 +233,21 @@ public class ProjectMetaData implements Serializable { this.organism = organism; } + /** + * @return the publicationCount + * @see #publicationCount + */ + public Integer getPublicationCount() { + return publicationCount; + } + + /** + * @param publicationCount + * the publicationCount to set + * @see #publicationCount + */ + public void setPublicationCount(Integer publicationCount) { + this.publicationCount = publicationCount; + } + } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectRestImpl.java index 27157aa2be..71d93d6ba7 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/project/ProjectRestImpl.java @@ -17,11 +17,14 @@ import org.springframework.web.bind.annotation.RequestParam; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.Project; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.OverviewImageLink; import lcsb.mapviewer.model.map.OverviewLink; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; +import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; @@ -106,8 +109,35 @@ public class ProjectRestImpl { result.setTopOverviewImage(factory.create(model.getOverviewImages().get(0))); } result.setMap(new ModelMetaData(model)); + + Set<MiriamData> publications = new HashSet<>(); + List<ModelData> models = new ArrayList<>(); + for (ModelSubmodelConnection connection : model.getSubmodels()) { + models.add(connection.getSubmodel()); + } + models.add(model); + for (ModelData modelData : models) { + for (Element element : modelData.getElements()) { + for (MiriamData md : element.getMiriamData()) { + if (md.getDataType().equals(MiriamType.PUBMED)) { + publications.add(md); + } + } + } + for (Reaction reaction : modelData.getReactions()) { + for (MiriamData md : reaction.getMiriamData()) { + if (md.getDataType().equals(MiriamType.PUBMED)) { + publications.add(md); + } + } + + } + } + + result.setPublicationCount(publications.size()); + } - + return result; } -- GitLab