if (!failures.isEmpty()) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return validationMessagesSprint(failures);
} else {
s.setSlogan(s.getSlogan().trim());
Sprint sprint = this.sprintService.addSprint(s);
List<BurnDown> bdList = new ArrayList<BurnDown>();
Calendar c = Calendar.getInstance();
c.setTime(sprint.getStartDate());
Calendar startCalendar = new GregorianCalendar(
c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE));
c.setTime(s.getEndDate());
Calendar endCalendar = new GregorianCalendar(
c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE));
boolean writeBurnDown = false;
BurnDown bd;
if (startCalendar.compareTo(endCalendar) <= 0) {
writeBurnDown = true;
}
while (startCalendar.compareTo(endCalendar) <= 0) {
bd = new BurnDown(0, 0, sprint.getId(), startCalendar.getTime());
bdList.add(bd);
startCalendar.add(Calendar.DATE, 1);
}
if (writeBurnDown) {
this.burnDownChartService.addBurnDownForSprint(bdList);
}
return Collections.singletonMap("sprint",
new SerializableSprint(
sprint.getId(),
sprint.getSlogan(),
sprint.getStartDate(),
sprint.getEndDate()
)
);
}
}