From 1d5f980bd36c2436f01d0bbc1a442d00115548f7 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 24 Jul 2019 19:54:38 +0200
Subject: [PATCH] old unused code removed

---
 .../projects/comments/CommentRestImpl.java    |  98 ++++++------
 .../services/overlay/IconManager.java         | 144 ------------------
 .../mapviewer/services/overlay/IconType.java  |  68 ---------
 .../services/overlay/AllOverlayTests.java     |   1 -
 .../services/overlay/IconManagerTest.java     |  47 ------
 5 files changed, 48 insertions(+), 310 deletions(-)
 delete mode 100644 service/src/main/java/lcsb/mapviewer/services/overlay/IconManager.java
 delete mode 100644 service/src/main/java/lcsb/mapviewer/services/overlay/IconType.java
 delete mode 100644 service/src/test/java/lcsb/mapviewer/services/overlay/IconManagerTest.java

diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/comments/CommentRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/comments/CommentRestImpl.java
index 4f5a8265f1..5527253a14 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/comments/CommentRestImpl.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/comments/CommentRestImpl.java
@@ -4,15 +4,14 @@ import java.awt.geom.Line2D;
 import java.awt.geom.Point2D;
 import java.util.*;
 
-import org.apache.logging.log4j.*;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import lcsb.mapviewer.api.BaseRestImpl;
-import lcsb.mapviewer.api.ElementIdentifierType;
-import lcsb.mapviewer.api.ObjectNotFoundException;
-import lcsb.mapviewer.api.QueryException;
+import lcsb.mapviewer.api.*;
+import lcsb.mapviewer.common.Configuration;
 import lcsb.mapviewer.common.geometry.PointTransformation;
 import lcsb.mapviewer.model.Project;
 import lcsb.mapviewer.model.map.Comment;
@@ -22,7 +21,6 @@ import lcsb.mapviewer.model.map.species.Element;
 import lcsb.mapviewer.persist.dao.map.ReactionDao;
 import lcsb.mapviewer.persist.dao.map.species.ElementDao;
 import lcsb.mapviewer.services.interfaces.ICommentService;
-import lcsb.mapviewer.services.overlay.IconManager;
 
 @Transactional
 @Service
