コード例 #1
0
ファイル: JobController.java プロジェクト: williamfeng91/ors
 @RequestMapping(value = "/jobs/{id}")
 public String visitJobPage(@PathVariable String id, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   try {
     DetailedJob dj = new DetailedJob(JobsDao.instance.getById(id));
     if (user != null) {
       dj.setApplications(
           ORSKEY,
           user.getShortKey(),
           (ArrayList<Application>)
               ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), dj.get_jobId()));
     }
     model.addAttribute("job", dj);
     model.addAttribute("today", TODAY);
     return "jobDetails";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
コード例 #2
0
ファイル: JobController.java プロジェクト: williamfeng91/ors
 @RequestMapping(
     value = "/jobs/{jobId}/shortlist",
     method = {RequestMethod.POST})
 public String submitShortlist(
     @PathVariable String jobId, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   if (user == null || !user.getRole().equals("manager")) {
     model.addAttribute("errorMsg", "User has no permission");
     return "login";
   }
   try {
     Job j = JobsDao.instance.getById(jobId);
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     DetailedJob dj = new DetailedJob(j);
     dj.setApplications(ORSKEY, user.getShortKey(), (ArrayList<Application>) applications);
     if (!dj.getStatus().equals(RecruitmentStatus.IN_REVIEW) && dj.allApplicationsReviewed()) {
       return "redirect:/jobs";
     }
     for (Application a : applications) {
       if (request.getParameter(a.get_appId()) != null) {
         a.setStatus(ApplicationStatus.SHORTLISTED);
         // TODO send invitations
       } else {
         a.setStatus(ApplicationStatus.FINALISED);
         // TODO send notifications
       }
       ApplicationsDao.instance.update(a);
     }
     j.setStatus(RecruitmentStatus.SENT_INVITATIONS);
     JobsDao.instance.update(ORSKEY, user.getShortKey(), j);
     return "redirect:/jobs";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
コード例 #3
0
ファイル: JobController.java プロジェクト: williamfeng91/ors
 @RequestMapping(
     value = "/jobs",
     method = {RequestMethod.GET})
 public String visitJobListPage(
     @ModelAttribute("successMsg") final String successMsg,
     HttpServletRequest request,
     ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   try {
     if (user != null && user.getRole().equals("manager")) {
       List<DetailedJob> list = new ArrayList<DetailedJob>();
       List<Job> jobs = JobsDao.instance.getAll(ORSKEY, user.getShortKey());
       for (Job j : jobs) {
         DetailedJob dj = new DetailedJob(j);
         dj.setApplications(
             ORSKEY,
             user.getShortKey(),
             (ArrayList<Application>)
                 ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), dj.get_jobId()));
         list.add(dj);
       }
       model.addAttribute("jobs", list);
     } else if (user != null && user.getRole().equals("reviewer")) {
       List<DetailedJob> list = new ArrayList<DetailedJob>();
       List<Job> jobs =
           JobsDao.instance.getAssignedJobs(ORSKEY, user.getShortKey(), user.getDepartment());
       for (Job j : jobs) {
         DetailedJob dj = new DetailedJob(j);
         dj.setApplications(
             ORSKEY,
             user.getShortKey(),
             (ArrayList<Application>)
                 ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), dj.get_jobId()));
         list.add(dj);
       }
       model.addAttribute("jobs", list);
     } else {
       List<Job> list = JobsDao.instance.getOpenJobs();
       model.addAttribute("jobs", list);
     }
     model.addAttribute("today", TODAY);
     model.addAttribute("successMsg", successMsg);
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
   return "jobs";
 }
コード例 #4
0
ファイル: JobController.java プロジェクト: williamfeng91/ors
  @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";
    }
  }
コード例 #5
0
ファイル: JobController.java プロジェクト: williamfeng91/ors
  @RequestMapping(
      value = "/advSearchJob",
      method = {RequestMethod.POST})
  public String doAdvSearch(HttpServletRequest request, ModelMap model) {
    String closingDateFrom = request.getParameter("closingDateFrom");
    String closingDateTo = request.getParameter("closingDateTo");
    String salaryFrom = request.getParameter("salaryFrom");
    String salaryTo = request.getParameter("salaryTo");
    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");

    if (!validateSearchInput(
        closingDateFrom,
        closingDateTo,
        salaryFrom,
        salaryTo,
        positionType,
        location,
        description,
        status,
        assignedTeam)) {
      model.addAttribute("errorMsg", "Invalid form data");
      return "advSearchJob";
    }
    try {
      User user = (User) request.getSession().getAttribute("user");
      if (user == null) {
        List<Job> list =
            JobsDao.instance.search(
                null,
                null,
                closingDateFrom,
                closingDateTo,
                salaryFrom,
                salaryTo,
                positionType,
                location,
                description,
                status,
                assignedTeam);
        model.addAttribute("jobs", list);
      } else {
        List<DetailedJob> list = new ArrayList<DetailedJob>();
        List<Job> jobs =
            JobsDao.instance.search(
                ORSKEY,
                user.getShortKey(),
                closingDateFrom,
                closingDateTo,
                salaryFrom,
                salaryTo,
                positionType,
                location,
                description,
                status,
                assignedTeam);
        for (Job j : jobs) {
          DetailedJob dj = new DetailedJob(j);
          dj.setApplications(
              ORSKEY,
              user.getShortKey(),
              (ArrayList<Application>)
                  ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), dj.get_jobId()));
          list.add(dj);
        }
        model.addAttribute("jobs", list);
      }
      return "jobs";
    } catch (Exception e) {
      e.printStackTrace();
      model.addAttribute("errorMsg", e.getMessage());
      return "error";
    }
  }