Beispiel #1
0
 public String execute() throws Exception {
   StudentDao dao = new StudentDao();
   boolean update = dao.updateInfo(info());
   if (update) {
     message = "success";
   }
   return message;
 }
  public void dropEnrolledSection(Student student, int sectionNo) {
    StudentDao sd = dataAccess.createStudentDao();
    sd.dropEnrolledSection(student, sectionNo);

    SectionDao scd = dataAccess.createSectionDao();
    Section section = scd.getSection(sectionNo);

    student.dropSection(section);
  }
  public String getEnrolledSections(Student student) {
    JSONArray ja = new JSONArray();

    StudentDao sd = dataAccess.createStudentDao();
    List<Section> sections = sd.getEnrolledSections(student);

    for (Section s : sections) {
      JSONObject jo = new JSONObject();
      jo.put("sectionNo", s.getSectionNo());
      jo.put("day", s.getDayOfWeek());
      jo.put("time", s.getTimeOfDay());
      jo.put("room", s.getRoom());
      jo.put("sCapacity", s.getSeatingCapacity());
      jo.put("courseName", s.getRepresentedCourse().getCourseName());
      jo.put("professor", s.getInstructor().getName());
      ja.put(jo);
    }
    return ja.toString();
  }
Beispiel #4
0
 private static void testDatabase() {
   Student student = (Student) studentDao.list("stud1").toArray()[0];
   System.out.println("last name: " + student.getLastName());
   System.out.println("group name: " + student.getGroup().getName());
   for (Student student1 : student.getGroup().getStudentList()) {
     System.out.println("students in group: " + student1.getFirstName());
   }
   System.out.println("curator last name: " + student.getGroup().getCurator().getLastName());
   for (GroupLection groupLection : student.getGroup().getCurator().getGroupLectionList()) {
     System.out.println("group lection time: " + groupLection.getDate());
   }
   LossStudent lossStudent = (LossStudent) lossStudentDao.list().toArray()[0];
   System.out.println(
       lossStudent.getDate()
           + " "
           + lossStudent.getStudent().getLastName()
           + " "
           + lossStudent.getLection().getName());
 }
Beispiel #5
0
  private static void fillDatabase() {

    Teacher teacher = new Teacher();
    teacher.setFirstName("Ivan");
    teacher.setLastName("Ivanov");
    teacherDao.save(teacher);

    Teacher teacher2 = new Teacher();
    teacher2.setFirstName("Petr");
    teacher2.setLastName("Petrov");
    teacherDao.save(teacher2);

    Group group = new Group();
    group.setCreated(new Date());
    group.setCurator(teacher);
    group.setName("1");
    groupDao.save(group);

    Student student = new Student();
    student.setBirthday(new Date());
    student.setFirstName("stud1");
    student.setLastName("stud1");
    Group group1 = (Group) groupDao.list("1").toArray()[0];
    student.setGroup(group1);
    studentDao.save(student);

    Student student2 = new Student();
    student2.setBirthday(new Date());
    student2.setFirstName("stud2");
    student2.setLastName("stud2");
    student2.setGroup(group1);
    studentDao.save(student2);

    Student student3 = new Student();
    student3.setBirthday(new Date());
    student3.setFirstName("stud3");
    student3.setLastName("stud3");
    student3.setGroup(group1);
    studentDao.save(student3);

    Lection lection = new Lection();
    lection.setName("Math");
    lectionDao.save(lection);

    Lection lection1 = new Lection();
    lection1.setName("Phisics");
    lectionDao.save(lection1);

    Lection lection2 = (Lection) lectionDao.list("Math").toArray()[0];
    Teacher teacher3 = (Teacher) teacherDao.list("Ivan").toArray()[0];
    GroupLection groupLection = new GroupLection();
    groupLection.setDate(new Date());
    groupLection.setGroup(group1);
    groupLection.setLection(lection2);
    groupLection.setTeacher(teacher3);
    groupLectionDao.save(groupLection);

    LossStudent lossStudent = new LossStudent();
    lossStudent.setDate(new Date());
    lossStudent.setGroup(group1);
    lossStudent.setLection(lection2);
    lossStudent.setStudent(student3);
    lossStudent.setReason("sleeping");
    lossStudentDao.save(lossStudent);
  }