// See one project
 @RequestMapping(value = "viewproject", method = RequestMethod.GET)
 public ModelAndView viewproject(Integer id) throws Exception {
   ModelAndView mav = new ModelAndView();
   ProjectWrapper pw = projectDao.getProjectWrapperById(id);
   mav.addObject("pw", pw);
   Date now = new Date();
   DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
   if (!pw.getProject().getEndDate().trim().equals("")) {
     boolean expired = now.after(df.parse(pw.getProject().getEndDate()));
     mav.addObject("expired", expired);
   }
   for (RPLink r : pw.getRpLinks()) {
     if (!r.getResearcher().getEndDate().trim().equals("")) {
       if (now.after(df.parse(r.getResearcher().getEndDate()))) {
         r.getResearcher().setFullName(r.getResearcher().getFullName() + " (expired)");
       }
     }
   }
   for (APLink a : pw.getApLinks()) {
     if (a.getAdviser().getEndDate() != null && !a.getAdviser().getEndDate().trim().equals("")) {
       if (now.after(df.parse(a.getAdviser().getEndDate()))) {
         a.getAdviser().setFullName(a.getAdviser().getFullName() + " (expired)");
       }
     }
   }
   mav.addObject("jobauditBaseProjectUrl", this.jobauditBaseProjectUrl);
   return mav;
 }
  private boolean isProjectValid(ProjectWrapper pw) {
    if (pw.getProject().getName().trim().equals("")) {
      pw.setErrorMessage("A project must have a title");
      return false;
    }

    // Exactly one PI?
    int count = 0;
    for (RPLink rp : pw.getRpLinks()) {
      if (rp.getResearcherRoleId() == 1) {
        count += 1;
      }
    }
    if (count == 0 || count > 1) {
      pw.setErrorMessage("There must be exactly 1 project owner on a project");
      return false;
    }

    // Exactly one primary adviser?
    count = 0;
    for (APLink ap : pw.getApLinks()) {
      if (ap.getAdviserRoleId() == 1) {
        count += 1;
      }
    }
    if (count == 0 || count > 1) {
      pw.setErrorMessage("There must be exactly 1 primary adviser on a project");
      return false;
    }
    // At least one HPC
    if (pw.getProjectFacilities().isEmpty()) {
      pw.setErrorMessage("There must be at least one HPC facility associated with the project");
      return false;
    }
    return true;
  }