Search in sources :

Example 11 with Comment

use of de.catma.document.comment.Comment in project catma by forTEXT.

the class TPGraphProjectIndexer method searchCommentPhrase.

@Override
public QueryResult searchCommentPhrase(QueryId queryId, List<String> documentIdList, List<String> termList, int limit, List<String> unseparableCharacterSequences, List<Character> userDefinedSeparatingCharacters, Locale locale) throws Exception {
    List<Comment> comments = commentProvider.getComments(documentIdList);
    QueryResultRowArray result = new QueryResultRowArray();
    for (Comment comment : comments) {
        if (termList.size() == 1 && termList.get(0).equals("%")) {
            result.add(new CommentQueryResultRow(queryId, comment));
        } else {
            TermExtractor termExtractor = new TermExtractor(comment.getBody(), unseparableCharacterSequences, userDefinedSeparatingCharacters, locale);
            List<String> commentTerms = termExtractor.getTermsInOrder();
            if (matches(commentTerms, termList)) {
                result.add(new CommentQueryResultRow(queryId, comment));
            } else {
                for (Reply reply : comment.getReplies()) {
                    TermExtractor replyTermExtractor = new TermExtractor(reply.getBody(), unseparableCharacterSequences, userDefinedSeparatingCharacters, locale);
                    List<String> replyTerms = replyTermExtractor.getTermsInOrder();
                    if (matches(replyTerms, termList)) {
                        result.add(new CommentQueryResultRow(queryId, comment));
                        break;
                    }
                }
            }
        }
    }
    return result;
}
Also used : Comment(de.catma.document.comment.Comment) CommentQueryResultRow(de.catma.queryengine.result.CommentQueryResultRow) TermExtractor(de.catma.indexer.TermExtractor) Reply(de.catma.document.comment.Reply) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray)

Example 12 with Comment

use of de.catma.document.comment.Comment in project catma by forTEXT.

the class TaggerView method handleReplyChange.

@Subscribe
public void handleReplyChange(ReplyChangeEvent replyChangeEvent) {
    switch(replyChangeEvent.getChangeType()) {
        case CREATED:
            {
                try {
                    tagger.addReply(replyChangeEvent.getComment(), replyChangeEvent.getReply());
                } catch (IOException e) {
                    errorHandler.showAndLogError("Error adding Reply!", e);
                }
                break;
            }
        case UPDATED:
            {
                try {
                    tagger.updateReply(replyChangeEvent.getComment(), replyChangeEvent.getReply());
                } catch (IOException e) {
                    errorHandler.showAndLogError("Error updating Reply!", e);
                }
                break;
            }
        case DELETED:
            {
                try {
                    tagger.removeReply(replyChangeEvent.getComment(), replyChangeEvent.getReply());
                } catch (IOException e) {
                    errorHandler.showAndLogError("Error removing Reply!", e);
                }
                break;
            }
    }
    try {
        if (commentTopic != null) {
            Comment comment = replyChangeEvent.getComment();
            ClientComment clientComment = new ClientComment(comment.getUuid(), comment.getUsername(), comment.getUserId(), comment.getBody(), comment.getReplyCount(), comment.getRanges().stream().map(r -> new TextRange(r.getStartPoint(), r.getEndPoint())).collect(Collectors.toList()));
            Reply reply = replyChangeEvent.getReply();
            ClientCommentReply clientCommentReply = new ClientCommentReply(reply.getUuid(), reply.getBody(), reply.getUsername(), reply.getUserId(), reply.getCommentUuid());
            commentTopic.publish(new CommentMessage(comment.getId(), comment.getIid(), project.getUser().getUserId(), clientComment, comment.getDocumentId(), replyChangeEvent.getChangeType() == ChangeType.DELETED, reply.getId(), clientCommentReply));
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "error publishing a comment message", e);
    }
}
Also used : ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) Comment(de.catma.document.comment.Comment) ClientCommentReply(de.catma.ui.client.ui.tagger.shared.ClientCommentReply) CommentMessage(de.catma.ui.events.CommentMessage) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) ClientCommentReply(de.catma.ui.client.ui.tagger.shared.ClientCommentReply) Reply(de.catma.document.comment.Reply) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) IOException(java.io.IOException) ValueOutOfBoundsException(com.vaadin.ui.Slider.ValueOutOfBoundsException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) Subscribe(com.google.common.eventbus.Subscribe)

Example 13 with Comment

use of de.catma.document.comment.Comment in project catma by forTEXT.

the class TaggerView method handleCommentChange.

