@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { try { ActividadDao oActividadDAO = new ActividadDao(Conexion.getConection()); ActividadBean oActividad = new ActividadBean(); Gson gson = new GsonBuilder().setDateFormat("dd/MM/yyyy").create(); String jason = request.getParameter("json"); jason = EncodingUtil.decodeURIComponent(jason); oActividad = gson.fromJson(jason, oActividad.getClass()); Map<String, String> data = new HashMap<>(); if (oActividad != null) { oActividadDAO.set(oActividad); data.put("status", "200"); data.put("message", Integer.toString(oActividad.getId())); } else { data.put("status", "error"); data.put("message", "error"); } String resultado = gson.toJson(data); return resultado; } catch (Exception e) { throw new ServletException("ActividadSaveJson: View Error: " + e.getMessage()); } }
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { try { EstadoDao oEstadoDAO = new EstadoDao(Conexion.getConection()); EstadoBean oEstado = new EstadoBean(); Gson gson = new Gson(); String jason = request.getParameter("json"); jason = EncodingUtil.decodeURIComponent(jason); oEstado = gson.fromJson(jason, oEstado.getClass()); Map<String, String> data = new HashMap<>(); if (oEstado != null) { oEstado = oEstadoDAO.set(oEstado); data.put("status", "200"); data.put("message", Integer.toString(oEstado.getId())); } else { data.put("status", "error"); data.put("message", "error"); } String resultado = gson.toJson(data); return resultado; } catch (Exception e) { throw new ServletException("EstadoSaveJson: View Error: " + e.getMessage()); } }
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { try { FollowerDao oFollowerDAO = new FollowerDao(Conexion.getConection()); FollowerBean oFollower = new FollowerBean(); oFollower.setId(Integer.parseInt(request.getParameter("id"))); Map<String, String> data = new HashMap<>(); if (oFollower != null) { oFollowerDAO.remove(oFollower); data.put("status", "200"); data.put("message", "se ha eliminado el registro con id=" + oFollower.getId()); } else { data.put("status", "error"); data.put("message", "error"); } Gson gson = new Gson(); String resultado = gson.toJson(data); return resultado; } catch (Exception e) { throw new ServletException("FollowerRemoveJson: View Error: " + e.getMessage()); } }
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { String data; try { ArrayList<FilterBean> alFilter = new ArrayList<>(); if (request.getParameter("filter") != null) { if (request.getParameter("filteroperator") != null) { if (request.getParameter("filtervalue") != null) { FilterBean oFilterBean = new FilterBean(); oFilterBean.setFilter(request.getParameter("filter")); oFilterBean.setFilterOperator(request.getParameter("filteroperator")); oFilterBean.setFilterValue(request.getParameter("filtervalue")); oFilterBean.setFilterOrigin("user"); alFilter.add(oFilterBean); } } } if (request.getParameter("systemfilter") != null) { if (request.getParameter("systemfilteroperator") != null) { if (request.getParameter("systemfiltervalue") != null) { FilterBean oFilterBean = new FilterBean(); oFilterBean.setFilter(request.getParameter("systemfilter")); oFilterBean.setFilterOperator(request.getParameter("systemfilteroperator")); oFilterBean.setFilterValue(request.getParameter("systemfiltervalue")); oFilterBean.setFilterOrigin("system"); alFilter.add(oFilterBean); } } } AlumnoDao oAlumnoDAO = new AlumnoDao(Conexion.getConection()); int pages = oAlumnoDAO.getCount(alFilter); data = "{\"data\":\"" + Integer.toString(pages) + "\"}"; return data; } catch (Exception e) { throw new ServletException("AlumnoGetregistersJson: View Error: " + e.getMessage()); } }