private void setupDropdownsInHeader() {
   EgovMasterDataCaching masterCache = EgovMasterDataCaching.getInstance();
   setupDropdownDataExcluding(Constants.SUB_SCHEME);
   dropdownData.put("budgetGroupList", masterCache.get("egf-budgetGroup"));
   dropdownData.put("executingDepartmentList", masterCache.get("egi-department"));
   addDropdownData("financialYearList", budgetService.getFYForNonApprovedBudgets());
   List<String> isbereList = new ArrayList<String>();
   isbereList.add("BE");
   isbereList.add("RE");
   dropdownData.put("isbereList", isbereList);
 }
  @Action(value = "/deduction/autoRemittance-manualSchedule")
  public String manualSchedule() {
    try {
      coaMap = new LinkedHashMap<String, String>();
      List<Recovery> allActiveAutoRemitTds = tdsDAO.getAllActiveAutoRemitTds();

      for (Recovery r : allActiveAutoRemitTds) {
        coaMap.put(
            r.getChartofaccounts().getGlcode(),
            r.getChartofaccounts().getGlcode() + "-" + r.getChartofaccounts().getName());
      }

      addDropdownData("departmentList", masterCache.get("egi-department"));
      deptDOList =
          persistenceService.findAllBy("from DepartmentDOMapping where department is not null  ");

      List<Object[]> list =
          HibernateUtil.getCurrentSession()
              .createSQLQuery(
                  "select glcode, to_char(max(lastrundate),'dd/mm/yyyy') from egf_remittance_scheduler where glcode is not null and sch_type='A' "
                      + " GROUP by glcode order by glcode")
              .list();
      lastRunDateMap = new HashMap<String, String>();
      for (Object[] ob : list) {
        lastRunDateMap.put((String) ob[0], (String) ob[1]);
      }
    } catch (ApplicationRuntimeException e) {
      addActionError("failed");
    } catch (HibernateException e) {
      addActionError("failed");
    } catch (Exception e) {
      addActionError("failed");
    }

    return "manual";
  }
  @SuppressWarnings("unchecked")
  private void loadApproverUser(String atype) {
    String scriptName = "paymentHeader.nextDesg";
    if (paymentheader != null && paymentheader.getPaymentAmount() != null) {
      if (LOGGER.isInfoEnabled())
        LOGGER.info(
            "paymentheader.getPaymentAmount() >>>>>>>>>>>>>>>>>>> :"
                + paymentheader.getPaymentAmount());
      atype = atype + "|" + paymentheader.getPaymentAmount();
    } else {
      atype = atype + "|";
    }
    EgovMasterDataCaching masterCache = EgovMasterDataCaching.getInstance();
    departmentId = voucherService.getCurrentDepartment().getId().intValue();
    if (LOGGER.isInfoEnabled()) LOGGER.info("departmentId :" + departmentId);
    Map<String, Object> map = new HashMap<String, Object>();
    if (paymentheader != null && paymentheader.getVoucherheader().getFiscalPeriodId() != null) {
      map =
          voucherService.getDesgByDeptAndTypeAndVoucherDate(
              atype, scriptName, paymentheader.getVoucherheader().getVoucherDate(), paymentheader);
    } else {
      map =
          voucherService.getDesgByDeptAndTypeAndVoucherDate(
              atype, scriptName, new Date(), paymentheader);
    }
    addDropdownData("departmentList", masterCache.get("egi-department"));

    List<Map<String, Object>> desgList = (List<Map<String, Object>>) map.get("designationList");
    String strDesgId = "", dName = "";
    boolean bDefaultDeptId = false;
    List<Map<String, Object>> designationList = new ArrayList<Map<String, Object>>();
    Map<String, Object> desgFuncryMap;
    for (Map<String, Object> desgIdAndName : desgList) {
      desgFuncryMap = new HashMap<String, Object>();

      if (desgIdAndName.get("designationName") != null) {
        desgFuncryMap.put("designationName", (String) desgIdAndName.get("designationName"));
      }

      if (desgIdAndName.get("designationId") != null) {
        strDesgId = (String) desgIdAndName.get("designationId");
        if (strDesgId.indexOf("~") != -1) {
          strDesgId = strDesgId.substring(0, strDesgId.indexOf('~'));
          dName = (String) desgIdAndName.get("designationId");
          dName = dName.substring(dName.indexOf('~') + 1);
          bDefaultDeptId = true;
        }
        desgFuncryMap.put("designationId", strDesgId);
      }
      designationList.add(desgFuncryMap);
    }
    map.put("designationList", designationList);

    addDropdownData("designationList", (List<Designation>) map.get("designationList"));

    if (bDefaultDeptId && !dName.equals("")) {
      Department dept =
          (Department)
              persistenceService.find("from Department where deptName like '%" + dName + "' ");
      departmentId = dept.getId().intValue();
    }
    wfitemstate = map.get("wfitemstate") != null ? map.get("wfitemstate").toString() : "";
  }
@Transactional(readOnly = true)
@Results({@Result(name = "manual", location = "autoRemittance-manual.jsp")})
public class AutoRemittanceAction extends BaseFormAction {

  private static final Logger LOGGER = Logger.getLogger(AutoRemittanceAction.class);
  private static final String MANUAL = "manual";
  private ScheduledRemittanceService scheduledRemittanceService;
  private String glcode;
  private Integer dept;
  private String drawingOfficer;
  private Date lastRunDate;
  private Map<String, String> coaMap;
  private EgovMasterDataCaching masterCache = EgovMasterDataCaching.getInstance();
  private List<DepartmentDOMapping> deptDOList;
  private RemittanceSchedulerLog remittanceScheduler;
  private Map<String, String> lastRunDateMap;
  private TdsHibernateDAO tdsDAO;

