Skip to content

Commit

Permalink
#2 - Return all tickets in findTickets.
Browse files Browse the repository at this point in the history
 Remove the filter to resolved tickets only when querying Jira. Allow the absence of a ticket resolution.
  • Loading branch information
mp911de committed Feb 15, 2016
1 parent 327fa07 commit 5ec34cb
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
Expand All @@ -31,6 +32,8 @@
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.release.Application;
import org.springframework.data.release.jira.JiraIssue.Fields;
import org.springframework.data.release.jira.JiraIssue.Resolution;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Project;
Expand Down Expand Up @@ -58,7 +61,7 @@ class Jira implements JiraConnector {
private final RestOperations operations;
private final Logger logger;

/*
/*
* (non-Javadoc)
* @see org.springframework.data.release.jira.JiraConnector#flushTickets()
*/
Expand Down Expand Up @@ -90,7 +93,7 @@ public Ticket getReleaseTicketFor(ModuleIteration iteration) {

/**
* (non-Javadoc)
*
*
* @see org.springframework.data.release.jira.IssueTracker#findTickets(Project, Collection)
*/
@Override
Expand All @@ -101,7 +104,8 @@ public Collection<Ticket> findTickets(Project project, Collection<String> ticket
return Collections.emptyList();
}

JqlQuery query = JqlQuery.from(ticketIds).and(" resolution is not EMPTY");
logger.log(project, "Retrieving {} tickets…", ticketIds.size());
JqlQuery query = JqlQuery.from(ticketIds);

Map<String, Object> parameters = new HashMap<>();
parameters.put("jql", query);
Expand Down Expand Up @@ -171,23 +175,24 @@ public Tickets getTicketsFor(TrainIteration iteration, Credentials credentials)

private Ticket toTicket(JiraIssue issue) {

JiraIssue.Fields fields = issue.getFields();
Fields fields = issue.getFields();

JiraTicketStatus jiraTicketStatus;
if (fields.getStatus() != null && fields.getResolution() != null) {
if (fields.getStatus() != null) {
JiraIssue.Status status = fields.getStatus();
boolean resolved = status.getStatusCategory().getKey().equals("done");
JiraIssue.Resolution resolution = fields.getResolution();
Optional<Resolution> resolution = Optional.ofNullable(fields.getResolution());

jiraTicketStatus = new JiraTicketStatus(resolved, status.getName(), resolution.getName());
jiraTicketStatus = new JiraTicketStatus(resolved, status.getName(),
resolution.map(Resolution::getName).orElse(null));
} else {
jiraTicketStatus = JiraTicketStatus.UNKNOWN;
}

return new Ticket(issue.getKey(), fields.getSummary(), jiraTicketStatus);
}

/*
/*
* (non-Javadoc)
* @see org.springframework.data.release.jira.JiraConnector#verifyBeforeRelease(org.springframework.data.release.model.Train, org.springframework.data.release.model.Iteration)
*/
Expand All @@ -200,7 +205,7 @@ public void verifyBeforeRelease(TrainIteration iteration) {
}

/*
*
*
* (non-Javadoc)
* @see org.springframework.data.release.jira.JiraConnector#closeIteration(org.springframework.data.release.model.Train, org.springframework.data.release.model.Iteration, org.springframework.data.release.jira.Credentials)
*/
Expand All @@ -218,7 +223,7 @@ public void closeIteration(TrainIteration iteration, Credentials credentials) {
// - if no next version exists, create
}

/*
/*
* (non-Javadoc)
* @see org.springframework.data.release.jira.JiraConnector#getChangelogFor(org.springframework.data.release.model.Module, org.springframework.data.release.model.Iteration)
*/
Expand Down Expand Up @@ -247,7 +252,7 @@ public Changelog getChangelogFor(ModuleIteration module) {
return new Changelog(module, new Tickets(tickets, tickets.size()));
}

/*
/*
* (non-Javadoc)
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
*/
Expand Down

0 comments on commit 5ec34cb

Please sign in to comment.