public Result(final Issue issue) { this.key = issue.getKey(); this.summary = issue.getSummary(); } }
@Override public Promise<Void> transition(final Issue issue, final TransitionInput transitionInput) { if (issue.getTransitionsUri() != null) { return transition(issue.getTransitionsUri(), transitionInput); } else { final UriBuilder uriBuilder = UriBuilder.fromUri(issue.getSelf()); uriBuilder.path("transitions"); return transition(uriBuilder.build(), transitionInput); } }
private void setLabels(JiraIssue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { Set<String> jiraLabels = jiraIssue.getLabels(); List<JiraLabel> labels = new ArrayList<>(); if (jiraLabels != null) jiraLabels.forEach(name -> labels.add(new JiraLabel(name))); issue.setLabels(labels); }
while (issues.hasNext()) { Issue issue = issues.next(); try { Issue claim = JiraClientManager.getInstance().getRestClient().getIssueClient().getIssue(issue.getKey()).claim(); TimeTracking timeTracking = claim.getTimeTracking(); Integer estimatedTimeSeconds =(Integer) issue.getField("timeoriginalestimate").getValue(); Double estimatedTimeHours = (estimatedTimeSeconds.doubleValue())/3600; System.out.println(estimatedTimeHours+" "+issue.getKey()); sumEstimatedTimeHours += estimatedTimeHours; }catch(NullPointerException e){ System.out.println("Time Tracking null "+ issue.getKey()); } }
issue.setId(String.valueOf(jiraIssue.getKey())); issue.setProjectId(jiraIssue.getProject().getKey()); issue.setCreationDate(jiraIssue.getCreationDate()); issue.setDescription(jiraIssue.getDescription()); issue.setReporter(jiraIssue.getReporter().getName()); issue.setName(jiraIssue.getSummary()); User assignee = jiraIssue.getAssignee(); issue.setOpened(openDate.peek()); issue.setClosed(closeDate.peek()); issue.setDueTo(jiraIssue.getDueDate()); TimeTracking track = jiraIssue.getTimeTracking(); if (track != null) { issue.setPriority(fromMap(jiraIssue.getPriority().getName(), priorityMapping)); issue.setSeverity(fromMap(jiraIssue.getPriority().getName(), severityMapping)); issue.setType(fromMap(jiraIssue.getIssueType().getName(), typeMapping)); issue.setTags(jiraIssue.getLabels());
void copy(final URL url, final com.atlassian.jira.rest.client.api.domain.Issue jiraIssue, final JiraIssue issue) { issue.setTrackerId(jiraIssue.getKey()); issue.setSummary(jiraIssue.getSummary()); issue.setDescription(jiraIssue.getDescription()); issue.setStatus(getAphroditeStatus(jiraIssue.getStatus().getName())); issue.setPriority(getAphroditePriority(jiraIssue.getPriority().getName())); TimeTracking timeTracking = jiraIssue.getTimeTracking(); if(timeTracking != null) { int estimate = (timeTracking.getOriginalEstimateMinutes() == null) ? 0 : timeTracking.getOriginalEstimateMinutes(); setIssueComponent(issue, jiraIssue); setIssueUser((i, u) -> i.setAssignee(new User(u.getEmailAddress(), u.getName())), issue, jiraIssue.getAssignee()); setIssueUser((i, u) -> i.setReporter(new User(u.getEmailAddress(), u.getName())), issue, jiraIssue.getReporter()); setIssueAffectedVersions(issue, jiraIssue); setIssueReleases(issue, jiraIssue); setIssueDependencies(url, issue, jiraIssue.getIssueLinks()); setIssueComments(issue, jiraIssue); setCreationTime(issue, jiraIssue);
private Ticket getInternal(String ticketId, JiraRestClient jira) throws PluginException { // w00t Issue issue; try { issue = jira.getIssueClient().getIssue(ticketId).get(); } catch (InterruptedException|ExecutionException e) { throw new PluginException("Failed to get issue with id: " + ticketId, e); } if (issue != null) { Ticket ticket = new Ticket(); ticket.setId(issue.getKey()); ticket.setModificationTimestamp(String.valueOf(issue.getUpdateDate().toDate().getTime())); ticket.setSummary(issue.getSummary()); ticket.setDetails(issue.getDescription()); ticket.setState(getStateFromStatusName(issue.getStatus().getName())); return ticket; } else { return null; } }
String key = issue.getKey(); String summary = issue.getSummary(); String status = issue.getStatus().getName(); String type = issue.getIssueType().getName();
/** * write's the issue id in the file, which is stored in the Job's directory * * @param filename * @param issue * @throws FileNotFoundException */ private void writeInFile(String filename, Issue issue) throws IOException { // olamy really weird to write an empty file especially with null // but backward compat and unit tests assert that..... // can't believe such stuff has been merged...... try(BufferedWriter bw =Files.newBufferedWriter( Paths.get( filename ) )) { bw.write(issue.getKey()==null?"null":issue.getKey()); } }
public URI getWorklogUri() { return UriUtil.path(getSelf(), "worklog"); }
private void updateStreamStatus(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue, Map<String, Version> versionsMap, IssueInputBuilder inputBuilder) throws NotFoundException { String customField = JSON_CUSTOM_FIELD + TARGET_RELEASE; IssueField issueField = jiraIssue.getField(customField); if (issueField == null || (issueField.getType() == null && issueField.getValue() == null)) { String msg = String.format("Unable to set a stream status for issue %1$s as %2$s projects do not utilise field: %3$s", jiraIssue.getKey(), jiraIssue.getProject().getName(), customField); Utils.logWarnMessage(LOG, msg); return; } for (Map.Entry<String, FlagStatus> entry : issue.getStreamStatus().entrySet()) { if (entry.getValue() != FlagStatus.ACCEPTED) { String streamName = entry.getKey(); Version version = versionsMap.get(streamName); if (version != null) { inputBuilder.setFieldInput(new FieldInput(customField, ComplexIssueInputFieldValue.with("value", version.getId()))); } else { throw new NotFoundException("No Stream exists for this project with the name : " + streamName); } } } }
/** * Adds the specified version to the fix version list of all issues matching the JQL. * * @param projectKey The JIRA Project * @param version The version to add * @param query The JQL Query */ public void addFixVersion(String projectKey, String version, String query) throws TimeoutException { Version newVersion = getVersionByName(projectKey, version); if (newVersion == null) { LOGGER.warning("Version " + version + " was not found"); return; } LOGGER.fine("Fetching issues with JQL:" + query); List<Issue> issues = service.getIssuesFromJqlSearch(query, Integer.MAX_VALUE); if (issues == null || issues.isEmpty()) { return; } LOGGER.fine("Found issues: " + issues.size()); for (Issue issue : issues) { LOGGER.fine("Adding version: " + newVersion.getName() + " to issue: " + issue.getKey()); List<Version> fixVersions = new ArrayList<>(); issue.getFixVersions().forEach(fixVersions::add); fixVersions.add(newVersion); service.updateIssue(issue.getKey(), fixVersions); } }
/** * Returns the status of the issue. * * @param build * @param id * @return Status of the issue * @throws IOException */ private Status getStatus(AbstractBuild<?, ?> build, String id) throws IOException { JiraSession session = getJiraSession(build); Issue issue = session.getIssueByKey(id); return issue.getStatus(); }
private List<LinkIssuesInput> calculateNewLinks(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { // When jiraIssueLinks is null, this means that issue links have been disabled, so return an empty list Iterable<IssueLink> jiraIssueLinks = jiraIssue.getIssueLinks(); if (jiraIssueLinks == null) return new ArrayList<>(); // Process the existing IssueLinks and retrieve their Issue keys List<IssueLink> tmp = StreamSupport.stream(jiraIssueLinks.spliterator(), false).collect(Collectors.toList()); List<String> inbound = getExistingIssueLinkKeys(tmp, Direction.INBOUND); List<String> outbound = getExistingIssueLinkKeys(tmp, Direction.OUTBOUND); return Stream.concat( createIssueLinks(issue, inbound, e -> new LinkIssuesInput(e, jiraIssue.getKey(), "Dependency")), createIssueLinks(issue, outbound, e -> new LinkIssuesInput(jiraIssue.getKey(), e, "Dependency"))) .collect(Collectors.toList()); }
private void setIssueStream(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { try { IssueField jsonField = jiraIssue.getField(JSON_CUSTOM_FIELD + TARGET_RELEASE); if (jsonField == null || jsonField.getValue() == null) { return; } JSONObject value = (JSONObject) jsonField.getValue(); Map<String, FlagStatus> streamStatus; streamStatus = Collections.singletonMap(value.getString("name"), FlagStatus.ACCEPTED); issue.setStreamStatus(streamStatus); } catch (JSONException e) { LOG.error("error setting the stream in " + jiraIssue.getKey(), e); } }
private void setResolution(JiraIssue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { if (jiraIssue.getResolution() != null && !"".equals(jiraIssue.getResolution())) { if (!JiraIssueResolution.hasId(jiraIssue.getResolution().getId())) { String msg = String.format("Could not convert issue resolution: %1$s (%2$s) for issue: %3$s", jiraIssue .getResolution().getName(), jiraIssue.getResolution().getId(), jiraIssue.getKey()); Utils.logWarnMessage(LOG, msg); } else issue.setResolution(JiraIssueResolution.getById(jiraIssue.getResolution().getId())); } else issue.setResolution(JiraIssueResolution.UNRESOLVED); }
Project project = restClient.getProjectClient().getProject(jiraIssue.getProject().getSelf()).claim(); IssueInput update = WRAPPER.issueToFluentUpdate(issue, jiraIssue, project); issueClient.updateIssue(jiraIssue.getKey(), update).claim(); if (!JiraFields.hasSameIssueStatus(issue, jiraIssue)) { String transition = getJiraTransition(issue, jiraIssue);
IssueInput issueToFluentUpdate(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue, Project project) throws NotFoundException { checkUnsupportedUpdateFields(issue); IssueInputBuilder inputBuilder = new IssueInputBuilder(jiraIssue.getProject().getKey(), jiraIssue.getIssueType().getId()); issue.getSummary().ifPresent(inputBuilder::setSummary); inputBuilder.setFieldInput(new FieldInput(IssueFieldId.COMPONENTS_FIELD, issue.getComponents().stream().map(e -> ComplexIssueInputFieldValue.with("name", e)).collect(Collectors.toList())) ); issue.getDescription().ifPresent(inputBuilder::setDescription); issue.getAssignee().ifPresent(assignee -> inputBuilder.setFieldInput( new FieldInput(IssueFieldId.ASSIGNEE_FIELD, ComplexIssueInputFieldValue.with("name", assignee.getName().orElseThrow(this::nullUsername))))); // this is ok but does nothing if there is no permissions. issue.getStage().getStateMap().entrySet() .stream().filter(entry -> entry.getValue() != FlagStatus.NO_SET) .forEach(entry -> inputBuilder.setFieldInput(new FieldInput(JSON_CUSTOM_FIELD + FLAG_MAP.get(entry.getKey()), entry.getValue().getSymbol()))); Map<String, Version> versionsMap = StreamSupport.stream(project.getVersions().spliterator(), false) .collect(Collectors.toMap(Version::getName, Function.identity())); updateFixVersions(issue, versionsMap, inputBuilder); updateStreamStatus(issue, jiraIssue, versionsMap, inputBuilder); return inputBuilder.build(); }
private void setIssueType(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { String type = jiraIssue.getIssueType().getName(); issue.setType(getIssueType(type)); }