  @Override
  public Object getModel() {
    return null;
  }

  @Action(value = "/deduction/autoRemittance-manualSchedule")
  public String manualSchedule() {
    try {
      coaMap = new LinkedHashMap<String, String>();
      List<Recovery> allActiveAutoRemitTds = tdsDAO.getAllActiveAutoRemitTds();

      for (Recovery r : allActiveAutoRemitTds) {
        coaMap.put(
            r.getChartofaccounts().getGlcode(),
            r.getChartofaccounts().getGlcode() + "-" + r.getChartofaccounts().getName());
      }

      addDropdownData("departmentList", masterCache.get("egi-department"));
      deptDOList =
          persistenceService.findAllBy("from DepartmentDOMapping where department is not null  ");

      List<Object[]> list =
          HibernateUtil.getCurrentSession()
              .createSQLQuery(
                  "select glcode, to_char(max(lastrundate),'dd/mm/yyyy') from egf_remittance_scheduler where glcode is not null and sch_type='A' "
                      + " GROUP by glcode order by glcode")
              .list();
      lastRunDateMap = new HashMap<String, String>();
      for (Object[] ob : list) {
        lastRunDateMap.put((String) ob[0], (String) ob[1]);
      }
    } catch (ApplicationRuntimeException e) {
      addActionError("failed");
    } catch (HibernateException e) {
      addActionError("failed");
    } catch (Exception e) {
      addActionError("failed");
    }

    return "manual";
  }

  @ValidationErrorPage(value = "messages")
  public String schedule() {
    try {
      LOGGER.info("Inside RemittanceJob");
      remittanceScheduler = new RemittanceSchedulerLog();
      remittanceScheduler.setGlcode(glcode);
      remittanceScheduler.setSchType(FinancialConstants.REMITTANCE_SCHEDULER_SCHEDULAR_TYPE_MANUAL);
      remittanceScheduler.setSchJobName("Manual");
      remittanceScheduler.setLastRunDate(new Date());
      remittanceScheduler.setCreatedDate(new Date());
      remittanceScheduler.setCreatedBy(EgovThreadLocals.getUserId().intValue());
      remittanceScheduler.setStatus("Started");
      scheduledRemittanceService.getRemittanceSchedulerLogService().persist(remittanceScheduler);
      Long schedularLogId = remittanceScheduler.getId();
      boolean searchRecovery =
          scheduledRemittanceService.searchRecovery(
              glcode, "Manual", schedularLogId, dept, lastRunDate);
      if (searchRecovery == false) {
        addActionMessage(getText("schedular.failed"));
        addActionMessage(scheduledRemittanceService.getErrorMessage().toString());
      } else {
        addActionMessage(getText("schedular.succeful"));
      }
    } catch (ValidationException e) {
      addActionMessage(getText("schedular.failed"));
      throw new ValidationException(
          Arrays.asList(
              new ValidationError(
                  scheduledRemittanceService.getErrorMessage().toString(),
                  scheduledRemittanceService.getErrorMessage().toString())));
    } catch (Exception e) {
      addActionMessage(getText("schedular.failed"));
      throw new ValidationException(
          Arrays.asList(
              new ValidationError(
                  scheduledRemittanceService.getErrorMessage().toString(),
                  scheduledRemittanceService.getErrorMessage().toString())));
    }
    List<String> findAllBy =
        (List<String>)
            scheduledRemittanceService
                .getRemittancePersistenceService()
                .getPersistenceService()
                .findAllBy(
                    "select voucherheaderId.voucherNumber from "
                        + "RemittanceSchedulePayment  where schId.id=?",
                    remittanceScheduler.getId());
    if (findAllBy.isEmpty()) {
      addActionMessage(" No Payments Created ");
    } else {
      addActionMessage(" Payment vouchernumbers listed below");
      addActionMessage(findAllBy.toString().replace('[', ' ').replace(']', ' '));
    }
    return "messages";
  }

  public void setScheduledRemittanceService(ScheduledRemittanceService scheduledRemittanceService) {
    this.scheduledRemittanceService = scheduledRemittanceService;
  }

  public String getGlcode() {
    return glcode;
  }

  public void setGlcode(String glcode) {
    this.glcode = glcode;
  }

  public Integer getDept() {
    return dept;
  }

  public void setDept(Integer dept) {
    this.dept = dept;
  }

  public String getDrawingOfficer() {
    return drawingOfficer;
  }

  public void setDrawingOfficer(String drawingOfficer) {
    this.drawingOfficer = drawingOfficer;
  }

  public Date getLastRunDate() {
    return lastRunDate;
  }

  public void setLastRunDate(Date lastRunDate) {
    this.lastRunDate = lastRunDate;
  }

  public Map<String, String> getCoaMap() {
    return coaMap;
  }

  public void setCoaMap(Map<String, String> coaMap) {
    this.coaMap = coaMap;
  }

  public RemittanceSchedulerLog getRemittanceScheduler() {
    return remittanceScheduler;
  }

  public void setRemittanceScheduler(RemittanceSchedulerLog remittanceScheduler) {
    this.remittanceScheduler = remittanceScheduler;
  }

  public List<DepartmentDOMapping> getDeptDOList() {
    return deptDOList;
  }

  public void setDeptDOList(List<DepartmentDOMapping> deptDOList) {
    this.deptDOList = deptDOList;
  }

  public Map<String, String> getLastRunDateMap() {
    return lastRunDateMap;
  }

  public void setLastRunDateMap(Map<String, String> lastRunDateMap) {
    this.lastRunDateMap = lastRunDateMap;
  }

  public void setTdsDAO(TdsHibernateDAO tdsDAO) {
    this.tdsDAO = tdsDAO;
  }
}