Search in sources :

Example 1 with BasicCommentEvent

use of com.cloudogu.scm.review.comment.service.BasicCommentEvent in project scm-review-plugin by scm-manager.

the class RemoveReviewMarksOnChangedCommentsHook method checkForLocation.

private <C extends BasicComment, T extends BasicCommentEvent<C>> void checkForLocation(T event, Function<C, Location> locationExtractor) {
    if (event.getEventType() == HandlerEventType.DELETE) {
        return;
    }
    Location location = locationExtractor.apply(event.getItem());
    if (location == null) {
        return;
    }
    Collection<ReviewMark> reviewMarksToBeRemoved = event.getPullRequest().getReviewMarks().stream().filter(mark -> mark.getFile().equals(location.getFile())).collect(Collectors.toList());
    pullRequestService.removeReviewMarks(event.getRepository(), event.getPullRequest().getId(), reviewMarksToBeRemoved);
}
Also used : EagerSingleton(sonia.scm.EagerSingleton) Collection(java.util.Collection) BasicComment(com.cloudogu.scm.review.comment.service.BasicComment) Subscribe(com.github.legman.Subscribe) Extension(sonia.scm.plugin.Extension) ReplyEvent(com.cloudogu.scm.review.comment.service.ReplyEvent) Repository(sonia.scm.repository.Repository) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) BasicCommentEvent(com.cloudogu.scm.review.comment.service.BasicCommentEvent) CommentEvent(com.cloudogu.scm.review.comment.service.CommentEvent) Inject(javax.inject.Inject) Objects(java.util.Objects) HandlerEventType(sonia.scm.HandlerEventType) Reply(com.cloudogu.scm.review.comment.service.Reply) Comment(com.cloudogu.scm.review.comment.service.Comment) CommentService(com.cloudogu.scm.review.comment.service.CommentService) Location(com.cloudogu.scm.review.comment.service.Location) Location(com.cloudogu.scm.review.comment.service.Location)

Aggregations

BasicComment (com.cloudogu.scm.review.comment.service.BasicComment)1 BasicCommentEvent (com.cloudogu.scm.review.comment.service.BasicCommentEvent)1 Comment (com.cloudogu.scm.review.comment.service.Comment)1 CommentEvent (com.cloudogu.scm.review.comment.service.CommentEvent)1 CommentService (com.cloudogu.scm.review.comment.service.CommentService)1 Location (com.cloudogu.scm.review.comment.service.Location)1 Reply (com.cloudogu.scm.review.comment.service.Reply)1 ReplyEvent (com.cloudogu.scm.review.comment.service.ReplyEvent)1 Subscribe (com.github.legman.Subscribe)1 Collection (java.util.Collection)1 Objects (java.util.Objects)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 EagerSingleton (sonia.scm.EagerSingleton)1 HandlerEventType (sonia.scm.HandlerEventType)1 Extension (sonia.scm.plugin.Extension)1 Repository (sonia.scm.repository.Repository)1