// get the service
StoryService storyService = AgilePlanningObjectFactory.getStoryService();
// get the form
TaskForm taskForm = (TaskForm) form;
// TODO faire une seul m�thode taskService.save ?
Errors errors = null;
// save the story
if (taskForm.getPersistanceId() == 0) {
// add
errors = storyService.addTask(taskForm.getStoryPersistanceId(),
taskForm.getDaysEstimated(),
taskForm.getShortDescription(),
taskForm.getDevelopperPersistanceId());
} else {
// update
errors = storyService.updateTask(taskForm.getStoryPersistanceId(),
taskForm.getDaysEstimated(),
taskForm.getShortDescription(),
taskForm.getDevelopperPersistanceId(),
taskForm.getPersistanceId(),
taskForm.getPersistanceVersion());
}
// Convert into struts action errors
ActionMessages actionMessages = new ActionMessages();
if (errors.hasErrors()) {
for (Iterator iterator = errors.getAllErrorsMessageParameters().iterator(); iterator.hasNext();) {
MessageParameters messageParameters = (MessageParameters) iterator.next();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(messageParameters.getErrorCode(),
messageParameters.getErrorArguments()));
}
saveErrors(request, actionMessages);
}
// forward
if (actionMessages.isEmpty() == false) {
//put the persistanceId in the request
request.setAttribute("persistanceId", Integer.valueOf(taskForm.getPersistanceId()));
// populate the list box
populateListBox(request);
// populate the summary
populateSummary(request);
return mapping.findForward("taskDetail");
} else {
// set the storyPersistanceId in request
request.setAttribute("storyPersistanceId", String.valueOf(taskForm.getStoryPersistanceId()));
return this.list(mapping, form, request, response);
}
}