Пример #1
0
  @RequestMapping(value = "/init", method = RequestMethod.GET)
  public String init(ModelMap model) {

    if (studentSystem == null) {
      model.addAttribute("message", "Error filling in data. studentSystem == null");
    } else {
      int john = studentSystem.addStudent("John McClane");
      int jane = studentSystem.addStudent("Jane Fonda");
      int inf5750 = studentSystem.addCourse("INF5750", "Open Source Development");
      int inf5761 = studentSystem.addCourse("INF5761", "Health management information systems");

      int master = studentSystem.addDegree("Master");
      int bachelor = studentSystem.addDegree("Bachelor");
      int phd = studentSystem.addDegree("PhD");

      studentSystem.addAttendantToCourse(inf5750, john);
      studentSystem.addAttendantToCourse(inf5750, jane);
      studentSystem.addAttendantToCourse(inf5761, john);
      studentSystem.addAttendantToCourse(inf5761, jane);

      studentSystem.addRequiredCourseToDegree(master, inf5761);

      model.addAttribute("message", "Filled in data OK");
    }

    model.addAttribute("message", "Filling in data");

    populateModel(model);
    return "index";
  }
Пример #2
0
  private ModelMap populateModel(ModelMap model) {
    Collection<Student> students = studentSystem.getAllStudents();
    model.addAttribute("students", students);
    Collection<Course> courses = studentSystem.getAllCourses();
    model.addAttribute("courses", courses);
    Collection<Degree> degrees = studentSystem.getAllDegrees();
    model.addAttribute("degrees", degrees);

    return model;
  }
Пример #3
0
  @RequestMapping(value = "/student/{studentId}/enrolldegree", method = RequestMethod.POST)
  public String enrollDegree(
      ModelMap model,
      @PathVariable("studentId") int studentId,
      @RequestParam("degreeid") int degreeId) {

    logger.debug("Enrolling student " + studentId + " in degree " + degreeId);
    if (studentSystem.studentFulfillsDegreeRequirements(studentId, degreeId)) {
      studentSystem.addDegreeToStudent(studentId, degreeId);
    } else {
      model.addAttribute("message", "Student does not fulfill course requirements. ");
    }
    populateModel(model);
    return "student";
  }
Пример #4
0
  @RequestMapping(value = "/student/{studentId}/delete", method = RequestMethod.GET)
  public String deleteStudent(ModelMap model, @PathVariable("studentId") int studentId) {

    studentSystem.delStudent(studentId);
    populateModel(model);
    return "student";
  }
Пример #5
0
  @RequestMapping(value = "/student/new", method = RequestMethod.POST)
  public String createStudent(ModelMap model, @RequestParam("name") String name) {

    studentSystem.addStudent(name);
    populateModel(model);
    return "student";
  }
Пример #6
0
  @RequestMapping(value = "/degree/{degreeId}/delete", method = RequestMethod.GET)
  public String deleteDegree(ModelMap model, @PathVariable("degreeId") int degreeId) {

    studentSystem.delDegree(degreeId);
    populateModel(model);
    return "degree";
  }
Пример #7
0
  @RequestMapping(value = "/degree/new", method = RequestMethod.POST)
  public String createDegree(ModelMap model, @RequestParam("type") String type) {

    studentSystem.addDegree(type);
    populateModel(model);
    return "degree";
  }
Пример #8
0
  @RequestMapping(value = "/course/{courseId}/delete", method = RequestMethod.GET)
  public String deleteCourse(ModelMap model, @PathVariable("courseId") int courseId) {

    studentSystem.delCourse(courseId);
    populateModel(model);
    return "course";
  }
Пример #9
0
  @RequestMapping(value = "/course/new", method = RequestMethod.POST)
  public String createCourse(
      ModelMap model,
      @RequestParam("name") String name,
      @RequestParam("coursecode") String courseCode) {

    studentSystem.addCourse(courseCode, name);
    populateModel(model);
    return "course";
  }
Пример #10
0
  @RequestMapping(value = "/student/{studentId}/enrollcourse", method = RequestMethod.POST)
  public String enrollCourse(
      ModelMap model,
      @PathVariable("studentId") int studentId,
      @RequestParam("courseid") int courseId) {

    logger.debug("Enrolling student " + studentId + " in course " + courseId);
    studentSystem.addAttendantToCourse(courseId, studentId);
    populateModel(model);
    return "student";
  }
Пример #11
0
  @RequestMapping(value = "/degree/{degreeId}/requiredcourse", method = RequestMethod.POST)
  public String addRequiredCourse(
      ModelMap model,
      @PathVariable("degreeId") int degreeId,
      @RequestParam("courseid") int courseId) {

    logger.debug("Adding required course " + courseId + " in degree " + degreeId);
    studentSystem.addRequiredCourseToDegree(degreeId, courseId);
    populateModel(model);
    return "degree";
  }
Пример #12
0
  @RequestMapping(
      value = "/degree/{degreeId}/removerequiredcourse/{courseId}",
      method = RequestMethod.GET)
  public String removeRequiredCourse(
      ModelMap model,
      @PathVariable("degreeId") int degreeId,
      @PathVariable("courseId") int courseId) {

    logger.debug("Removing required course " + courseId + " in degree " + degreeId);
    studentSystem.removeRequiredCourseFromDegree(degreeId, courseId);
    populateModel(model);
    return "degree";
  }
Пример #13
0
  @RequestMapping(
      value = "/student/{studentId}/unenrollcourse/{courseId}",
      method = RequestMethod.GET)
  public String unenrollCourse(
      ModelMap model,
      @PathVariable("studentId") int studentId,
      @PathVariable("courseId") int courseId) {

    logger.debug("Un-Enrolling student " + studentId + " in course " + courseId);
    studentSystem.removeAttendantFromCourse(courseId, studentId);
    populateModel(model);
    return "student";
  }