Ejemplo n.º 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";
  }
Ejemplo n.º 2
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";
  }