return "console/directory/gradeEdit";
}
@RequestMapping(value = "/console/directory/grade/submit/(*:action)", method = RequestMethod.POST)
public String consoleGradeSubmit(ModelMap model, @RequestParam("action") String action, @RequestParam("orgId") String orgId, @ModelAttribute("grade") Grade grade, BindingResult result) {
Organization organization = organizationDao.getOrganization(orgId);
// validate ID
validator.validate(grade, result);
boolean invalid = result.hasErrors();
if (!invalid) {
// check error
Collection<String> errors = new ArrayList<String>();
if ("create".equals(action)) {
// check id exist
if (gradeDao.getGrade(grade.getId()) != null) {
errors.add("console.directory.grade.error.label.idExists");
} else {
grade.setOrganization(organization);
invalid = !gradeDao.addGrade(grade);
}
} else {
Grade g = gradeDao.getGrade(grade.getId());
g.setName(grade.getName());
g.setDescription(grade.getDescription());
invalid = !gradeDao.updateGrade(g);
}
if (!errors.isEmpty()) {
model.addAttribute("errors", errors);
invalid = true;
}
}
if (invalid) {
model.addAttribute("organization", organization);
model.addAttribute("grade", grade);
if ("create".equals(action)) {
return "console/directory/gradeCreate";
} else {
return "console/directory/gradeEdit";
}
} else {
String id = organization.getId();
String contextPath = WorkflowUtil.getHttpServletRequest().getContextPath();
String url = contextPath;
if ("create".equals(action)) {
url += "/web/console/directory/org/view/" + id;
} else {