com.ba.reports.DayReport.BADayReportAction.java Source code

Java tutorial

Introduction

Here is the source code for com.ba.reports.DayReport.BADayReportAction.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ba.reports.DayReport;

import com.ba.masters.room.BARoomActionForm;
import com.ba.masters.room.BARoomDAO;
import com.ba.masters.room.BARoomDTO;
import com.ba.masters.room.BARoomFactory;

import com.ba.util.BAHandleAllException;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;

import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.json.simple.JSONObject;

/**
 *
 * @author RAPID
 */
public class BADayReportAction extends DispatchAction {

    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    private int objPageCount = 0;
    private static Logger logger = Logger.getLogger(BADayReportAction.class);

    public ActionForward loadDayReport(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        logger.info(" loadDayReport method starts here");
        return mapping.findForward(SUCCESS);
    }

    public ActionForward baView(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        System.out.println("view()");
        JSONObject json = new JSONObject();
        BADayReportDTO vo = new BADayReportDTO();
        try {
            logger.info(" view method starts here");
            String fromDate = request.getParameter("fromDate");
            String toDate = request.getParameter("toDate");

            List hashMpRoomItemDet = BADayReportFactory.getInstanceOfBADayReportFactory().getRoomDtls(1, fromDate,
                    toDate);
            objPageCount = BADayReportFactory.getInstanceOfBADayReportFactory().getPageCount(fromDate, toDate);
            json.put("exception", "");
            json.put("RoomDets", hashMpRoomItemDet);
            json.put("RoomExit", hashMpRoomItemDet.size());
            json.put("objPageCount", objPageCount);
            logger.warn("strCurrent PageNo ------------->" + objPageCount);

        } catch (Exception ex) {
            logger.error("The Exception is  :" + ex);
            ex.printStackTrace();
            json.put("exception", BAHandleAllException.exceptionHandler(ex));
        }
        response.getWriter().write(json.toString());
        return null;

    }

    public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        JSONObject json = new JSONObject();
        BADayReportDTO vo = new BADayReportDTO();
        try {
            logger.info(" get method starts here");
            String roomId = request.getParameter("search");
            HashMap hashMpRoomItemDet = BADayReportFactory.getInstanceOfBADayReportFactory().getRoomDtls(roomId);
            json.put("exception", "");
            json.put("RoomDets", hashMpRoomItemDet);
            json.put("RoomExit", hashMpRoomItemDet.size());
            //
            //                 logger.warn("strCurrent PageNo ------------->"+objPageCount);
        } catch (Exception ex) {
            logger.error("The Exception is  :" + ex);
            ex.printStackTrace();
            json.put("exception", BAHandleAllException.exceptionHandler(ex));
        }
        response.getWriter().write(json.toString());
        return null;

    }
}

/**
 * This is the Struts action method called on
 * http://.../actionPath?method=myAction1, where "method" is the value
 * specified in <action> element : ( <action parameter="method" .../> )
 */