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;
}
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);
}
}
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);
}
}
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);
}
}
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;
}
}
Aggregations