diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java index 5681b467302d38e63965f60274439001e3562646..cb1d33bfb3b833cdd8dfc1e18c33157f94c2d47c 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java @@ -29,8 +29,6 @@ import lcsb.mapviewer.services.interfaces.ICommentService; import lcsb.mapviewer.services.interfaces.IConfigurationService; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.IUserService; -import lcsb.mapviewer.services.search.comment.FullCommentView; -import lcsb.mapviewer.services.search.comment.FullCommentViewFactory; import lcsb.mapviewer.services.utils.EmailSender; /** @@ -255,26 +253,6 @@ public class CommentService implements ICommentService { this.configurationService = configurationService; } - /** - * Creates list of {@link CustomCommentMarker} that represents agregated - * comments. - * - * @param comments - * agregated comments (every list contains comments for single element) - * @param topModel - * model which is commented - * @return list of {@link CustomCommentMarker} that represents agregated - * comments - */ - protected List<FullCommentView> agregatedCommentsIntoMarker(List<List<Comment>> comments, Model topModel) { - List<FullCommentView> result = new ArrayList<>(); - FullCommentViewFactory factory = new FullCommentViewFactory(); - for (List<Comment> list : comments) { - result.add(factory.create(list)); - } - return result; - } - @Override public void removeCommentsForModel(ModelData model) { List<Comment> comments = commentDao.getCommentByModel(model, null, null); diff --git a/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentView.java b/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentView.java deleted file mode 100644 index 871f7150b1283c56cc0f49f63839aee84398e0c7..0000000000000000000000000000000000000000 --- a/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentView.java +++ /dev/null @@ -1,97 +0,0 @@ -package lcsb.mapviewer.services.search.comment; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import lcsb.mapviewer.common.Pair; -import lcsb.mapviewer.services.search.ISearchResultView; - -/** - * This class represent data that are sent into the client (by designe Google - * Map object, but not necessery). It is connected to the comment on the map. It - * contains information required for vizualization like localization - * information. However, there are no information about formating, css, etc. - * - * @author Piotr Gawron - * - */ -public class FullCommentView extends LightCommentView implements ISearchResultView { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * List of comments in the marker. {@link Pair#left} is id of a comment; - * {@link Pair#right} is a content. - */ - private List<Pair<String, String>> comments = new ArrayList<Pair<String, String>>(); - - /** - * Type of the object that is commented. - */ - private Class<?> type = null; - - /** - * Default constructor. - * - * @param point - * {@link Point2D} where the comment is placed - * @param idModel - * identifier of the model where comment is placed - * - */ - public FullCommentView(Point2D point, Integer idModel) { - super(point, idModel); - } - - /** - * Default constructor. - * - * @param objectId - * identifier of the element that is commented - * @param idModel - * identifier of the model where comment is placed - * - */ - public FullCommentView(Integer objectId, Integer idModel) { - super(objectId, idModel); - } - - /** - * @return the comments - * @see #comments - */ - public List<Pair<String, String>> getComments() { - return comments; - } - - /** - * @param comments - * the comments to set - * @see #comments - */ - public void setComments(List<Pair<String, String>> comments) { - this.comments = comments; - } - - /** - * @return the type - * @see #type - */ - public Class<?> getType() { - return type; - } - - /** - * @param type - * the type to set - * @see #type - */ - public void setType(Class<?> type) { - this.type = type; - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java deleted file mode 100644 index 928f73601844211250078e22b1fcd960eb6c5f51..0000000000000000000000000000000000000000 --- a/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java +++ /dev/null @@ -1,84 +0,0 @@ -package lcsb.mapviewer.services.search.comment; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import com.google.gson.Gson; - -import lcsb.mapviewer.common.Pair; -import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.Comment; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.reaction.Reaction; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.services.overlay.IconManager; -import lcsb.mapviewer.services.search.SearchResultFactory; -import lcsb.mapviewer.services.search.data.ElementIdentifier; -import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; - -/** - * Factory class for {@link FullCommentView} class. - * - * @author Piotr Gawron - * - */ -public class FullCommentViewFactory extends SearchResultFactory<List<Comment>, FullCommentView> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(FullCommentViewFactory.class); - - @Override - public FullCommentView create(List<Comment> list) { - Point2D point = new Point2D.Double(0, 0); - Comment comment = list.get(0); - Class<?> type; - FullCommentView result; - if (comment.getTableName() != null) { - result = new FullCommentView(comment.getTableId(), comment.getSubmodelData().getId()); - if (comment.getTableName().getName().contains("Reaction")) { - type = Reaction.class; - } else { - type = Element.class; - } - } else { - point.setLocation(comment.getCoordinates().getX(), comment.getCoordinates().getY()); - result = new FullCommentView(point, comment.getSubmodelData().getId()); - type = Point2D.class; - } - result.setType(type); - - for (int i = 0; i < list.size(); i++) { - Pair<String, String> pair = new Pair<String, String>("" + list.get(i).getId(), list.get(i).getContent()); - result.getComments().add(pair); - } - return result; - } - - @Override - public String createGson(FullCommentView object) { - return new Gson().toJson(object); - } - - @Override - public List<ElementIdentifier> searchResultToElementIdentifier(FullCommentView comment, Model model) { - List<ElementIdentifier> result = new ArrayList<>(); - if (Reaction.class.equals(comment.getType())) { - result - .add(new ElementIdentifier(comment.getIdObject(), comment.getModelId(), ElementIdentifierType.REACTION, IconManager.getInstance().getCommentIcon())); - } else if (Element.class.equals(comment.getType())) { - result.add(new ElementIdentifier(comment.getIdObject(), comment.getModelId(), ElementIdentifierType.ALIAS, IconManager.getInstance().getCommentIcon())); - } else if (Point2D.class.equals(comment.getType())) { - result.add(new ElementIdentifier(comment.getIdObject(), comment.getModelId(), ElementIdentifierType.POINT, IconManager.getInstance().getCommentIcon())); - } else { - throw new InvalidArgumentException("Unknown comment type: " + comment.getType()); - } - return result; - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/comment/LightCommentView.java b/service/src/main/java/lcsb/mapviewer/services/search/comment/LightCommentView.java deleted file mode 100644 index 9758b6f03a5c46a0e25c8e814b62594bb72c5420..0000000000000000000000000000000000000000 --- a/service/src/main/java/lcsb/mapviewer/services/search/comment/LightCommentView.java +++ /dev/null @@ -1,54 +0,0 @@ -package lcsb.mapviewer.services.search.comment; - -import java.awt.geom.Point2D; - -import lcsb.mapviewer.services.search.ElementView; - -/** - * Light {@link ElementView view} for comment representing data that should be - * send to client. - * - * @author Piotr Gawron - * - */ -public class LightCommentView extends ElementView { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Default constructor. - * - * @param point - * {@link Point2D} where the comment is placed - * @param idModel - * identifier of the model where comment is placed - * - */ - protected LightCommentView(Point2D point, Integer idModel) { - super(point.toString(), idModel); - } - - /** - * Default constructor. - * - * @param objectId - * identifier of the element that is commented - * @param idModel - * identifier of the model where comment is placed - * - */ - protected LightCommentView(Integer objectId, Integer idModel) { - super(objectId, idModel); - } - - /** - * Constructor that should be used only for (de)serialization. - */ - protected LightCommentView() { - super(); - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/comment/package-info.java b/service/src/main/java/lcsb/mapviewer/services/search/comment/package-info.java deleted file mode 100644 index d8e30b66a4dd7ab6d6e0982d8089914143809346..0000000000000000000000000000000000000000 --- a/service/src/main/java/lcsb/mapviewer/services/search/comment/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package contains structures used for passing data about comments to - * client. - * <p/> - * Be carefull when refactoring classes in this package. Data are accessed not - * directly (not via managable code) by client side. - */ -package lcsb.mapviewer.services.search.comment; diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java index 87178b5eb5d48808826847fc98ec436eeeddbbb2..673ade770fa33642d7af67a9a08c93210593f129 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java @@ -2,7 +2,6 @@ package lcsb.mapviewer.services.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.awt.geom.Point2D; @@ -21,7 +20,6 @@ import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; -import lcsb.mapviewer.services.search.comment.FullCommentView; @Rollback(true) public class CommentServiceTest extends ServiceTestFunctions { @@ -107,43 +105,6 @@ public class CommentServiceTest extends ServiceTestFunctions { } } - @Test - public void testAgregatedCommentsIntoMarker() throws Exception { - try { - commentService.addComment("John Doe", "a@a.pl", "Conteneta 1", model, new Point2D.Double(0, 1), alias, false, - model); - commentService.addComment("John Doe", "a@a.pl", "Contenetb 2", model, new Point2D.Double(0, 2), alias, false, - model); - commentService.addComment("John Doe", "a@a.pl", "Contenetc 3", model, new Point2D.Double(0, 3), alias2, false, - model); - commentService.addComment("John Doe", "a@a.pl", "Contenetc 4", model, new Point2D.Double(0, 4), null, false, - model); - commentService.addComment("John Doe", "a@a.pl", "Contenetc 5", model, new Point2D.Double(0, 5), null, false, - model); - CommentService service = new CommentService(); - service.setCommentDao(commentDao); - List<List<Comment>> comments = service.getAgregatedComments(model, null); - assertEquals(4, comments.size()); - - List<FullCommentView> markers = service.agregatedCommentsIntoMarker(comments, model); - assertNotNull(markers); - assertEquals(4, markers.size()); - - assertEquals(2, markers.get(0).getComments().size()); - assertEquals("Conteneta 1", markers.get(0).getComments().get(0).getRight()); - assertEquals(1, markers.get(1).getComments().size()); - - List<Comment> allComments = commentDao.getCommentByModel(model, null, null); - assertEquals(5, allComments.size()); - for (Comment comment : allComments) { - commentDao.delete(comment); - } - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - @Test public void testAddComment() throws Exception { try {