Ejemplo n.º 1
0
 @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";
 }
Ejemplo n.º 2
0
 @RequestMapping(
     value = "/jobs/{jobId}/finalList",
     method = {RequestMethod.GET})
 public String visitFinalListPage(
     @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);
     if (!j.getStatus().equals(RecruitmentStatus.SENT_INVITATIONS)) {
       return "redirect:/jobs";
     }
     List<Application> validApplications = new ArrayList<Application>();
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     for (Application a : applications) {
       if (a.getStatus().equals(ApplicationStatus.ACCEPTED_INVITATION)) {
         validApplications.add(a);
       }
     }
     model.addAttribute("applications", validApplications);
     model.addAttribute("job", j);
     return "finalList";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Ejemplo n.º 3
0
 @RequestMapping(
     value = "/jobs/{jobId}/shortlist",
     method = {RequestMethod.GET})
 public String visitShortlistPage(
     @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);
     if (j.getStatus().equals(RecruitmentStatus.CREATED)) {
       return "redirect:/jobs";
     }
     List<DetailedApplication> list = new ArrayList<DetailedApplication>();
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     for (Application a : applications) {
       DetailedApplication da = new DetailedApplication(a);
       da.setReviews(
           (ArrayList<Review>)
               ReviewsDao.instance.getByApplication(ORSKEY, user.getShortKey(), a.get_appId()));
       list.add(da);
     }
     model.addAttribute("applications", list);
     model.addAttribute("job", j);
     return "shortlist";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Ejemplo n.º 4
0
 @RequestMapping(value = "/jobs/{jobId}/startAutoChecks")
 public String doAutoChecks(
     @PathVariable String jobId,
     HttpServletRequest request,
     RedirectAttributes redirectAttrs,
     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 {
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     for (Application a : applications) {
       AutoCheckRequest req = new AutoCheckRequest();
       req.setLicenseNo(a.getLicenseNo());
       req.setFullName(a.getFullName());
       req.setPostcode(a.getPostcode());
       AutoCheckResponse response = autoCheckService.check(req);
       String pdvResult = response.getPdvResult();
       String crvResult = response.getCrvResult();
       // save result to API
       AutoCheckResult newAutoCheckResult = new AutoCheckResult();
       newAutoCheckResult.set_appId(a.get_appId());
       newAutoCheckResult.setPdvResult(pdvResult);
       newAutoCheckResult.setCrvResult(crvResult);
       AutoCheckResultsDao.instance.create(ORSKEY, user.getShortKey(), newAutoCheckResult);
     }
     Job j = JobsDao.instance.getById(jobId);
     if (j.getAssignedTeam() != null) {
       j.setStatus(RecruitmentStatus.IN_REVIEW);
       JobsDao.instance.update(ORSKEY, user.getShortKey(), j);
       // update status for all applications of the job
       for (Application a : applications) {
         a.setStatus(ApplicationStatus.IN_REVIEW);
         ApplicationsDao.instance.update(a);
       }
     }
     redirectAttrs.addFlashAttribute("successMsg", "Auto-checks run successfully");
     return "redirect:/jobs";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Ejemplo n.º 5
0
 @RequestMapping("/jobs/{id}/edit")
 public String visitEditJobPage(
     @PathVariable String id, 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(id);
     model.addAttribute("job", j);
     return "editJob";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Ejemplo n.º 6
0
 @RequestMapping(
     value = "/jobs/{jobId}/finalList",
     method = {RequestMethod.POST})
 public String submitfinalList(
     @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);
     if (!j.getStatus().equals(RecruitmentStatus.SENT_INVITATIONS)) {
       return "redirect:/jobs";
     }
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     if (request.getParameter("selectedCandidate") != null) {
       for (Application a : applications) {
         if (a.getStatus().equals(ApplicationStatus.ARCHIVED)) {
           continue;
         }
         if (request.getParameter("selectedCandidate").equals(a.get_appId())) {
           // TODO send notifications
         } else {
           // TODO send notifications
         }
         a.setStatus(ApplicationStatus.FINALISED);
         ApplicationsDao.instance.update(a);
       }
       j.setStatus(RecruitmentStatus.FINALISED);
       JobsDao.instance.update(ORSKEY, user.getShortKey(), j);
     }
     return "redirect:/jobs";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Ejemplo n.º 7
0
 @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";
   }
 }