Package com.mockey.model

Examples of com.mockey.model.HistoryFilter


     *
     */
    public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String[] filterTokens = req.getParameterValues("token");
        HistoryFilter historyFilter = (HistoryFilter) req.getSession().getAttribute(HISTORY_FILTER);
        if (historyFilter == null) {
            historyFilter = new HistoryFilter();

        }

        String action = req.getParameter("action");

        if (action != null && "delete_all".equals(action)) {
            store.deleteFulfilledClientRequests();
            // don't allow reloads to re-delete.
            String contextRoot = req.getContextPath();
            resp.sendRedirect(Url.getContextAwarePath("/history", contextRoot));
            return;
        } else if (action != null && "delete".equals(action)) {
            String fulfilledRequestId = req.getParameter("fulfilledRequestId");
            try {
                store.deleteFulfilledClientRequestById(new Long(fulfilledRequestId));
            } catch (Exception e) {
                logger.error("Unable to delete fulfilled request with id:" + fulfilledRequestId, e);
            }
            // Ajax used in page, so don't return anything
            return;

        else if (action != null && "tag".equals(action)) {
            String fulfilledRequestId = req.getParameter("fulfilledRequestId");
           
            try {
              FulfilledClientRequest ffcr = store.getFulfilledClientRequestsById(new Long(fulfilledRequestId));
              if(ffcr.getComment()!=null){
                ffcr.setComment(null);
              }else {
                  ffcr.setComment("tagged");
              }
              store.saveOrUpdateFulfilledClientRequest(ffcr);
            } catch (Exception e) {
                logger.error("Unable to tag history of a fulfilled request with id:" + fulfilledRequestId, e);
            }
            // Ajax used in page, so don't return anything
            return;

        } else if (action != null && "remove_token".equals(action)) {
            historyFilter.deleteTokens(filterTokens);
        } else if (action != null && "remove_all_tokens".equals(action)) {
            historyFilter = new HistoryFilter();
        } else {

            historyFilter.addTokens(filterTokens);
        }
        List<FulfilledClientRequest> fulfilledRequests = store.getFulfilledClientRequest(historyFilter.getTokens());
        req.setAttribute("requests", fulfilledRequests);
        req.getSession().setAttribute(HISTORY_FILTER, historyFilter);
        RequestDispatcher dispatch = req.getRequestDispatcher("/history.jsp");
        dispatch.forward(req, resp);
    }
View Full Code Here

TOP

Related Classes of com.mockey.model.HistoryFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.