コード例 #1
0
ファイル: NewStudent.java プロジェクト: R-Rajkumar/ySchool
public class NewStudent {
  DataLayerYschool dataLayerYschool = DataLayerYschoolImpl.getInstance();

  public boolean addNewStudent(
      String admission_No,
      String name,
      String fullname,
      String name_wt_initial,
      Date dob,
      String gender,
      String address) {

    Student student = YschoolDataPoolFactory.getStudent();
    student.setAddress(admission_No);
    student.setName(name);
    student.setFullName(fullname);
    student.setNameWtInitial(name_wt_initial);
    student.setDob(dob);
    student.setGender(gender);
    student.setAddress(address);
    // TODO: hage to get bytestream to send database.
    // student.setPhoto(photo);

    dataLayerYschool.save(student);
    dataLayerYschool.flushSession();
    // TODO: save method does not indicates/returns success/failure
    return true;
  }
}
コード例 #2
0
  @Test
  @Transactional
  public void testPrediction() {

    DataLayerYschool dataLayerYschool = DataLayerYschoolImpl.getInstance();

    Student student = dataLayerYschool.getStudent(17);

    double re = -222;

    ClassroomSubject classroomSubject = dataLayerYschool.getClassroomSubject(2);
    Criteria marks = dataLayerYschool.createCriteria(Marks.class);
    marks.add(Restrictions.eq("studentIdstudent", student));
    marks
        .createAlias("examIdexam", "examId")
        .add(Restrictions.eq("examId.classroomSubjectIdclassroomSubject", classroomSubject));

    marks.add(Restrictions.eq("examId.term", 1));
    List<Marks> marksList = marks.list();
    if (marksList == null) {
      re = -1;
    } else if (marksList.isEmpty()) {
      re = -2;
    } else {
      if (marksList.get(0).getMarks() == null) {
        re = -3;
      }
    }
    //        if(marksList.get(0)!=null){
    //        re=marksList.get(0).getMarks();
    //        }

    Criteria classroomSubjectCR = dataLayerYschool.createCriteria(ClassroomSubject.class);
    // student_classroom_subject data is not ready yet
    // classroomSubjectCR.createAlias("studentClassroomSubjects",
    // "stclsu").createAlias("stclsu.classroomStudentIdclassroomStudent",
    // "clst").add(Restrictions.eq("clst.studentIdstudent", student));
    // so using this as temporary ,but this may violate optional subject...
    classroomSubjectCR
        .createAlias("classroomIdclass", "cl")
        .createAlias("cl.classroomStudents", "clst")
        .add(Restrictions.eq("clst.studentIdstudent", student));

    classroomSubjectCR.add(Restrictions.eq("cl.grade", 11));
    List<ClassroomSubject> lt = classroomSubjectCR.list();
    System.out.println("\n\n\n\n");

    System.out.println(lt.size());
    Iterator<ClassroomSubject> iterator = lt.iterator();

    while (iterator.hasNext()) {
      System.out.println("\n" + iterator.next().getSubjectIdsubject().getName());
    }

    System.out.println(lt.iterator().next().getSubjectIdsubject().getName());
    System.out.println(lt.iterator().next().getSubjectIdsubject().getName());
    System.out.println(lt.get(1).getSubjectIdsubject().getName());

    //        Criteria marks = dataLayerYschool.createCriteria(Marks.class);
    //        marks.add(Restrictions.eq("studentIdstudent", student));
    //        marks.createAlias("examIdexam",
    // "examId").add(Restrictions.eq("examId.classroomSubjectIdclassroomSubject", lt.get(0)));
    //
    //        marks.add(Restrictions.eq("examId.term", 3));
    //        List<Marks> marksList = marks.list();
    //        System.out.println("\n\n\n\n");
    //        System.out.println(marksList);

  }