// get the basicProject service
ProjectService projectService = CoreObjectFactory.getProjectService();
// get the form
BasicProjectForm basicProjectForm = (BasicProjectForm) form;
// Save or update the BasicProject
Errors errors = null;
if (basicProjectForm.getPersistanceId() == 0) {
// get the current user from the session
User user = (User) request.getSession().getAttribute("user");
// add
errors = projectService.add(basicProjectForm.getCode(),
basicProjectForm.getName(), user.getPersistanceId());
} else {
// update
errors = projectService.update(basicProjectForm
.getPersistanceId(), basicProjectForm.getCode(),
basicProjectForm.getName(), basicProjectForm
.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);
}
// 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);
//
// }
// populate the summary
Summary.populate(request);
// forward
if (actionMessages.isEmpty() == false) {
// put the persistanceId in the request
request.setAttribute("persistanceId", Integer
.valueOf(basicProjectForm.getPersistanceId()));
return mapping.findForward("basicProjectDetail");
} else {
return this.list(mapping, form, request, response);