From 90b945e626612a19d2bea446a215da87f00e7597 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 20 Nov 2017 18:05:26 +0100
Subject: [PATCH] change in public overlays is reflected in the API responses
 immediatelly

---
 .../mapviewer/persist/dao/map/LayoutDao.java  | 172 ++---
 .../api/projects/ProjectRestImpl.java         |   1 -
 .../api/projects/models/ModelMetaData.java    | 730 +++++++++---------
 .../api/projects/models/ModelRestImpl.java    | 137 ++--
 4 files changed, 526 insertions(+), 514 deletions(-)

diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java
index b30a947064..11fb912fdf 100644
--- a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java
+++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/LayoutDao.java
@@ -1,86 +1,86 @@
-package lcsb.mapviewer.persist.dao.map;
-
-import java.util.List;
-
-import lcsb.mapviewer.model.map.layout.Layout;
-import lcsb.mapviewer.model.map.model.Model;
-import lcsb.mapviewer.model.user.User;
-import lcsb.mapviewer.persist.dao.BaseDao;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Criteria;
-import org.hibernate.criterion.Projections;
-import org.hibernate.criterion.Restrictions;
-
-/**
- * Data access object for {@link Layout} class.
- * 
- * @author Piotr Gawron
- * 
- */
-public class LayoutDao extends BaseDao<Layout> {
-	
-	/**
-	 * Default class logger.
-	 */
-	@SuppressWarnings("unused")
-	private static Logger	logger	= Logger.getLogger(LayoutDao.class);
-
-	/**
-	 * Default constructor.
-	 */
-	public LayoutDao() {
-		super(Layout.class);
-	}
-
-	/**
-	 * Lists layouts for the model.
-	 * 
-	 * @param model
-	 *          for this model layouts will be listed
-	 * @return list of layouts for the model
-	 */
-	public List<Layout> getLayoutsByModel(Model model) {
-		List<Layout> layouts = getElementsByParameter("model_iddb", model.getId());
-//		for (Layout layout : layouts) {
-//			refresh(layout);
-//		}
-		return layouts;
-	}
-
-	/**
-	 * Return number of layouts created by the user.
-	 * 
-	 * @param user
-	 *          the user
-	 * @return number of layouts created by the user
-	 */
-	public long getCountByUser(User user) {
-		Criteria crit = getSession().createCriteria(this.getClazz());
-		crit.setProjection(Projections.rowCount());
-		crit.add(Restrictions.eq("creator", user));
-		crit.createAlias("model", "m");
-		crit.add(Restrictions.sizeLe("m.parentModels", 0));
-		return (Long) crit.uniqueResult();
-	}
-
-	/**
-	 * Returns layout identified by name and model.
-	 * 
-	 * @param model
-	 *          model where the layouts lay on
-	 * @param name
-	 *          name of the layout
-	 * @return layout
-	 */
-	public Layout getLayoutByName(Model model, String name) {
-		List<Layout> layouts = getElementsByParameter("model_iddb", model.getId());
-		for (Layout layout : layouts) {
-			refresh(layout);
-			if (layout.getTitle().equals(name)) {
-				return layout;
-			}
-		}
-		return null;
-	}
-}
+package lcsb.mapviewer.persist.dao.map;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Criteria;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+
+import lcsb.mapviewer.model.map.layout.Layout;
+import lcsb.mapviewer.model.map.model.Model;
+import lcsb.mapviewer.model.user.User;
+import lcsb.mapviewer.persist.dao.BaseDao;
+
+/**
+ * Data access object for {@link Layout} class.
+ * 
+ * @author Piotr Gawron
+ * 
+ */
+public class LayoutDao extends BaseDao<Layout> {
+
+  /**
+   * Default class logger.
+   */
+  @SuppressWarnings("unused")
+  private static Logger logger = Logger.getLogger(LayoutDao.class);
+
+  /**
+   * Default constructor.
+   */
+  public LayoutDao() {
+    super(Layout.class);
+  }
+
+  /**
+   * Lists layouts for the model.
+   * 
+   * @param model
+   *          for this model layouts will be listed
+   * @return list of layouts for the model
+   */
+  public List<Layout> getLayoutsByModel(Model model) {
+    List<Layout> layouts = getElementsByParameter("model_iddb", model.getId());
+    for (Layout layout : layouts) {
+      refresh(layout);
+    }
+    return layouts;
+  }
+
+  /**
+   * Return number of layouts created by the user.
+   * 
+   * @param user
+   *          the user
+   * @return number of layouts created by the user
+   */
+  public long getCountByUser(User user) {
+    Criteria crit = getSession().createCriteria(this.getClazz());
+    crit.setProjection(Projections.rowCount());
+    crit.add(Restrictions.eq("creator", user));
+    crit.createAlias("model", "m");
+    crit.add(Restrictions.sizeLe("m.parentModels", 0));
+    return (Long) crit.uniqueResult();
+  }
+
+  /**
+   * Returns layout identified by name and model.
+   * 
+   * @param model
+   *          model where the layouts lay on
+   * @param name
+   *          name of the layout
+   * @return layout
+   */
+  public Layout getLayoutByName(Model model, String name) {
+    List<Layout> layouts = getElementsByParameter("model_iddb", model.getId());
+    for (Layout layout : layouts) {
+      refresh(layout);
+      if (layout.getTitle().equals(name)) {
+        return layout;
+      }
+    }
+    return null;
+  }
+}
diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
index 0768945b28..c4351cfc3f 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
@@ -569,7 +569,6 @@ public class ProjectRestImpl extends BaseRestImpl {
       ZipEntryFile entry = null;
       String entryType = (String) data.get("zip-entries[" + fileIndex + "][_type]").get(0);
       String filename = (String) data.get("zip-entries[" + fileIndex + "][_filename]").get(0);
-      logger.debug(filename);
       if ("MAP".equalsIgnoreCase(entryType)) {
         String submodelTypeKey = "zip-entries[" + fileIndex + "][_data][type][id]";
         String rootKey = "zip-entries[" + fileIndex + "][_data][root]";
diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java
index 62181d0b37..2ff2bc4932 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelMetaData.java
@@ -1,365 +1,365 @@
-package lcsb.mapviewer.api.projects.models;
-
-import java.awt.geom.Point2D;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.primefaces.model.map.LatLng;
-
-import lcsb.mapviewer.common.Configuration;
-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.model.SubmodelType;
-import lcsb.mapviewer.services.utils.gmap.CoordinationConverter;
-import lcsb.mapviewer.services.view.LayoutView;
-import lcsb.mapviewer.services.view.LayoutViewFactory;
-
-public class ModelMetaData implements Serializable {
-
-	/**
-	 * 
-	 */
-	private static final long		serialVersionUID = 1L;
-
-	/**
-	 * Version of the model.
-	 */
-	private String							version;
-
-	/**
-	 * Name of the model.
-	 */
-	private String							name;
-
-	private Integer							idObject;
-
-	/**
-	 * Size in pixels of the single square tile (small image used for graphical
-	 * representation).
-	 */
-	private Integer							tileSize;
-
-	private Integer							width;
-
-	private Integer							height;
-
-	/**
-	 * Minimum zoom level that should be allowed by the Google Maps API.
-	 */
-	private Integer							minZoom;
-
-	/**
-	 * Maximum zoom level that should be allowed by the Google Maps API.
-	 */
-	private Integer							maxZoom;
-
-	private List<LayoutView>		layouts					 = new ArrayList<>();
-
-	/**
-	 * List of submodels in the model.
-	 */
-	private List<ModelMetaData>	submodels				 = new ArrayList<>();
-
-	/**
-	 * Where is the center of the map in latituted, longiude format.
-	 */
-	private LatLng							centerLatLng;
-
-	/**
-	 * Top-Left corner of the map (0,0) as a latLng coordinates.
-	 */
-	private LatLng							topLeftLatLng;
-
-	/**
-	 * Bottom-Right corner of the map (width,height) as a latLng coordinates.
-	 */
-	private LatLng							bottomRightLatLng;
-
-	/**
-	 * Type of the submodel.
-	 */
-	private SubmodelType				submodelType		 = SubmodelType.UNKNOWN;
-
-	/**
-	 * Default constructor.
-	 */
-	public ModelMetaData(Model model) {
-		this(model.getModelData());
-	}
-
-	public ModelMetaData(ModelData model) {
-		this.setName(model.getName());
-		this.setIdObject(model.getId());
-
-		this.setMinZoom(Configuration.MIN_ZOOM_LEVEL);
-		this.setMaxZoom(this.getMinZoom() + model.getZoomLevels());
-		this.setTileSize(model.getTileSize());
-		this.setWidth((int) (double) model.getWidth());
-		this.setHeight((int) (double) model.getHeight());
-		int size = Math.max(width, height);
-		CoordinationConverter cConverter = new CoordinationConverter(model);
-		this.setCenterLatLng(cConverter.toLatLng(new Point2D.Double(size / 2, size / 2)));
-		this.setBottomRightLatLng(cConverter.toLatLng(new Point2D.Double(model.getWidth(), model.getHeight())));
-		this.setTopLeftLatLng(cConverter.toLatLng(new Point2D.Double(0, 0)));
-
-		List<ModelMetaData> submodels = new ArrayList<>();
-		for (ModelSubmodelConnection connection : model.getSubmodels()) {
-			ModelMetaData submodelData = new ModelMetaData(connection.getSubmodel());
-			submodelData.setSubmodelType(connection.getType());
-			submodels.add(submodelData);
-		}
-		LayoutViewFactory factory = new LayoutViewFactory();
-		for (Layout layout : model.getLayouts()) {
-			if (layout.isPublicLayout()) {
-				layouts.add(factory.create(layout));
-			}
-		}
-		this.setSubmodels(submodels);
-
-	}
-
-	protected ModelMetaData() {
-	}
-
-	/**
-	 * @return the version
-	 * @see #version
-	 */
-	public String getVersion() {
-		return version;
-	}
-
-	/**
-	 * @param version
-	 *          the version to set
-	 * @see #version
-	 */
-	public void setVersion(String version) {
-		this.version = version;
-	}
-
-	/**
-	 * @return the tileSize
-	 * @see #tileSize
-	 */
-	public Integer getTileSize() {
-		return tileSize;
-	}
-
-	/**
-	 * @param tileSize
-	 *          the tileSize to set
-	 * @see #tileSize
-	 */
-	public void setTileSize(Integer tileSize) {
-		this.tileSize = tileSize;
-	}
-
-	/**
-	 * @return the minZoom
-	 * @see #minZoom
-	 */
-	public Integer getMinZoom() {
-		return minZoom;
-	}
-
-	/**
-	 * @param minZoom
-	 *          the minZoom to set
-	 * @see #minZoom
-	 */
-	public void setMinZoom(Integer minZoom) {
-		this.minZoom = minZoom;
-	}
-
-	/**
-	 * @return the maxZoom
-	 * @see #maxZoom
-	 */
-	public Integer getMaxZoom() {
-		return maxZoom;
-	}
-
-	/**
-	 * @param maxZoom
-	 *          the maxZoom to set
-	 * @see #maxZoom
-	 */
-	public void setMaxZoom(Integer maxZoom) {
-		this.maxZoom = maxZoom;
-	}
-
-	/**
-	 * @return the centerLatLng
-	 * @see #centerLatLng
-	 */
-	public LatLng getCenterLatLng() {
-		return centerLatLng;
-	}
-
-	/**
-	 * @param centerLatLng
-	 *          the centerLatLng to set
-	 * @see #centerLatLng
-	 */
-	public void setCenterLatLng(LatLng centerLatLng) {
-		this.centerLatLng = centerLatLng;
-	}
-
-	/**
-	 * @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 topLeftLatLng
-	 * @see #topLeftLatLng
-	 */
-	public LatLng getTopLeftLatLng() {
-		return topLeftLatLng;
-	}
-
-	/**
-	 * @param topLeftLatLng
-	 *          the topLeftLatLng to set
-	 * @see #topLeftLatLng
-	 */
-	public void setTopLeftLatLng(LatLng topLeftLatLng) {
-		this.topLeftLatLng = topLeftLatLng;
-	}
-
-	/**
-	 * @return the bottomRightLatLng
-	 * @see #bottomRightLatLng
-	 */
-	public LatLng getBottomRightLatLng() {
-		return bottomRightLatLng;
-	}
-
-	/**
-	 * @param bottomRightLatLng
-	 *          the bottomRightLatLng to set
-	 * @see #bottomRightLatLng
-	 */
-	public void setBottomRightLatLng(LatLng bottomRightLatLng) {
-		this.bottomRightLatLng = bottomRightLatLng;
-	}
-
-	/**
-	 * @return the width
-	 * @see #width
-	 */
-	public Integer getWidth() {
-		return width;
-	}
-
-	/**
-	 * @param width
-	 *          the width to set
-	 * @see #width
-	 */
-	public void setWidth(Integer width) {
-		this.width = width;
-	}
-
-	/**
-	 * @return the height
-	 * @see #height
-	 */
-	public Integer getHeight() {
-		return height;
-	}
-
-	/**
-	 * @param height
-	 *          the height to set
-	 * @see #height
-	 */
-	public void setHeight(Integer height) {
-		this.height = height;
-	}
-
-	/**
-	 * @return the submodels
-	 * @see #submodels
-	 */
-	public List<ModelMetaData> getSubmodels() {
-		return submodels;
-	}
-
-	/**
-	 * @param submodels
-	 *          the submodels to set
-	 * @see #submodels
-	 */
-	public void setSubmodels(List<ModelMetaData> submodels) {
-		this.submodels = submodels;
-	}
-
-	/**
-	 * @return the layouts
-	 * @see #layouts
-	 */
-	public List<LayoutView> getLayouts() {
-		return layouts;
-	}
-
-	/**
-	 * @param layouts
-	 *          the layouts to set
-	 * @see #layouts
-	 */
-	public void setLayouts(List<LayoutView> layouts) {
-		this.layouts = layouts;
-	}
-
-	/**
-	 * @return the idObject
-	 * @see #idObject
-	 */
-	public Integer getIdObject() {
-		return idObject;
-	}
-
-	/**
-	 * @param idObject
-	 *          the idObject to set
-	 * @see #idObject
-	 */
-	public void setIdObject(Integer idObject) {
-		this.idObject = idObject;
-	}
-
-	/**
-	 * @return the submodelType
-	 * @see #submodelType
-	 */
-	public SubmodelType getSubmodelType() {
-		return submodelType;
-	}
-
-	/**
-	 * @param submodelType
-	 *          the submodelType to set
-	 * @see #submodelType
-	 */
-	public void setSubmodelType(SubmodelType submodelType) {
-		this.submodelType = submodelType;
-	}
-
-}
+package lcsb.mapviewer.api.projects.models;
+
+import java.awt.geom.Point2D;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.primefaces.model.map.LatLng;
+
+import lcsb.mapviewer.common.Configuration;
+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.model.SubmodelType;
+import lcsb.mapviewer.services.utils.gmap.CoordinationConverter;
+import lcsb.mapviewer.services.view.LayoutView;
+import lcsb.mapviewer.services.view.LayoutViewFactory;
+
+public class ModelMetaData implements Serializable {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  /**
+   * Version of the model.
+   */
+  private String version;
+
+  /**
+   * Name of the model.
+   */
+  private String name;
+
+  private Integer idObject;
+
+  /**
+   * Size in pixels of the single square tile (small image used for graphical
+   * representation).
+   */
+  private Integer tileSize;
+
+  private Integer width;
+
+  private Integer height;
+
+  /**
+   * Minimum zoom level that should be allowed by the Google Maps API.
+   */
+  private Integer minZoom;
+
+  /**
+   * Maximum zoom level that should be allowed by the Google Maps API.
+   */
+  private Integer maxZoom;
+
+  private List<LayoutView> layouts = new ArrayList<>();
+
+  /**
+   * List of submodels in the model.
+   */
+  private List<ModelMetaData> submodels = new ArrayList<>();
+
+  /**
+   * Where is the center of the map in latitude, longitude format.
+   */
+  private LatLng centerLatLng;
+
+  /**
+   * Top-Left corner of the map (0,0) as a latLng coordinates.
+   */
+  private LatLng topLeftLatLng;
+
+  /**
+   * Bottom-Right corner of the map (width,height) as a latLng coordinates.
+   */
+  private LatLng bottomRightLatLng;
+
+  /**
+   * Type of the submodel.
+   */
+  private SubmodelType submodelType = SubmodelType.UNKNOWN;
+
+  /**
+   * Default constructor.
+   */
+  public ModelMetaData(Model model) {
+    this(model.getModelData());
+  }
+
+  public ModelMetaData(ModelData model) {
+    this.setName(model.getName());
+    this.setIdObject(model.getId());
+
+    this.setMinZoom(Configuration.MIN_ZOOM_LEVEL);
+    this.setMaxZoom(this.getMinZoom() + model.getZoomLevels());
+    this.setTileSize(model.getTileSize());
+    this.setWidth((int) (double) model.getWidth());
+    this.setHeight((int) (double) model.getHeight());
+    int size = Math.max(width, height);
+    CoordinationConverter cConverter = new CoordinationConverter(model);
+    this.setCenterLatLng(cConverter.toLatLng(new Point2D.Double(size / 2, size / 2)));
+    this.setBottomRightLatLng(cConverter.toLatLng(new Point2D.Double(model.getWidth(), model.getHeight())));
+    this.setTopLeftLatLng(cConverter.toLatLng(new Point2D.Double(0, 0)));
+
+    List<ModelMetaData> submodels = new ArrayList<>();
+    for (ModelSubmodelConnection connection : model.getSubmodels()) {
+      ModelMetaData submodelData = new ModelMetaData(connection.getSubmodel());
+      submodelData.setSubmodelType(connection.getType());
+      submodels.add(submodelData);
+    }
+    LayoutViewFactory factory = new LayoutViewFactory();
+    for (Layout layout : model.getLayouts()) {
+      if (layout.isPublicLayout()) {
+        layouts.add(factory.create(layout));
+      }
+    }
+    this.setSubmodels(submodels);
+
+  }
+
+  protected ModelMetaData() {
+  }
+
+  /**
+   * @return the version
+   * @see #version
+   */
+  public String getVersion() {
+    return version;
+  }
+
+  /**
+   * @param version
+   *          the version to set
+   * @see #version
+   */
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  /**
+   * @return the tileSize
+   * @see #tileSize
+   */
+  public Integer getTileSize() {
+    return tileSize;
+  }
+
+  /**
+   * @param tileSize
+   *          the tileSize to set
+   * @see #tileSize
+   */
+  public void setTileSize(Integer tileSize) {
+    this.tileSize = tileSize;
+  }
+
+  /**
+   * @return the minZoom
+   * @see #minZoom
+   */
+  public Integer getMinZoom() {
+    return minZoom;
+  }
+
+  /**
+   * @param minZoom
+   *          the minZoom to set
+   * @see #minZoom
+   */
+  public void setMinZoom(Integer minZoom) {
+    this.minZoom = minZoom;
+  }
+
+  /**
+   * @return the maxZoom
+   * @see #maxZoom
+   */
+  public Integer getMaxZoom() {
+    return maxZoom;
+  }
+
+  /**
+   * @param maxZoom
+   *          the maxZoom to set
+   * @see #maxZoom
+   */
+  public void setMaxZoom(Integer maxZoom) {
+    this.maxZoom = maxZoom;
+  }
+
+  /**
+   * @return the centerLatLng
+   * @see #centerLatLng
+   */
+  public LatLng getCenterLatLng() {
+    return centerLatLng;
+  }
+
+  /**
+   * @param centerLatLng
+   *          the centerLatLng to set
+   * @see #centerLatLng
+   */
+  public void setCenterLatLng(LatLng centerLatLng) {
+    this.centerLatLng = centerLatLng;
+  }
+
+  /**
+   * @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 topLeftLatLng
+   * @see #topLeftLatLng
+   */
+  public LatLng getTopLeftLatLng() {
+    return topLeftLatLng;
+  }
+
+  /**
+   * @param topLeftLatLng
+   *          the topLeftLatLng to set
+   * @see #topLeftLatLng
+   */
+  public void setTopLeftLatLng(LatLng topLeftLatLng) {
+    this.topLeftLatLng = topLeftLatLng;
+  }
+
+  /**
+   * @return the bottomRightLatLng
+   * @see #bottomRightLatLng
+   */
+  public LatLng getBottomRightLatLng() {
+    return bottomRightLatLng;
+  }
+
+  /**
+   * @param bottomRightLatLng
+   *          the bottomRightLatLng to set
+   * @see #bottomRightLatLng
+   */
+  public void setBottomRightLatLng(LatLng bottomRightLatLng) {
+    this.bottomRightLatLng = bottomRightLatLng;
+  }
+
+  /**
+   * @return the width
+   * @see #width
+   */
+  public Integer getWidth() {
+    return width;
+  }
+
+  /**
+   * @param width
+   *          the width to set
+   * @see #width
+   */
+  public void setWidth(Integer width) {
+    this.width = width;
+  }
+
+  /**
+   * @return the height
+   * @see #height
+   */
+  public Integer getHeight() {
+    return height;
+  }
+
+  /**
+   * @param height
+   *          the height to set
+   * @see #height
+   */
+  public void setHeight(Integer height) {
+    this.height = height;
+  }
+
+  /**
+   * @return the submodels
+   * @see #submodels
+   */
+  public List<ModelMetaData> getSubmodels() {
+    return submodels;
+  }
+
+  /**
+   * @param submodels
+   *          the submodels to set
+   * @see #submodels
+   */
+  public void setSubmodels(List<ModelMetaData> submodels) {
+    this.submodels = submodels;
+  }
+
+  /**
+   * @return the layouts
+   * @see #layouts
+   */
+  public List<LayoutView> getLayouts() {
+    return layouts;
+  }
+
+  /**
+   * @param layouts
+   *          the layouts to set
+   * @see #layouts
+   */
+  public void setLayouts(List<LayoutView> layouts) {
+    this.layouts = layouts;
+  }
+
+  /**
+   * @return the idObject
+   * @see #idObject
+   */
+  public Integer getIdObject() {
+    return idObject;
+  }
+
+  /**
+   * @param idObject
+   *          the idObject to set
+   * @see #idObject
+   */
+  public void setIdObject(Integer idObject) {
+    this.idObject = idObject;
+  }
+
+  /**
+   * @return the submodelType
+   * @see #submodelType
+   */
+  public SubmodelType getSubmodelType() {
+    return submodelType;
+  }
+
+  /**
+   * @param submodelType
+   *          the submodelType to set
+   * @see #submodelType
+   */
+  public void setSubmodelType(SubmodelType submodelType) {
+    this.submodelType = submodelType;
+  }
+
+}
diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java
index 91170295f8..7e26e7430e 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java
@@ -1,62 +1,75 @@
-package lcsb.mapviewer.api.projects.models;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.springframework.transaction.annotation.Transactional;
-
-import lcsb.mapviewer.api.BaseRestImpl;
-import lcsb.mapviewer.api.ObjectNotFoundException;
-import lcsb.mapviewer.model.Project;
-import lcsb.mapviewer.model.map.model.Model;
-import lcsb.mapviewer.services.SecurityException;
-import lcsb.mapviewer.services.view.AuthenticationToken;
-
-@Transactional(value = "txManager")
-public class ModelRestImpl extends BaseRestImpl {
-
-  /**
-   * Default class logger.
-   */
-  @SuppressWarnings("unused")
-  private Logger logger = Logger.getLogger(ModelRestImpl.class);
-
-  public List<ModelMetaData> getModels(String projectId, String token)
-      throws SecurityException, ObjectNotFoundException {
-    AuthenticationToken authenticationToken = getUserService().getToken(token);
-    Project project = getProjectService().getProjectByProjectId(projectId, authenticationToken);
-    if (project == null) {
-      throw new ObjectNotFoundException("Project with given id doesn't exist");
-    }
-    List<ModelMetaData> result = createData(project, authenticationToken);
-    return result;
-  }
-
-  public ModelMetaData getModel(String projectId, String modelId, String token)
-      throws SecurityException, ObjectNotFoundException {
-    AuthenticationToken authenticationToken = getUserService().getToken(token);
-    Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken);
-    Model submodel = model.getSubmodelById(modelId);
-    if (submodel == null) {
-      return null;
-    } else {
-      return new ModelMetaData(submodel);
-    }
-  }
-
-  private List<ModelMetaData> createData(Project project, AuthenticationToken token) {
-    List<ModelMetaData> result = new ArrayList<>();
-    Model model = getModelService().getLastModelByProjectId(project.getProjectId(), token);
-    if (model != null) {
-
-      List<Model> models = new ArrayList<>();
-      models.add(model);
-      models.addAll(model.getSubmodels());
-      for (Model model2 : models) {
-        result.add(new ModelMetaData(model2));
-      }
-    }
-    return result;
-  }
-}
+package lcsb.mapviewer.api.projects.models;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import lcsb.mapviewer.api.BaseRestImpl;
+import lcsb.mapviewer.api.ObjectNotFoundException;
+import lcsb.mapviewer.model.Project;
+import lcsb.mapviewer.model.map.model.Model;
+import lcsb.mapviewer.services.SecurityException;
+import lcsb.mapviewer.services.interfaces.ILayoutService;
+import lcsb.mapviewer.services.view.AuthenticationToken;
+
+@Transactional(value = "txManager")
+public class ModelRestImpl extends BaseRestImpl {
+
+  @Autowired
+  private ILayoutService layoutService;
+
+  /**
+   * Default class logger.
+   */
+  @SuppressWarnings("unused")
+  private Logger logger = Logger.getLogger(ModelRestImpl.class);
+
+  public List<ModelMetaData> getModels(String projectId, String token)
+      throws SecurityException, ObjectNotFoundException {
+    AuthenticationToken authenticationToken = getUserService().getToken(token);
+    Project project = getProjectService().getProjectByProjectId(projectId, authenticationToken);
+    if (project == null) {
+      throw new ObjectNotFoundException("Project with given id doesn't exist");
+    }
+    List<ModelMetaData> result = createData(project, authenticationToken);
+    return result;
+  }
+
+  public ModelMetaData getModel(String projectId, String modelId, String token) throws SecurityException {
+    AuthenticationToken authenticationToken = getUserService().getToken(token);
+    Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken);
+    Model submodel = model.getSubmodelById(modelId);
+    if (submodel == null) {
+      return null;
+    } else {
+      ModelMetaData result = new ModelMetaData(submodel);
+
+      List<ModelMetaData> metaDataToProcess = new ArrayList<>();
+      metaDataToProcess.add(result);
+      metaDataToProcess.addAll(result.getSubmodels());
+      for (ModelMetaData submodelData : metaDataToProcess) {
+        submodelData.setLayouts(layoutService.getGeneralLayouts(model));
+        logger.debug(submodelData.getLayouts());
+      }
+      return result;
+    }
+  }
+
+  private List<ModelMetaData> createData(Project project, AuthenticationToken token) throws SecurityException {
+    List<ModelMetaData> result = new ArrayList<>();
+    Model model = getModelService().getLastModelByProjectId(project.getProjectId(), token);
+    if (model != null) {
+
+      List<Model> models = new ArrayList<>();
+      models.add(model);
+      models.addAll(model.getSubmodels());
+      for (Model model2 : models) {
+        result.add(getModel(project.getProjectId(), model2.getId() + "", token.getId()));
+      }
+    }
+    return result;
+  }
+}
-- 
GitLab