Commit a1e3d12f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

removed changed to Boolean

parent ff2746ae
......@@ -57,7 +57,7 @@ public class CommentController extends BaseController {
@PathVariable(value = "projectId") String projectId,
@RequestParam(value = "columns", defaultValue = "") String columns,
@PathVariable(value = "modelId") String modelId,
@RequestParam(value = "removed", defaultValue = "") String removed) throws QueryException {
@RequestParam(value = "removed", required = false) Boolean removed) throws QueryException {
boolean isAdmin = authentication.getAuthorities()
.contains(new SimpleGrantedAuthority(PrivilegeType.IS_ADMIN.name()));
boolean isProjectCurator = authentication.getAuthorities()
......@@ -101,7 +101,7 @@ public class CommentController extends BaseController {
@RequestParam(value = "columns", defaultValue = "") String columns,
@PathVariable(value = "modelId") String modelId,
@PathVariable(value = "reactionId") String reactionId,
@RequestParam(value = "removed", defaultValue = "") String removed) throws QueryException {
@RequestParam(value = "removed", required = false) Boolean removed) throws QueryException {
return commentController.getCommentList(projectId, columns, reactionId,
ElementIdentifierType.REACTION, removed, modelId);
}
......@@ -117,7 +117,7 @@ public class CommentController extends BaseController {
@RequestParam(value = "columns", defaultValue = "") String columns,
@PathVariable(value = "elementId") String elementId,
@PathVariable(value = "modelId") String modelId,
@RequestParam(value = "removed", defaultValue = "") String removed) throws QueryException {
@RequestParam(value = "removed", required = false) Boolean removed) throws QueryException {
return commentController.getCommentList(
projectId, columns, elementId, ElementIdentifierType.ALIAS, removed, modelId);
}
......@@ -133,7 +133,7 @@ public class CommentController extends BaseController {
@RequestParam(value = "columns", defaultValue = "") String columns,
@PathVariable(value = "coordinates") String coordinates,
@PathVariable(value = "modelId") String modelId,
@RequestParam(value = "removed", defaultValue = "") String removed) throws QueryException {
@RequestParam(value = "removed", required = false) Boolean removed) throws QueryException {
return commentController.getCommentList(projectId, columns, coordinates,
ElementIdentifierType.POINT, removed, modelId);
}
......@@ -154,7 +154,7 @@ public class CommentController extends BaseController {
if (user.getLogin().equals(Configuration.ANONYMOUS_LOGIN)) {
user = null;
}
return commentController.addComment(projectId, ElementIdentifierType.ALIAS.getJsName(), elementId,
return commentController.addComment(projectId, ElementIdentifierType.ALIAS.getJsName(), elementId,
email, content, pinned.toLowerCase().equals("true"), pointCoordinates, modelId, user);
}
......@@ -173,7 +173,7 @@ public class CommentController extends BaseController {
if (user.getLogin().equals(Configuration.ANONYMOUS_LOGIN)) {
user = null;
}
return commentController.addComment(projectId, ElementIdentifierType.REACTION.getJsName(), reactionId,
return commentController.addComment(projectId, ElementIdentifierType.REACTION.getJsName(), reactionId,
email, content, pinned.toLowerCase().equals("true"), pointCoordinates, modelId, user);
}
......@@ -191,7 +191,7 @@ public class CommentController extends BaseController {
if (user.getLogin().equals(Configuration.ANONYMOUS_LOGIN)) {
user = null;
}
return commentController.addComment(projectId, ElementIdentifierType.POINT.getJsName(), coordinates,
return commentController.addComment(projectId, ElementIdentifierType.POINT.getJsName(), coordinates,
email, content, pinned.toLowerCase().equals("true"), pointCoordinates, modelId, user);
}
......
......@@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.api.BaseRestImpl;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.common.geometry.PointTransformation;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.Comment;
......@@ -61,7 +60,7 @@ public class CommentRestImpl extends BaseRestImpl {
public List<Map<String, Object>> getCommentList(
String projectId, String columns, String elementId,
ElementIdentifierType elementType, String removed, String modelId) throws QueryException {
ElementIdentifierType elementType, Boolean removed, String modelId) throws QueryException {
Project project = getProjectService().getProjectByProjectId(projectId);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
......@@ -73,7 +72,7 @@ public class CommentRestImpl extends BaseRestImpl {
List<Comment> comments = commentService.getCommentsByModel(project, modelId);
for (Comment comment : comments) {
boolean reject = false;
if (elementType!=null) {
if (elementType != null) {
switch (elementType) {
case POINT: {
reject = comment.getTableName() != null;
......@@ -95,9 +94,8 @@ public class CommentRestImpl extends BaseRestImpl {
Object id = getId(comment).toString();
reject |= (!elementId.equals(id));
}
if (!"".equals(removed)) {
boolean expectedRemoved = removed.equalsIgnoreCase("true");
reject |= (comment.isDeleted() != expectedRemoved);
if (removed != null) {
reject |= (comment.isDeleted() != removed);
}
if (!reject) {
result.add(preparedComment(comment, columnsSet));
......@@ -114,52 +112,52 @@ 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.getModelData().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 "email":
value = comment.getEmail();
break;
case "owner":
if (comment.getUser() != null) {
value = comment.getUser().getLogin();
} else {
value = null;
}
break;
default:
value = "Unknown column";
case "id":
case "idobject":
value = comment.getId();
break;
case "elementid":
value = getId(comment);
break;
case "modelid":
value = comment.getModelData().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 "email":
value = comment.getEmail();
break;
case "owner":
if (comment.getUser() != null) {
value = comment.getUser().getLogin();
} else {
value = null;
}
break;
default:
value = "Unknown column";
}
result.put(string, value);
}
......
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