HttpServletResponse response)
throws Throwable {
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
boolean insertMode = false;
CustomerClassMaintActionForm form = (CustomerClassMaintActionForm) actionForm;
if (form.getMode().equals("C")) {
insertMode = true;
}
AdminBean adminBean = getAdminBean(request);
Site site = adminBean.getSite();
CustomerClass customerClass = new CustomerClass();
if (!insertMode) {
customerClass = CustomerClassDAO.load(site.getSiteId(), Format.getLong(form.getCustClassId()));
}
ActionMessages errors = validate(form);
if (errors.size() != 0) {
saveMessages(request, errors);
return mapping.findForward("error");
}
if (insertMode) {
customerClass.setRecCreateBy(adminBean.getUser().getUserId());
customerClass.setRecCreateDatetime(new Date(System.currentTimeMillis()));
customerClass.setSystemRecord(Constants.VALUE_NO);
}
customerClass.setSite(site);
customerClass.setCustClassName(form.getCustClassName());
customerClass.setRecUpdateBy(adminBean.getUser().getUserId());
customerClass.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
if (insertMode) {
em.persist(customerClass);
}
else {
// em.update(customerClass);
}
form.setMode("U");
form.setCustClassId(customerClass.getCustClassId().toString());
FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
return mapping.findForward("success");
}