private AutoPopulatingList<UserCourseFormAttribute> getNewUserCourseFormAttributeList() {
   AutoPopulatingList<UserCourseFormAttribute> userCourseList =
       new AutoPopulatingList<UserCourseFormAttribute>(new UserCourseFormAttributeFactory());
   UserCourseFormAttribute userCourseOne = new UserCourseFormAttribute();
   userCourseOne.setUniversity("University of Bern");
   userCourseOne.setSubject("Computer Science");
   userCourseOne.setCourse("ESE");
   userCourseOne.setGrade("6");
   userCourseOne.setTeaching(true);
   userCourseList.add(userCourseOne);
   return userCourseList;
 }
 private AutoPopulatingList<TimeSlot> getNewTimeSlotList() {
   AutoPopulatingList<TimeSlot> timeSlotList =
       new AutoPopulatingList<TimeSlot>(new TimeSlotFactory());
   TimeSlot expectedtimeSlot = new TimeSlot();
   expectedtimeSlot.setSemesterOrSemesterBreak("Autumn semester 2015");
   expectedtimeSlot.setDay("Monday");
   expectedtimeSlot.setStartTime("07:00");
   expectedtimeSlot.setEndTime("08:00");
   expectedtimeSlot.setRemove(false);
   timeSlotList.add(expectedtimeSlot);
   return timeSlotList;
 }
 /**
  * This method...
  *
  * @param map
  */
 protected void removeRestrictedFieldChangedErrors(MessageMap map, String propertyKey) {
   AutoPopulatingList<ErrorMessage> errorMessages = map.getErrorMessagesForProperty(propertyKey);
   if (errorMessages != null) {
     for (int i = 0; i < errorMessages.size(); i++) {
       ErrorMessage eMessage = (ErrorMessage) errorMessages.get(i);
       String errorKey = eMessage.getErrorKey();
       if (errorKey.equals(
           KFSKeyConstants.ERROR_DOCUMENT_AUTHORIZATION_RESTRICTED_FIELD_CHANGED)) {
         errorMessages.remove(i);
       }
     }
   }
 }
  /**
   * Serve model with signupForm.
   *
   * @param principal the logged in principal.
   * @return a signupForm with filled name and biography fields.
   */
  @ModelAttribute("signupForm")
  public SignupForm getSignupForm(Principal principal) {
    User user = userService.getPrincipalUser();

    SignupForm form = new SignupForm();
    form.setFirstName(user.getFirstName());
    form.setLastName(user.getLastName());
    form.setBiography(user.getBiography());

    try {
      AutoPopulatingList<UserCourseFormAttribute> userCourseList =
          new AutoPopulatingList<UserCourseFormAttribute>(new UserCourseFormAttributeFactory());
      Iterator<UserCourse> itr = userCourseDao.findByUser(user).iterator();
      while (itr.hasNext()) {
        UserCourse tmpUserCourse = itr.next();
        UserCourseFormAttribute formAttr = new UserCourseFormAttribute();
        formAttr.setUniversity(tmpUserCourse.getCourse().getSubject().getUniversity().toString());
        formAttr.setSubject(tmpUserCourse.getCourse().getSubject().toString());
        formAttr.setCourse(tmpUserCourse.getCourse().toString());
        formAttr.setGrade(String.valueOf(tmpUserCourse.getGrade()));
        formAttr.setTeaching(tmpUserCourse.isTeaching());
        userCourseList.add(formAttr);
      }
      form.setUserCourseList(userCourseList);
    } catch (Exception e) {
    }

    try {
      AutoPopulatingList<TimeSlot> timeSlotList =
          new AutoPopulatingList<TimeSlot>(new TimeSlotFactory());
      ListIterator<TimeSlot> iter = user.getTimeSlots().listIterator();
      while (iter.hasNext()) {
        timeSlotList.add(iter.next());
      }
      form.setTimeSlots(timeSlotList);
    } catch (Exception e) {
    }

    return form;
  }