/**
   * This method is for delete Presenter
   *
   * @param presenter code
   * @param requestParameters Servlet Request Parameter
   * @return void
   */
  public void deletePresenter(String presenter_code, HttpServletRequest request) {
    log.log(Level.INFO, "PresenterMaintenance --> delete presenter ");
    AuditTrailMaintenance auditTrailMaint = new AuditTrailMaintenance();
    User user = (User) request.getSession().getAttribute(SessionAttributes.CURR_USER_OBJ);
    Session session = HibernateFactory.openSession();
    Transaction tx = session.beginTransaction();
    String msg = "";
    Presenter presenter = new Presenter();
    try {
      presenter = (Presenter) session.get(Presenter.class, Integer.parseInt(presenter_code));
      presenter.setStatus(false);
      session.update(presenter);
      tx.commit();

      /*ResourceBundle msgProps = ResourceBundle.getBundle("configurations");
      String ModulePath  = msgProps.getString("PresenterPath");
      String filePath = ModulePath+"/"+presenterName;

         File file = new File(filePath);
         FileUtils.deleteFileNFolder(file);*/
      msg = "The Presenter has been successfully deleted.";
      auditTrailMaint.insertAuditTrail(
          new AuditTrail(
              user.getStaffLoginId() + "",
              AuditTrail.MODULE_PRESENTER,
              AuditTrail.FUNCTION_DELETE,
              "SUCCESS,Presenter_code:" + presenter_code));

    } catch (Exception e) {
      msg = "The Presenter has not been successfully deleted.";
      auditTrailMaint.insertAuditTrail(
          new AuditTrail(
              user.getStaffLoginId() + "",
              AuditTrail.MODULE_PRESENTER,
              AuditTrail.FUNCTION_DELETE,
              "FAILED,Presenter_code:" + presenter_code));
      log.log(Level.SEVERE, e.getMessage());
      e.printStackTrace();
    }
    try {
      HibernateFactory.close(session);
    } catch (Exception e) {
      log.log(Level.SEVERE, e.getMessage());
      e.printStackTrace();
    }

    MsgObject msgObj = new MsgObject(msg);
    request.setAttribute("CacheName", "Presenter");
    request.setAttribute(RequestAttributes.MESSAGE_OBJ, msgObj);

    Pager pager = retrieveActivityListing(getAllPresenter(request));
    request.getSession().setAttribute("pager", pager);
    request.setAttribute("pager", pager);
    request
        .getSession()
        .setAttribute("pageObj", new PathDetail().getPageObj("PresenterMaintenance"));
  }
  /**
   * This method checks all validations & sets values to bean
   *
   * @param presenter Presenter object
   * @param requestParameters Servlet Request Parameter
   * @return Presenter Object
   */
  public Object mapForm1(Presenter presenter, HttpServletRequest requestParameters) {
    log.log(Level.INFO, "PresenterMaintenance --> mapping all presnter field ");
    if (presenter == null) {
      presenter = new Presenter();
      return presenter;
    }
    LocaleObject localeObj =
        (LocaleObject) requestParameters.getSession().getAttribute(SessionAttributes.LOCALE_OBJ);
    User userObj = (User) requestParameters.getSession().getAttribute("currUserObj");

    String presenter_cat_code = requestParameters.getParameter("presenter_category_code");
    String presenter_name = requestParameters.getParameter("name");
    String startdate = requestParameters.getParameter("startdate");
    String enddate = requestParameters.getParameter("enddate");
    String desc = requestParameters.getParameter("desc");
    String bu = requestParameters.getParameter("bu");
    String visibility = requestParameters.getParameter("presenter_visibility");

    if (presenter_cat_code.equals("%"))
      return new ErrorObject("Presenter Category", " field is required", localeObj);
    if (presenter_name == null || presenter_name.length() == 0)
      return new ErrorObject("Presenter Name", " field is required", localeObj);
    if (startdate == null || startdate.length() == 0)
      return new ErrorObject("Start Date", " field is required", localeObj);
    if (enddate == null || enddate.length() == 0)
      return new ErrorObject("Expiry Date", " field is required", localeObj);
    if (desc == null || desc.length() == 0)
      return new ErrorObject("Presenter Description", " field is required", localeObj);
    if (visibility == null || visibility.equals("%"))
      return new ErrorObject("Presenter Visibility", " field is required", localeObj);
    if (bu == null || bu.equals("0")) return new ErrorObject("BU", " field is required", localeObj);

    presenter.setCategory(Integer.parseInt(presenter_cat_code));
    presenter.setPresenterName(presenter_name);
    presenter.setStart_date(LMSUtil.convertToDate1(startdate));
    presenter.setExpiry_date(LMSUtil.convertToDate1(enddate));
    presenter.setPresenterDescription(desc);
    presenter.setVisibility(visibility);

    presenter.setBuCode(Integer.parseInt(requestParameters.getParameter("bu")));
    presenter.setDistCode(Integer.parseInt(requestParameters.getParameter("district")));
    presenter.setBranchCode(Integer.parseInt(requestParameters.getParameter("branch")));
    presenter.setCityCode(Integer.parseInt(requestParameters.getParameter("city")));
    presenter.setSscCode(Integer.parseInt(requestParameters.getParameter("ssc")));
    presenter.setOfficeCode(Integer.parseInt(requestParameters.getParameter("office")));

    if (presenter.getExpiry_date().before(presenter.getStart_date())
        || presenter.getExpiry_date().equals(presenter.getStart_date())) {
      return new ErrorObject(" ", "Expired Date should be after Start Date", localeObj);
    }
    presenter.setStatus(true);
    presenter.setToken(LMSUtil.getRendomToken());
    return presenter;
  }