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