MCPcopy Create free account
hub / github.com/Grashjs/cmms / update

Method update

api/src/main/java/com/grash/service/CommentService.java:75–92  ·  view source on GitHub ↗
(Long id, CommentPatchDTO commentPatchDTO, User user)

Source from the content-addressed store, hash-verified

73 }
74
75 public Comment update(Long id, CommentPatchDTO commentPatchDTO, User user) {
76 Comment savedComment =
77 commentRepository.findById(id).orElseThrow(() -> new CustomException("Not found",
78 HttpStatus.NOT_FOUND));
79 if (!savedComment.getUser().getId().equals(user.getId()))
80 throw new CustomException("Access denied", HttpStatus.FORBIDDEN);
81
82 WorkOrder workOrder = savedComment.getWorkOrder();
83
84 Comment updatedComment = commentRepository.saveAndFlush(commentMapper.updateComment(savedComment,
85 commentPatchDTO));
86 em.refresh(updatedComment);
87
88 Set<User> notifiedUsers = getNotifiedUsers(updatedComment, workOrder, user);
89 sendCommentNotifications(updatedComment, workOrder, notifiedUsers, user, true);
90
91 return updatedComment;
92 }
93
94 public List<Comment> findByCriteria(CommentCriteria criteria, User user) {
95 Specification<Comment> specification = (root, query, cb) -> {

Callers

nothing calls this directly

Calls 6

getNotifiedUsersMethod · 0.95
getUserMethod · 0.80
updateCommentMethod · 0.80
findByIdMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected