/** * Delete an Issue Note * * @param issue The issue * @param noteToDelete The note to delete * @throws IOException on gitlab api call error */ public void deleteNote(GitlabIssue issue, GitlabNote noteToDelete) throws IOException { deleteNote(String.valueOf(issue.getProjectId()), issue.getId(), noteToDelete); }
public GitlabNote createNote(GitlabIssue issue, String message) throws IOException { return createNote(String.valueOf(issue.getProjectId()), issue.getIid(), message); }
private GitLabIssue createGitLabIssue(String projectUrl, GitlabIssue candidate) { String title = candidate.getTitle(); String link = projectUrl + "/issues/" + candidate.getIid(); List<String> labels = new ArrayList<>(); for (String l : candidate.getLabels()) { labels.add(l); } return new GitLabIssue(title, link, labels); }
GitlabConnection connection = ConnectionManager.get(repository); TaskData data = new TaskData(connection.mapper, GitlabPluginCore.CONNECTOR_KIND, repository.getUrl(), "" + issue.getIid()); String labels = StringUtils.join(issue.getLabels(), ", "); root.getAttribute(GitlabAttribute.AUTHOR.getTaskKey()).setValue(issue.getAuthor().getName()); root.getAttribute(GitlabAttribute.CREATED.getTaskKey()).setValue("" + issue.getCreatedAt().getTime()); root.getAttribute(GitlabAttribute.BODY.getTaskKey()).setValue(issue.getDescription() == null ? "" : issue.getDescription()); root.getAttribute(GitlabAttribute.LABELS.getTaskKey()).setValue(labels); root.getAttribute(GitlabAttribute.PROJECT.getTaskKey()).setValue(connection.project.getName()); root.getAttribute(GitlabAttribute.STATUS.getTaskKey()).setValue(issue.getState()); root.getAttribute(GitlabAttribute.TITLE.getTaskKey()).setValue(issue.getTitle()); root.getAttribute(GitlabAttribute.IID.getTaskKey()).setValue("" + issue.getIid()); root.getAttribute(GitlabAttribute.PRIORITY.getTaskKey()).setValue(getPriority(labels)); root.getAttribute(GitlabAttribute.TYPE.getTaskKey()).setValue(getType(labels)); if(issue.getMilestone() != null) { root.getAttribute(GitlabAttribute.MILESTONE.getTaskKey()).setValue(issue.getMilestone().getTitle()); if(issue.getUpdatedAt() != null) { root.getAttribute(GitlabAttribute.UPDATED.getTaskKey()).setValue("" + issue.getUpdatedAt().getTime()); if(issue.getState().equals(GitlabIssue.STATE_CLOSED)) { root.getAttribute(GitlabAttribute.COMPLETED.getTaskKey()).setValue("" + issue.getUpdatedAt().getTime()); if(issue.getAssignee() != null) { root.getAttribute(GitlabAttribute.ASSIGNEE.getTaskKey()).setValue(issue.getAssignee().getName());
public boolean doesMatch(GitlabIssue issue) { if(!assignee.equals("") && (issue.getAssignee() == null || !( assignee.equals(issue.getAssignee().getUsername()) || assignee.equals(issue.getAssignee().getName())))) { return false; (issue.getMilestone() == null || !milestone.equals(issue.getMilestone().getTitle()))) { return false; for(String label : issue.getLabels()) { if(p.matcher(label).find()) { matchedLabels.add(p); if(!closed && issue.getState().equals(GitlabIssue.STATE_CLOSED)) { return false; if(!opened && issue.getState().equals(GitlabIssue.STATE_OPENED)) { return false;
@Override public String getDisplayKey() { return "#" + gitlabIssue.getId(); }
public Optional<GitLabIssue> getIssue(String projectName, Integer matchedIssue) throws GitChangelogIntegrationException { GitlabAPI gitLabApi = GitlabAPI.connect(hostUrl, apiToken); GitlabProject project; try { project = gitLabApi.getProject(projectName); } catch (Exception e) { throw new GitChangelogIntegrationException( "Unable to find project \"" + projectName + "\". It should be \"tomas.bjerre85/violations-test\" for a repo like: https://gitlab.com/tomas.bjerre85/violations-test", e); } Integer projectId = project.getId(); String httpUrl = project.getHttpUrl(); try { List<GitlabIssue> issues = cache.get(new GitLabProjectIssuesCacheKey(hostUrl, apiToken, projectId)); for (GitlabIssue candidate : issues) { if (candidate.getIid() == matchedIssue) { return Optional.of(createGitLabIssue(httpUrl, candidate)); } } return Optional.absent(); } catch (Exception e) { throw new GitChangelogIntegrationException(e.getMessage(), e); } }
@Override public String getSummary() { return gitlabIssue.getTitle(); }
public List<String> getLabels() { return Arrays.asList(gitlabIssue.getLabels()); } }
/** * Returns all valid actions for the given issue. * @param issue * @return */ public static GitlabAction[] getActions(GitlabIssue issue) { if(issue.getState().equals(GitlabIssue.STATE_CLOSED)) { return closed; } else { return opened; } }
@Override public LocalDateTime getUpdateTime() { return Time.from(gitlabIssue.getUpdatedAt(), null); }
@Override public GitLabIssueWrapper getIssue(String repository, int id) { try { // Issue String issueUrl = configuration.getUrl() + "/" + repository + GitlabIssue.URL + "/" + id; GitlabIssue issue = api.getIssue(repository, id); // Milestone URL String milestoneUrl = null; if (issue.getMilestone() != null) { milestoneUrl = configuration.getUrl() + "/" + repository + GitlabMilestone.URL + "/" + issue.getMilestone().getId(); } // OK return GitLabIssueWrapper.of(issue, milestoneUrl, issueUrl); } catch (IOException e) { throw new OntrackGitLabClientException(e); } }
@Override public String getKey() { return String.valueOf(gitlabIssue.getId()); }
@Override public IssueStatus getStatus() { return new GitLabIssueStatusWrapper(gitlabIssue.getState()); }
/** * Delete an Issue Note * * @param issue The issue * @param noteToDelete The note to delete * @throws IOException on gitlab api call error */ public void deleteNote(GitlabIssue issue, GitlabNote noteToDelete) throws IOException { deleteNote(String.valueOf(issue.getProjectId()), issue.getId(), noteToDelete); }
public GitlabNote createNote(GitlabIssue issue, String message) throws IOException { return createNote(String.valueOf(issue.getProjectId()), issue.getIid(), message); }
/** * Delete an Issue Note * * @param issue The issue * @param noteToDelete The note to delete * @throws IOException on gitlab api call error */ public void deleteNote(GitlabIssue issue, GitlabNote noteToDelete) throws IOException { deleteNote(String.valueOf(issue.getProjectId()), issue.getId(), noteToDelete); }
public GitlabNote createNote(GitlabIssue issue, String message) throws IOException { return createNote(String.valueOf(issue.getProjectId()), issue.getIid(), message); }
/** * Get all awards for an issue note * * @param issue * @param noteId */ public List<GitlabAward> getAllAwards(GitlabIssue issue, Integer noteId) { String tailUrl = GitlabProject.URL + "/" + issue.getProjectId() + GitlabIssue.URL + "/" + issue.getId() + GitlabNote.URL + noteId + GitlabAward.URL + PARAM_MAX_ITEMS_PER_PAGE; return retrieve().getAll(tailUrl, GitlabAward[].class); }