Commit 1d5f980b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

old unused code removed

parent ca477399
......@@ -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) {
......
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);
}
}
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;
}
}
......@@ -6,7 +6,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ AnnotatedObjectTreeRowTest.class,
IconManagerTest.class,
})
public class AllOverlayTests {
......
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));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment