Ejemplo n.º 1
0
 @RequestMapping(
     value = "/advSearchJob",
     method = {RequestMethod.GET})
 public String visitAdvSearchPage(ModelMap model) {
   model.addAttribute("statuses", RecruitmentStatus.values());
   model.addAttribute("teams", UsersDao.instance.getAllTeams());
   return "advSearchJob";
 }
Ejemplo n.º 2
0
 private boolean validateSearchInput(
     String closingDateFrom,
     String closingDateTo,
     String salaryFrom,
     String salaryTo,
     String positionType,
     String location,
     String description,
     String status,
     String assignedTeam) {
   if (closingDateFrom != null && !closingDateFrom.isEmpty()) {
     try {
       Date d = DATE_FORMAT.parse(closingDateFrom);
       if (!DATE_FORMAT.format(d).equals(closingDateFrom)) {
         return false;
       }
     } catch (ParseException e) {
       return false;
     }
   }
   if (closingDateTo != null && !closingDateTo.isEmpty()) {
     try {
       Date d = DATE_FORMAT.parse(closingDateTo);
       if (!DATE_FORMAT.format(d).equals(closingDateTo)) {
         return false;
       }
     } catch (ParseException e) {
       return false;
     }
   }
   if (salaryFrom != null && !salaryFrom.isEmpty()) {
     try {
       Integer.parseInt(salaryFrom);
     } catch (NumberFormatException e) {
       return false;
     }
   }
   if (salaryTo != null && !salaryTo.isEmpty()) {
     try {
       Integer.parseInt(salaryTo);
     } catch (NumberFormatException e) {
       return false;
     }
   }
   if (status != null && !status.isEmpty()) {
     try {
       RecruitmentStatus.valueOf(status);
     } catch (Exception e) {
       return false;
     }
   }
   if (assignedTeam != null
       && !assignedTeam.isEmpty()
       && !UsersDao.instance.getAllTeams().contains(assignedTeam)) {
     return false;
   }
   return true;
 }
Ejemplo n.º 3
0
  @RequestMapping(
      value = "/jobs/{jobId}/update",
      method = {RequestMethod.POST})
  public String updateJob(@PathVariable String jobId, HttpServletRequest request, ModelMap model) {
    User user = (User) request.getSession().getAttribute("user");
    if (user == null) {
      model.addAttribute("errorMsg", "User has no permission");
      return "login";
    }
    String closingDate = request.getParameter("closingDate");
    String salary = request.getParameter("salary");
    String positionType = request.getParameter("positionType");
    String location = request.getParameter("location");
    String description = request.getParameter("description");
    String status = request.getParameter("status");
    String assignedTeam = request.getParameter("assignedTeam");

    Job updatedJob = JobsDao.instance.getById(jobId);
    if (closingDate != null) {
      updatedJob.setClosingDate(closingDate);
    }
    if (salary != null) {
      updatedJob.setSalary(Integer.parseInt(salary));
    }
    if (positionType != null) {
      updatedJob.setPositionType(positionType);
    }
    if (location != null) {
      updatedJob.setLocation(location);
    }
    if (description != null) {
      updatedJob.setDescription(description);
    }
    if (status != null) {
      updatedJob.setStatus(RecruitmentStatus.valueOf(status));
    }
    if (assignedTeam != null) {
      if (assignedTeam.isEmpty()) {
        assignedTeam = null;
      } else { // if hiring team is assigned and auto-check is done, proceed to next recruitment
               // stage
        DetailedJob j = new DetailedJob(JobsDao.instance.getById(jobId));
        j.setApplications(
            ORSKEY,
            user.getShortKey(),
            (ArrayList<Application>)
                ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId));
        if (j.allApplicationsAutoChecked()) {
          updatedJob.setStatus(RecruitmentStatus.IN_REVIEW);
          // update status for all applications of the job
          List<Application> applications =
              ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
          for (Application a : applications) {
            a.setStatus(ApplicationStatus.IN_REVIEW);
            ApplicationsDao.instance.update(a);
          }
        }
      }
      updatedJob.setAssignedTeam(assignedTeam);
    }
    if (!validateInput(
        closingDate, salary, positionType, location, description, status, assignedTeam)) {
      model.addAttribute("errorMsg", "Invalid form data");
      model.addAttribute("job", updatedJob);
      return "redirect:/jobs/" + jobId + "/edit";
    }
    try {
      JobsDao.instance.update(ORSKEY, user.getShortKey(), updatedJob);
      return "redirect:/jobs/" + jobId;
    } catch (Exception e) {
      e.printStackTrace();
      model.addAttribute("errorMsg", e.getMessage());
      return "error";
    }
  }