Search in sources :

Example 1 with Comments

use of org.sonarqube.ws.Issues.Comments in project sonarqube by SonarSource.

the class SearchResponseFormat method formatIssueComments.

private static void formatIssueComments(SearchResponseData data, Issue.Builder wsIssue, IssueDto dto) {
    Comments.Builder wsComments = Comments.newBuilder();
    List<IssueChangeDto> comments = data.getCommentsForIssueKey(dto.getKey());
    if (comments != null) {
        Comment.Builder wsComment = Comment.newBuilder();
        for (IssueChangeDto comment : comments) {
            String markdown = comment.getChangeData();
            wsComment.clear().setKey(comment.getKey()).setUpdatable(data.isUpdatableComment(comment.getKey())).setCreatedAt(DateUtils.formatDateTime(new Date(comment.getIssueChangeCreationDate())));
            ofNullable(data.getUserByUuid(comment.getUserUuid())).ifPresent(user -> wsComment.setLogin(user.getLogin()));
            if (markdown != null) {
                wsComment.setHtmlText(Markdown.convertToHtml(markdown)).setMarkdown(markdown);
            }
            wsComments.addComments(wsComment);
        }
    }
    wsIssue.setComments(wsComments);
}
Also used : IssueChangeDto(org.sonar.db.issue.IssueChangeDto) Comment(org.sonarqube.ws.Common.Comment) Comments(org.sonarqube.ws.Issues.Comments) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 IssueChangeDto (org.sonar.db.issue.IssueChangeDto)1 Comment (org.sonarqube.ws.Common.Comment)1 Comments (org.sonarqube.ws.Issues.Comments)1