@Test
  public void test1() throws Exception {

    Student denise = studentHome.create("823", "Denise Smith");

    Course power = courseHome.create("220", "Power J2EE Programming");

    Enroller enroller = enrollerHome.create();
    enroller.enroll("823", "220");
    enroller.enroll("823", "333");
    enroller.enroll("823", "777");
    enroller.enroll("456", "777");
    enroller.enroll("388", "777");

    System.out.println(denise.getName() + ":");
    ArrayList courses = denise.getCourseIds();
    Iterator i = courses.iterator();
    while (i.hasNext()) {
      String courseId = (String) i.next();
      Course course = courseHome.findByPrimaryKey(courseId);
      System.out.println(courseId + " " + course.getName());
    }

    System.out.println();

    Course intro = courseHome.findByPrimaryKey("777");
    System.out.println(intro.getName() + ":");
    courses = intro.getStudentIds();
    i = courses.iterator();
    while (i.hasNext()) {
      String studentId = (String) i.next();
      Student student = studentHome.findByPrimaryKey(studentId);
      System.out.println(studentId + " " + student.getName());
    }
  }
Esempio n. 2
0
  public void addEdge(Course source, Course target) {

    if (this.edges.containsKey(source.getName())) {
      this.edges.get(source.getName()).put(target.getName(), target);
    } else {
      this.edges.put(source.getName(), new HashMap<String, Course>());
      this.edges.get(source.getName()).put(target.getName(), target);
    }
  }
Esempio n. 3
0
  public void addNode(Course course) {

    if (!this.nodes.containsKey(course.getName())) {
      this.nodes.put(course.getName(), course);
    }
  }