@@ -38,7 +36,7 @@ public class CommentRestImpl extends BaseRestImpl {
   private ReactionDao reactionDao;
 
   private ElementDao elementDao;
-  
+
   private PointTransformation pt = new PointTransformation();
 
   @Autowired
@@ -101,48 +99,48 @@ public class CommentRestImpl extends BaseRestImpl {
       String column = string.toLowerCase();
       Object value;
       switch (column) {
-        case "id":
-        case "idobject":
-          value = comment.getId();
-          break;
-        case "elementid":
-          value = getId(comment);
-          break;
-        case "modelid":
-          value = comment.getSubmodelData().getId();
-          break;
-        case "title":
-          value = getTitle(comment);
-          break;
-        case "pinned":
-          value = comment.isPinned();
-          break;
-        case "content":
-          value = comment.getContent();
-          break;
-        case "removed":
-          value = comment.isDeleted();
-          break;
-        case "coord":
-          value = getCoordinates(comment);
-          break;
-        case "removereason":
-          value = comment.getRemoveReason();
-          break;
-        case "type":
-          value = getType(comment);
-          break;
-        case "icon":
-          value = IconManager.getInstance().getCommentIcon();
-          break;
-        case "author":
-          value = comment.getName();
-          break;
-        case "email":
-          value = comment.getEmail();
-          break;
-        default:
-          value = "Unknown column";
+      case "id":
+      case "idobject":
+        value = comment.getId();
+        break;
+      case "elementid":
+        value = getId(comment);
+        break;
+      case "modelid":
+        value = comment.getSubmodelData().getId();
+        break;
+      case "title":
+        value = getTitle(comment);
+        break;
+      case "pinned":
+        value = comment.isPinned();
+        break;
+      case "content":
+        value = comment.getContent();
+        break;
+      case "removed":
+        value = comment.isDeleted();
+        break;
+      case "coord":
+        value = getCoordinates(comment);
+        break;
+      case "removereason":
+        value = comment.getRemoveReason();
+        break;
+      case "type":
+        value = getType(comment);
+        break;
+      case "icon":
+        value = "icons/comment.png?v=" + Configuration.getSystemBuildVersion(null);
+        break;
+      case "author":
+        value = comment.getName();
+        break;
+      case "email":
+        value = comment.getEmail();
+        break;
+      default:
+        value = "Unknown column";
       }
       result.put(string, value);
     }
@@ -247,7 +245,7 @@ public class CommentRestImpl extends BaseRestImpl {
   }
 
   public Map<String, Object> addComment(String projectId, String elementType, String elementId,
-                                        String name, String email, String content, boolean pinned, Point2D pointCoordinates, String submodelId)
+      String name, String email, String content, boolean pinned, Point2D pointCoordinates, String submodelId)
       throws QueryException {
     Model model = getModelService().getLastModelByProjectId(projectId);
     if (model == null) {
diff --git a/service/src/main/java/lcsb/mapviewer/services/overlay/IconManager.java b/service/src/main/java/lcsb/mapviewer/services/overlay/IconManager.java
deleted file mode 100644
index 7cf52eb49e..0000000000
--- a/service/src/main/java/lcsb/mapviewer/services/overlay/IconManager.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package lcsb.mapviewer.services.overlay;
-
-import org.apache.commons.lang3.mutable.MutableInt;
-
-import lcsb.mapviewer.common.Configuration;
-
-/**
- * This class return links to icons used by the client. It might be good idea to
- * move part of the functionality to client side as server shouldn't decide
- * about representation layer.
- * 
- * @author Piotr Gawron
- * 
- */
-public final class IconManager {
-	/**
-	 * Max index of the image.
-	 */
-	private static final int		MAX_INDEX	= 99;
-
-	/**
-	 * Colors available for bubble icons.
-	 */
-	private String[]						colors		= { "red", "blue", "green", "purple", "yellow", "pink", "paleblue", "brown", "orange" };
-
-	/**
-	 * Singelton.
-	 */
-	private static IconManager	manager;
-
-	/**
-	 * Default singleton constructor.
-	 */
-	private IconManager() {
-
-	}
-
-	/**
-	 * Returns only available instance of this class.
-	 * 
-	 * @return singletone instance
-	 */
-	public static IconManager getInstance() {
-		if (manager == null) {
-			manager = new IconManager();
-		}
-		return manager;
-	}
-
-	/**
-	 * Returns path to the search icon with the given index.
-	 * 
-	 * @param index
-	 *          identifier of the icon
-	 * @param type
-	 *          type of the icon to be generated
-	 * @param colorSet
-	 *          number of the color set that should be used in the generasted icon
-	 *          (number is influenced by {@link IconType#startingColorSet}
-	 * 
-	 * @return path to the icon
-	 */
-	public String getIconForIndex(MutableInt index, IconType type, int colorSet) {
-		return getIconForIndex(index.toInteger(), type, colorSet);
-	}
-
-	/**
-	 * Returns path to the search icon with the given index.
-	 * 
-	 * @param index
-	 *          identifier of the icon
-	 * @param type
-	 *          type of the icon to be generated
-	 * @param colorSet
-	 *          number of the color set that should be used in the generasted icon
-	 *          (number is influenced by {@link IconType#startingColorSet}
-	 * 
-	 * @return path to the icon
-	 */
-	public String getIconForIndex(int index, IconType type, int colorSet) {
-		String color = normalizeColor(colorSet + type.getStartingColorSet());
-		index = normalizeIndex(index);
-		String result = "marker/" + type.getIconFileSystemName() + "/" + type.getIconFileSystemName() + "_" + color + "_" + index + ".png";
-		return result;
-	}
-
-	/**
-	 * Returns index of the icon that is not out of the range.
-	 * 
-	 * @param index
-	 *          original index
-	 * @return index of the icon that is not out of the range
-	 */
-	public int normalizeIndex(int index) {
-		return (index % MAX_INDEX) + 1;
-	}
-
-	/**
-	 * Returns color set of the icon that is not out of the range.
-	 * 
-	 * @param set
-	 *          original index of the color set
-	 * @return index of the color set that is not out of the range
-	 */
-	private String normalizeColor(int set) {
-		return colors[Math.abs(set % colors.length)];
-	}
-
-	/**
-	 * Returns path to empty icon.
-	 * 
-	 * @return path to empty icon
-	 */
-	public String getEmpyIcon() {
-		return "marker/empty.png";
-	}
-
-	/**
-	 * Returns path to delete icon.
-	 * 
-	 * @return path to delete icon
-	 */
-	public String getDeleteIcon() {
-		return "icons/delete.png";
-	}
-
-	/**
-	 * Returns path to icon that indicate similarity search.
-	 * 
-	 * @return path to icon that indicate similarity search
-	 */
-	public String getSimilarIcon() {
-		return "icons/gunsight.png";
-	}
-
-	/**
-	 * Returns path to comment icon.
-	 * 
-	 * @return path to comment icon
-	 */
-	public String getCommentIcon() {
-		return "icons/comment.png?v="+Configuration.getSystemBuildVersion(null);
-	}
-}
diff --git a/service/src/main/java/lcsb/mapviewer/services/overlay/IconType.java b/service/src/main/java/lcsb/mapviewer/services/overlay/IconType.java
deleted file mode 100644
index ef96af73c4..0000000000
--- a/service/src/main/java/lcsb/mapviewer/services/overlay/IconType.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package lcsb.mapviewer.services.overlay;
-
-/**
- * Type of the icon that is returned to the client.
- * 
- * @author Piotr Gawron
- *
- */
-public enum IconType {
-
-	/**
-	 * Search result.
-	 */
-	SEARCH("marker", 0),
-
-	/**
-	 * Result of the drug search.
-	 */
-	DRUG("drug", 5),
-	/**
-	 * Result of the drug search.
-	 */
-	CHEMICAL("ball", 1),
-	/**
-	 * Result of the drug search.
-	 */
-	MI_RNA("target", 2);
-
-	/**
-	 * Name of the icons in filesystem.
-	 */
-	private String	iconFileSystemName;
-
-	/**
-	 * Color set starting index from which generasted icons should start for given
-	 * type.
-	 */
-	private int			startingColorSet;
-
-	/**
-	 * Default constructor.
-	 * 
-	 * @param name
-	 *          {@link #iconFileSystemName}
-	 * @param startColorSet
-	 *          {@link #startingColorSet}
-	 */
-	IconType(String name, int startColorSet) {
-		this.iconFileSystemName = name;
-		this.startingColorSet = startColorSet;
-	}
-
-	/**
-	 * @return the iconFileSystemName
-	 * @see #iconFileSystemName
-	 */
-	public String getIconFileSystemName() {
-		return iconFileSystemName;
-	}
-
-	/**
-	 * @return the startingColorSet
-	 * @see #startingColorSet
-	 */
-	public int getStartingColorSet() {
-		return startingColorSet;
-	}
-}
diff --git a/service/src/test/java/lcsb/mapviewer/services/overlay/AllOverlayTests.java b/service/src/test/java/lcsb/mapviewer/services/overlay/AllOverlayTests.java
index 818d875892..0d0d1de8ce 100644
--- a/service/src/test/java/lcsb/mapviewer/services/overlay/AllOverlayTests.java
+++ b/service/src/test/java/lcsb/mapviewer/services/overlay/AllOverlayTests.java
@@ -6,7 +6,6 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses({ AnnotatedObjectTreeRowTest.class,
-    IconManagerTest.class,
 })
 public class AllOverlayTests {
 
diff --git a/service/src/test/java/lcsb/mapviewer/services/overlay/IconManagerTest.java b/service/src/test/java/lcsb/mapviewer/services/overlay/IconManagerTest.java
deleted file mode 100644
index d030a8f1c4..0000000000
--- a/service/src/test/java/lcsb/mapviewer/services/overlay/IconManagerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package lcsb.mapviewer.services.overlay;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class IconManagerTest {
-
-	@Before
-	public void setUp() throws Exception {
-	}
-
-	@After
-	public void tearDown() throws Exception {
-	}
-
-	@Test
-	public void test() {
-		IconManager im = IconManager.getInstance();
-		assertNotNull(im);
-		String icon1 = im.getIconForIndex(0, IconType.SEARCH, 0);
-		String icon2 = im.getIconForIndex(1, IconType.SEARCH, 0);
-		assertFalse(icon1.equals(icon2));
-	}
-
-	@Test
-	public void test1() {
-		IconManager im = IconManager.getInstance();
-		assertNotNull(im);
-		String icon1 = im.getIconForIndex(0, IconType.SEARCH, 0);
-		String icon2 = im.getIconForIndex(0, IconType.DRUG, 0);
-		assertFalse(icon1.equals(icon2));
-	}
-
-	@Test
-	public void test2() {
-		IconManager im = IconManager.getInstance();
-		assertNotNull(im);
-		String icon1 = im.getIconForIndex(0, IconType.SEARCH, 0);
-		String icon2 = im.getIconForIndex(0, IconType.SEARCH, 1);
-		assertFalse(icon1.equals(icon2));
-	}
-
-}
-- 
GitLab