/**
  * getWeeklyReportOfAllEmployeeByWeek(-) method display the working details of an employee for a
  * week using line chart.
  *
  * @throws ParseException If text format is not supported
  */
 @RequestMapping(value = "/getWeeklyProductivityOfAllEmployeeByWeek", method = RequestMethod.POST)
 public @ResponseBody String getWeeklyProductivityOfAllEmployeeByWeek(
     HttpServletRequest request, @RequestParam("week") String week) throws ParseException {
   logger.info("inside ReportGenerationController getWeeklyProductivityOfAllEmployeeByWeek()");
   if (HttpSessionUtility.verifySession(request, "adminId"))
     return reportGenerationService.getWeeklyProductivityOfAllEmployeeByWeek(week);
   else return JsonUtility.convertToJson("-1");
 }
 /** This method is to find all employee productivity for given year. */
 @RequestMapping(value = "/getAllEmployeeAnnualProductivity", method = RequestMethod.POST)
 public @ResponseBody String getAllEmployeeAnnualProductivity(
     HttpServletRequest request, @RequestParam("year") int year) {
   logger.info("inside ReportGenerationController getAllEmployeeAnnualProductivity()");
   logger.info("data received:  year: " + year);
   if (HttpSessionUtility.verifySession(request, "adminId"))
     return reportGenerationService.getAllEmployeeAnnualProductivity(year);
   else return JsonUtility.convertToJson("-1");
 }
  public String getLoggedInEmoloyeeIds() {

    logger.info("inside ValidationServiceImpl getLoggedInEmoloyeeIds()");

    List<Object> loggedInList = validationDAO.getLoggedInEmployeeIds();
    logger.info("list size loggedinemp" + loggedInList.size());

    return JsonUtility.convertToJson(loggedInList);
  }
 /**
  * getAllEmployeeReportForMonthByMonth(-) method takes month as a inputs and displays all
  * employees working details during given period of time.
  *
  * @throws Exception
  */
 @RequestMapping(
     value = "/getMonthlyProductivityOfAllEmployeeByMonth",
     method = RequestMethod.POST)
 public @ResponseBody String getMonthlyProductivityOfAllEmployeeByMonth(
     HttpServletRequest request, @RequestParam("month") String month) {
   logger.info("inside ReportGenerationController getMonthlyProductivityOfAllEmployeeByMonth()");
   logger.info("Month in getMonthlyProductivityOfAllEmployeeByMonth : " + month);
   if (HttpSessionUtility.verifySession(request, "adminId"))
     return reportGenerationService.getMonthlyProductivityOfAllEmployeeByMonth(month);
   else return JsonUtility.convertToJson("-1");
 }
  /**
   * getAutoCompleteInfo(-) method take employeeId as a input and display all employeeId's or
   * employeeName's in the search box based on the user supplied values.
   */
  @RequestMapping(value = "/getAutoCompleteInfo", method = RequestMethod.POST)
  public @ResponseBody String getAutoCompleteInfo(@RequestParam("employeeId") String employeeId) {
    String pattern = "^[0-9]$";

    List<Integer> infolist = null;
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(employeeId);
    if (m.find()) {
      logger.info("Integer:" + employeeId);
      logger.info("inside ReportGenerationController getAutoCompleteInfo()");
      logger.info("received employee id: " + employeeId);
      int empid = Integer.parseInt(employeeId);
      infolist = reportGenerationService.getAutoCompleteInfo(empid);
      logger.info("info list in controller:" + infolist);

      return JsonUtility.convertToJson(infolist);
    } else {
      logger.info("String:" + employeeId);
      List<String> data = reportGenerationService.getAutoCompleteInfo(employeeId);
      return JsonUtility.convertToJson(data);
    }
  }
  public String getAllEmployeeIds() {
    logger.info("inside ValidationServiceImpl getAllEmployeeIds()");
    List<Object> allEmpData = validationDAO.getAllEmploeeIds();
    List<EmployeeData> listOfAllEmpIds = new ArrayList<EmployeeData>();
    for (Object data : allEmpData) {

      Object[] array = (Object[]) data;
      EmployeeData emp = new EmployeeData();
      emp.setEmpId((Integer) array[0]);
      emp.setEmpName((String) array[1] + " " + (String) array[2]);
      listOfAllEmpIds.add(emp);
    }
    return JsonUtility.convertToJson(listOfAllEmpIds);
  }