Skip to content
Snippets Groups Projects
Commit 08b130fb authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unused LightCommentView removed

parent 7c16a02e
No related branches found
No related tags found
1 merge request!207Resolve "remove unused JSF code"
......@@ -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);
......
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;
}
}
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;
}
}
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();
}
}
/**
* 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;
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment