return getDao().getFormDao().getById(formId);
}
@Override
public ServiceResponse saveForm(Map<String, String> vo) {
FormEntity form = null;
if (!StringUtils.isEmpty(vo.get("id"))) {
form = getDao().getFormDao().getById(Long.valueOf(vo.get("id")));
}
if (form == null) {
form = new FormEntity();
}
form.setTitle(vo.get("title"));
form.setName(vo.get("name"));
form.setEmail(vo.get("email"));
form.setLetterSubject(vo.get("letterSubject"));
form.setResetButtonTitle(vo.get("resetButtonTitle"));
form.setSendButtonTitle(vo.get("sendButtonTitle"));
form.setShowResetButton(Boolean.valueOf(vo.get("showResetButton")));
form.setEnableCaptcha(Boolean.valueOf(vo.get("enableCaptcha")));
form.setEnableSave(Boolean.valueOf(vo.get("enableSave")));
List<String> errors = getBusiness().getFormBusiness()
.validateBeforeUpdate(form);
if (errors.isEmpty()) {
getDao().getFormDao().save(form);
return ServiceResponse.createSuccessResponse(form.getId().toString());
}
else {
return ServiceResponse.createErrorResponse(
Messages.get("errors_occured"), errors);
}