public boolean canRequestTeaching(Person person) {
   List<UserRequest> results = searchTeachingRequest(person.getId());
   for (UserRequest request : results) {
     if (request.getStatus().equalsIgnoreCase("ag")) return false;
     if (request.getStatus().equalsIgnoreCase("ap")) return false;
   }
   return true;
 }
 public boolean canRequestAssistance(Person person, Course course) {
   List<UserRequest> results = searchRequestByUserID(course.getId(), person.getId());
   for (UserRequest request : results) {
     if (request.getStatus().equalsIgnoreCase("ag")) return false;
     if (request.getStatus().equalsIgnoreCase("ap")) return false;
   }
   return true;
 }
 public void approveRequest(UserRequest request, Person evaluator) {
   RequestEvaluation requestEvaluation = new RequestEvaluation();
   requestEvaluation.setPerson(evaluator);
   requestEvaluation.setRequest(request);
   requestEvaluation.setEvaluationDate(new Date());
   request.setStatus(Constants.APPROVED);
   this.insertRequestEvaluation(requestEvaluation);
   this.updateUserRequest(request);
   if (!request.isTeachingRequest()) {
     this.approveAssistantRequest(request, evaluator);
   }
 }
 public void requestTeacherProfile(UserRequest userRequest) throws RequestException {
   List<UserRequest> results = searchTeachingRequest(userRequest.getPerson().getId());
   for (UserRequest request : results) {
     if (request.getStatus().equalsIgnoreCase("ag")) {
       throw new RequestException("errors.request.waiting");
     }
     if (request.getStatus().equalsIgnoreCase("ap")) {
       throw new RequestException("errors.request.approved");
     }
   }
   userRequest.setStatus("ag");
   insertUserRequest(userRequest);
 }
 public void approveAssistantRequest(UserRequest request, Person evaluator) {
   AcademicController ac = new AcademicController();
   Role role = ac.searchRoleByConstant(Constants.MONITOR);
   PersonRoleCourse prc = this.searchPersonRoleCourse(request.getPerson(), request.getCourse());
   if (prc != null) {
     this.deletePersonRoleCourse(prc);
   }
   PersonRoleCourse prcc = new PersonRoleCourse();
   prcc.setCourse(request.getCourse());
   prcc.setPerson(request.getPerson());
   prcc.setRole(role);
   prcc.setDate(new Date());
   this.updatePersonRoleCourse(prcc);
 }
 public void disapproveRequest(UserRequest userRequest, Person evaluator) {
   RequestEvaluation requestEvaluation = new RequestEvaluation();
   requestEvaluation.setPerson(evaluator);
   requestEvaluation.setRequest(userRequest);
   requestEvaluation.setEvaluationDate(new Date());
   userRequest.setStatus(Constants.DISAPPROVED);
   this.insertRequestEvaluation(requestEvaluation);
   this.updateUserRequest(userRequest);
 }
 public void requestAssistance(UserRequest userRequest) throws RequestException {
   List<UserRequest> results =
       searchRequestByUserID(userRequest.getCourse().getId(), userRequest.getPerson().getId());
   for (UserRequest request : results) {
     if (request.getStatus().equalsIgnoreCase("ag")) {
       throw new RequestException("errors.request.waiting");
     }
     if (request.getStatus().equalsIgnoreCase("ap")) {
       throw new RequestException("errors.request.approved");
     }
   }
   userRequest.setStatus("ag");
   insertUserRequest(userRequest);
 }