package it.acxent.art.servlet; import it.acxent.art.CTipo; import it.acxent.art.Caratteristica; import it.acxent.art.CaratteristicaCR; import it.acxent.art.Marca; import it.acxent.db.ApplParmFull; import it.acxent.db.CRAdapter; import it.acxent.db.DBAdapter; import it.acxent.db.ResParm; import it.acxent.util.AbMessages; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = {"/admin/artConfig/Caratteristica.abl"}) public class CaratteristicaSvlt extends _MagSvlt { private static final long serialVersionUID = 3575908708336411061L; protected void fillComboAfterDetail(DBAdapter bean, HttpServletRequest req, HttpServletResponse res) { ApplParmFull apFull = getApFull(req); req.setAttribute("listaMarche", new Marca(apFull).findAll()); req.setAttribute("listaCTipi", new CTipo(apFull).findTipiByCaratteristica(((Caratteristica)bean).getId_caratteristica(), 0, 0)); } protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {} protected DBAdapter getBean(HttpServletRequest req) { return new Caratteristica(getApFull(req)); } protected CRAdapter getBeanCR(HttpServletRequest req) { return new CaratteristicaCR(getApFull(req)); } protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) { req.setAttribute("listaMarche", new Marca(getApFull(req)).findAll()); } public void _addTipo(HttpServletRequest req, HttpServletResponse res) { ResParm rp = new ResParm(true, ""); long l_id_tipo = getRequestLongParameter(req, "id_tipo"); long l_id = getRequestLongParameter(req, "id_caratteristica"); Caratteristica bean = new Caratteristica(getApFull(req)); bean.findByPrimaryKey(l_id); fillObject(req, bean); rp = bean.save(); req.setAttribute("id_caratteristica", String.valueOf(bean.getId_caratteristica())); if (l_id_tipo > 0L) { rp = bean.addTipo(l_id_tipo); sendMessage(req, rp.getMsg()); } showBean(req, res); } protected void addRows(HttpServletRequest req, HttpServletResponse res) { long l_id = 0L; Caratteristica bean = null; ResParm rp = new ResParm(true, ""); l_id = getRequestLongParameter(req, "id_caratteristica"); bean = new Caratteristica(getApFull(req)); try { bean.findByPrimaryKey(l_id); fillObject(req, bean); rp = bean.save(); req.setAttribute("id_caratteristica", String.valueOf(bean.getId_caratteristica())); if (rp.getStatus() == true) { long l_id_tipo = getRequestLongParameter(req, "id_tipo"); if (getAct(req).equals("addTipo")) { if (l_id_tipo > 0L) { rp = bean.addTipo(l_id_tipo); sendMessage(req, rp.getMsg()); showBean(req, res); } } else if (getAct(req).equals("delTipo") && l_id_tipo > 0L) { bean.delTipo(l_id_tipo); sendMessage(req, AbMessages.getMessage(getLocale(req), "DELETE_OK")); showBean(req, res); } } else { req.setAttribute("bean", bean); sendMessage(req, rp.getMsg()); showBean(req, res); } } catch (Exception e) { forceMessage(req, AbMessages.getMessage(getLocale(req), "SAVE_FAIL")); showBean(req, res); } } }