Search in sources :

Example 1 with IssueFilter

use of org.gitlab4j.api.models.IssueFilter in project catma by forTEXT.

the class GitlabManagerRestricted method getComments.

@Override
public List<Comment> getComments(String projectId) throws IOException {
    try {
        List<Comment> result = new ArrayList<Comment>();
        IssuesApi issuesApi = new IssuesApi(restrictedGitLabApi);
        String projectPath = projectId;
        List<Issue> issues = issuesApi.getGroupIssues(projectPath, new IssueFilter().withLabels(Collections.singletonList(CATMA_COMMENT_LABEL)).withState(IssueState.OPENED));
        for (Issue issue : issues) {
            String description = issue.getDescription();
            int noteCount = issue.getUserNotesCount();
            try {
                Author author = issue.getAuthor();
                Comment comment = new SerializationHelper<Comment>().deserialize(description, Comment.class);
                comment.setId(issue.getId());
                comment.setIid(issue.getIid());
                comment.setUserId(author.getId());
                comment.setUsername(author.getName());
                comment.setReplyCount(noteCount);
                result.add(comment);
            } catch (Exception e) {
                logger.log(Level.SEVERE, String.format("Error deserializing Comment #%1$d %2$s", issue.getId(), description), e);
            }
        }
        return result;
    } catch (GitLabApiException e) {
        throw new IOException(String.format("Failed to retrieve Comments in group %1$s!", projectId), e);
    }
}
Also used : Comment(de.catma.document.comment.Comment) IssuesApi(org.gitlab4j.api.IssuesApi) Issue(org.gitlab4j.api.models.Issue) ArrayList(java.util.ArrayList) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException) IssueFilter(org.gitlab4j.api.models.IssueFilter) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException) Author(org.gitlab4j.api.models.Author)

Example 2 with IssueFilter

use of org.gitlab4j.api.models.IssueFilter in project agile-architecture-documentation-system by Riduidel.

the class GitLabTicketsHandler method getTicketsTagged.

@Override
public Collection<Ticket> getTicketsTagged(String project, String label) {
    try {
        Object projectId = gitlab.getApi().getIssuesApi().getProjectIdOrPath(project);
        IssueFilter filter = new IssueFilter();
        filter.setLabels(Arrays.asList(label));
        Collection<Ticket> returned = new ArrayList<>();
        for (Issue issue : gitlab.getApi().getIssuesApi().getIssues(filter)) {
            returned.add(new GitLabTicket(issue, gitlab.getApi().getDiscussionsApi().getIssueDiscussions(projectId, issue.getId())));
        }
        return returned;
    } catch (GitLabApiException e) {
        throw new GitLabHandlerException(String.format("Unable to et project name of %s", project), e);
    }
}
Also used : Ticket(org.ndx.agile.architecture.base.enhancers.tickets.Ticket) Issue(org.gitlab4j.api.models.Issue) ArrayList(java.util.ArrayList) GitLabApiException(org.gitlab4j.api.GitLabApiException) IssueFilter(org.gitlab4j.api.models.IssueFilter)

Example 3 with IssueFilter

use of org.gitlab4j.api.models.IssueFilter in project dash-licenses by eclipse.

the class GitLabConnection method findIssue.

public Issue findIssue(GitLabReview review) throws GitLabApiException {
    String title = review.getTitle();
    IssueFilter filter = new IssueFilter().withSearch(title).withState(IssueState.OPENED);
    return getIssuesApi().getIssuesStream(path, filter).filter(issue -> issue.getTitle().equals(title)).findAny().orElse(null);
}
Also used : IssueFilter(org.gitlab4j.api.models.IssueFilter)

Aggregations

IssueFilter (org.gitlab4j.api.models.IssueFilter)3 ArrayList (java.util.ArrayList)2 GitLabApiException (org.gitlab4j.api.GitLabApiException)2 Issue (org.gitlab4j.api.models.Issue)2 Comment (de.catma.document.comment.Comment)1 IOException (java.io.IOException)1 IssuesApi (org.gitlab4j.api.IssuesApi)1 Author (org.gitlab4j.api.models.Author)1 Ticket (org.ndx.agile.architecture.base.enhancers.tickets.Ticket)1