* @param request
* @return
*/
@RequestMapping(method=RequestMethod.POST, params="migration=namesAndDescriptions")
public String doNameAndDescriptionMigration(WebRequest request) {
HtmlFormEntryService service = HtmlFormEntryUtil.getService();
for (HtmlForm htmlForm : service.getAllHtmlForms()) {
boolean modified = false;
String nameChoice = request.getParameter("name." + htmlForm.getId());
if (StringUtils.isNotBlank(nameChoice)) {
if (nameChoice.equals("html")) {
// use the old value
htmlForm.getForm().setName(htmlForm.getDeprecatedName());
htmlForm.setDeprecatedName(null);
} else if (nameChoice.equals("form")) {
// clear the old value, since we don't want it
htmlForm.setDeprecatedName(null);
}
modified = true;
}
String descriptionChoice = request.getParameter("description." + htmlForm.getId());
if (StringUtils.isNotBlank(descriptionChoice)) {
if (descriptionChoice.equals("html")) {
// use the old value
htmlForm.getForm().setDescription(htmlForm.getDeprecatedDescription());
htmlForm.setDeprecatedDescription(null);
} else if (descriptionChoice.equals("form")) {
// clear the old value, since we don't want it
htmlForm.setDeprecatedDescription(null);
}
modified = true;
}
if (modified) {
service.saveHtmlForm(htmlForm);
}
}
return "redirect:migrateNamesAndDescriptions.form";
}