@Subscribe
public void handleCommentChange(CommentChangeEvent commentChangeEvent) {
    switch(commentChangeEvent.getChangeType()) {
        case CREATED:
            {
                try {
                    comments.add(commentChangeEvent.getComment());
                    tagger.addComment(commentChangeEvent.getComment());
                } catch (IOException e) {
                    errorHandler.showAndLogError("Error adding Comment!", e);
                }
                break;
            }
        case UPDATED:
            {
                tagger.updateComment(commentChangeEvent.getComment());
                break;
            }
        case DELETED:
            {
                this.comments.remove(commentChangeEvent.getComment());
                tagger.removeComment(commentChangeEvent.getComment());
                break;
            }
    }
    try {
        if (commentTopic != null) {
            Comment comment = commentChangeEvent.getComment();
            ClientComment clientComment = new ClientComment(comment.getUuid(), comment.getUsername(), comment.getUserId(), comment.getBody(), comment.getReplyCount(), comment.getRanges().stream().map(r -> new TextRange(r.getStartPoint(), r.getEndPoint())).collect(Collectors.toList()));
            commentTopic.publish(new CommentMessage(comment.getId(), comment.getIid(), project.getUser().getUserId(), clientComment, comment.getDocumentId(), commentChangeEvent.getChangeType() == ChangeType.DELETED));
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "error publishing a comment message", e);
    }
}
Also used : ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) Comment(de.catma.document.comment.Comment) CommentMessage(de.catma.ui.events.CommentMessage) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) IOException(java.io.IOException) ValueOutOfBoundsException(com.vaadin.ui.Slider.ValueOutOfBoundsException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) Subscribe(com.google.common.eventbus.Subscribe)

Example 14 with Comment

use of de.catma.document.comment.Comment in project catma by forTEXT.

the class TaggerView method removeReplyToComment.

public void removeReplyToComment(Optional<Comment> optionalComment, String replyUuid) {
    if (optionalComment.isPresent()) {
        Comment comment = optionalComment.get();
        Reply reply = comment.getReply(replyUuid);
        if (reply != null) {
            ConfirmDialog.show(UI.getCurrent(), "Remove Reply", "Are you sure you want to remove the Reply?", "Yes", "Cancel", dlg -> {
                if (dlg.isConfirmed()) {
                    try {
                        project.removeReply(optionalComment.get(), reply);
                    } catch (IOException e) {
                        errorHandler.showAndLogError("Error removing Comment!", e);
                    }
                }
            });
        } else {
            Notification.show("Info", "Couldn't find a Reply to remove!", Type.HUMANIZED_MESSAGE);
        }
    } else {
        Notification.show("Info", "Couldn't find the Comment of the Reply!", Type.HUMANIZED_MESSAGE);
    }
}
Also used : ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) Comment(de.catma.document.comment.Comment) ClientCommentReply(de.catma.ui.client.ui.tagger.shared.ClientCommentReply) Reply(de.catma.document.comment.Reply) IOException(java.io.IOException)

Example 15 with Comment

use of de.catma.document.comment.Comment in project catma by forTEXT.

the class Pager method addComment.

public ClientComment addComment(Comment comment) {
    List<TextRange> absoluteRanges = comment.getRanges().stream().map(range -> new TextRange(range.getStartPoint(), range.getEndPoint())).collect(Collectors.toList());
    List<Page> pages = getPagesForAbsoluteTextRanges(absoluteRanges);
    for (Page page : pages) {
        page.addAbsoluteComment(comment);
    }
    if (pages.contains(getCurrentPage())) {
        Page currentPage = getCurrentPage();
        List<TextRange> overlappingRelativRanges = new ArrayList<>();
        for (Range absoluteRange : comment.getRanges()) {
            Range overlappingAbsoluteRange = currentPage.getOverlappingRange(absoluteRange);
            if (overlappingAbsoluteRange != null) {
                TextRange overlappingRelativeRange = currentPage.getRelativeRangeFor(overlappingAbsoluteRange);
                overlappingRelativRanges.add(new TextRange(overlappingRelativeRange));
            }
        }
        return new ClientComment(comment.getUuid(), comment.getUsername(), comment.getUserId(), comment.getBody(), comment.getReplyCount(), overlappingRelativRanges);
    } else {
        return null;
    }
}
Also used : Range(de.catma.document.Range) Iterator(java.util.Iterator) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ClientTagInstance(de.catma.ui.client.ui.tagger.shared.ClientTagInstance) List(java.util.List) Matcher(java.util.regex.Matcher) Comment(de.catma.document.comment.Comment) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) TagDefinition(de.catma.tag.TagDefinition) Optional(java.util.Optional) CRC32(java.util.zip.CRC32) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) ArrayList(java.util.ArrayList) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) Range(de.catma.document.Range) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange)

Aggregations

Comment (de.catma.document.comment.Comment)15 IOException (java.io.IOException)10 ClientComment (de.catma.ui.client.ui.tagger.shared.ClientComment)8 Reply (de.catma.document.comment.Reply)6 TextRange (de.catma.ui.client.ui.tagger.shared.TextRange)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Subscribe (com.google.common.eventbus.Subscribe)3 ValueOutOfBoundsException (com.vaadin.ui.Slider.ValueOutOfBoundsException)3 CommentMessage (de.catma.ui.events.CommentMessage)3 User (de.catma.user.User)3 GitLabApiException (org.gitlab4j.api.GitLabApiException)3 IssuesApi (org.gitlab4j.api.IssuesApi)3 Issue (org.gitlab4j.api.models.Issue)3 UI (com.vaadin.ui.UI)2 CommentQueryResultRow (de.catma.queryengine.result.CommentQueryResultRow)2 TagDefinition (de.catma.tag.TagDefinition)2 ClientCommentReply (de.catma.ui.client.ui.tagger.shared.ClientCommentReply)2 IDGenerator (de.catma.util.IDGenerator)2 URISyntaxException (java.net.URISyntaxException)2