コード例 #1
0
ファイル: StudentCatalog.java プロジェクト: davidbedok/oejava
 public List<Student> compare(Sex sex, String direction, Sport sport, Student student) {
   List<Student> result = new ArrayList<Student>();
   Student refStudent = this.find(student.getName());
   Integer refResult = refStudent.getResult(sport);
   for (Student currentStudent : this.students) {
     if (student.getSex().equals(sex)) {
       Integer currentResult = currentStudent.getResult(sport);
       if (currentResult != null) {
         if ("better".equals(direction)) {
           if (refResult < currentResult) {
             result.add(currentStudent);
           }
         } else {
           if (refResult > currentResult) {
             result.add(currentStudent);
           }
         }
       }
     }
   }
   return result;
 }
コード例 #2
0
 public void insertStudent(Student student) throws SQLException {
   PreparedStatement stmt = null;
   try {
     stmt =
         con.prepareStatement(
             "INSERT INTO students "
                 + "(firstName, patronymic, surName, sex, dateOfBirth, group_id, educationYear) "
                 + "VALUES (?, ?, ?, ?, ?, ?, ?)");
     stmt.setString(1, student.getFirstName());
     stmt.setString(2, student.getPatronymic());
     stmt.setString(3, student.getSurName());
     stmt.setString(4, new String(new char[] {student.getSex()}));
     stmt.setDate(5, new Date(student.getDateOfBirth().getTime()));
     stmt.setInt(6, student.getGroupId());
     stmt.setInt(7, student.getEducationYear());
     stmt.execute();
   } finally {
     if (stmt != null) {
       stmt.close();
     }
   }
 }
コード例 #3
0
 public void updateStudent(Student student) throws SQLException {
   PreparedStatement stmt = null;
   try {
     stmt =
         con.prepareStatement(
             "UPDATE students SET "
                 + "firstName=?, patronymic=?, surName=?, "
                 + "sex=?, dateOfBirth=?, group_id=?, educationYear=?"
                 + "WHERE student_id=?");
     stmt.setString(1, student.getFirstName());
     stmt.setString(2, student.getPatronymic());
     stmt.setString(3, student.getSurName());
     stmt.setString(4, new String(new char[] {student.getSex()}));
     stmt.setDate(5, new Date(student.getDateOfBirth().getTime()));
     stmt.setInt(6, student.getGroupId());
     stmt.setInt(7, student.getEducationYear());
     stmt.setInt(8, student.getStudentId());
     stmt.execute();
   } finally {
     if (stmt != null) {
       stmt.close();
     }
   }
 }
コード例 #4
0
  private void build(ReportXml report, Student student) {
    putDefaultValues(report.getValuesMap());
    report.addValue("FACULTY_FULLNAME", student.getSpeciality().getFaculty().getFullName());
    report.addValue("FACULTY_SHORTNAME", student.getSpeciality().getFaculty().getShortName());

    report.addValue(
        "FACULTY_DEAN", student.getSpeciality().getFaculty().getDean().generateShortName(true));

    report.addValue(
        "RECTOR",
        student
            .getSpeciality()
            .getFaculty()
            .getAdministration()
            .getRector()
            .generateShortName(true));
    report.addValue(
        "RECTOR_DEGREE",
        student.getSpeciality().getFaculty().getAdministration().getRector().getDegree());

    report.addValue(
        "Student.fullName",
        student.getLastName() + " " + student.getFirstName() + " " + student.getMiddleName());
    report.addValue("Student.lastName", student.getLastName());
    report.addValue("Student.firstName", student.getFirstName());
    report.addValue("Student.middleName", student.getMiddleName());

    report.addValue("Student.courseNumber", student.getGroup().getCourse().toString());
    report.addValue("Student.speciality", student.getSpeciality().getShortName());
    report.addValue("Student.specialityCode", student.getSpeciality().getCode());

    EnrollmentOrder order = student.getEnrollmentOrder();
    String division = "неизвестного";

    switch (student.getDivision()) {
      case INTRAMURAL:
        division = "очного";
        break;
      case EXTRAMURAL:
        division = "заочного";
        break;
      case EVENINGSTUDY:
        division = "вечернего";
        break;
    }
    report.addValue("Student.division_rad", division);

    SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    SimpleDateFormat dateFormatYear = new SimpleDateFormat("yyyy");
    Date date = order.getEnrollmentDate();

    // Борьба с ленивой загрузкой
    // http://forum.vingrad.ru/forum/topic-258355.html
    // http://www.javalobby.org/java/forums/t62077.html
    // .initialize(student.getAdditionalData());
    // Hibernate.initialize(student.getAdditionalData().getPhoto());

    report.addValue("Student.birthday", dateFormat.format(student.getBirthday()));
    report.addValue("Student.birthPlace", student.getAdditionalData().getBirthPlace());

    report.addValue("Student.photoData", student.getAdditionalData().getPhoto().getData());

    report.addValue("Student.startDate", dateFormat.format(date)); // "01.09.2007"
    report.addValue("Student.startYear", dateFormatYear.format(date));

    report.addValue("Student.endDate", dateFormat.format(student.getReleaseDate())); // "01.07.2012"
    report.addValue("Student.order.number", order.getNumber()); // "22-0107"
    report.addValue("Student.order.date", dateFormat.format(order.getSignedDate())); // "12.08.2007"

    String studyForm = "неизвестная";

    switch (student.getStudyForm()) {
      case BUDGET:
        studyForm = "бюджетная";
        break;
      case COMMERCIAL:
        studyForm = "коммерческая";
        break;
    }
    report.addValue("Student.studyForm", studyForm);

    String str = "";

    switch (student.getSex()) {
      case MALE:
        str = "М";
        break;
      case FEMALE:
        str = "Ж";
        break;
    }
    report.addValue("Student.sex", str);

    report.addValue("Student.education", student.getAdditionalData().getEducation());
    report.addValue("Student.workInfo", student.getAdditionalData().getWorkInfo());
    str = student.getAdditionalData().getMaritalStatus();
    report.addValue("Student.maritalStatus", str == null ? "\n" : str);
    str = student.getAdditionalData().getChildrenInfo();
    report.addValue("Student.childrenInfo", str == null ? "\n" : str);

    Passport firstPassport = student.getAdditionalData().getPassports().get(0);
    Passport lastPassport;
    /*Passport actualPasport = null;

    for (Passport currentPassport : student.getAdditionalData().getPassports()) {
        if (currentPassport.isActual()) {
            actualPasport = currentPassport;
            break;
        }
    }
    report.addValue("Student.citizenship", actualPasport.getCitizenship());
    */
    if (student.getAdditionalData().getPassports().size() > 1) {
      lastPassport =
          student
              .getAdditionalData()
              .getPassports()
              .get(student.getAdditionalData().getPassports().size() - 1);
      report.addValue("Student.citizenship", lastPassport.getCitizenship());
    } else {
      lastPassport = new Passport();
      new PassportServiceImpl().fillAllFields(lastPassport, "");
      report.addValue("Student.citizenship", firstPassport.getCitizenship());
    }

    report.addValue(
        "Student.firstPassport.fullName",
        firstPassport.getLastName()
            + " "
            + firstPassport.getFirstName()
            + " "
            + firstPassport.getMiddleName());
    report.addValue("Student.firstPassport.citizenship", firstPassport.getCitizenship());
    report.addValue("Student.firstPassport.number", firstPassport.getNumber());
    report.addValue("Student.firstPassport.series", firstPassport.getSeries());
    report.addValue(
        "Student.firstPassport.issuedDate", dateFormat.format(firstPassport.getIssuedDate()));
    report.addValue(
        "Student.firstPassport.issuingOrganization", firstPassport.getIssuingOrganization());

    report.addValue(
        "Student.lastPassport.fullName",
        lastPassport.getLastName()
            + " "
            + lastPassport.getFirstName()
            + " "
            + lastPassport.getMiddleName());
    report.addValue("Student.lastPassport.citizenship", lastPassport.getCitizenship());
    report.addValue("Student.lastPassport.number", lastPassport.getNumber());
    report.addValue("Student.lastPassport.series", lastPassport.getSeries());
    report.addValue(
        "Student.lastPassport.issuedDate",
        lastPassport.getIssuedDate() == null
            ? ""
            : dateFormat.format(lastPassport.getIssuedDate()));
    report.addValue(
        "Student.lastPassport.issuingOrganization", lastPassport.getIssuingOrganization());

    Parent father = student.getAdditionalData().getFather();
    Parent mother = student.getAdditionalData().getMother();

    report.addValue(
        "Student.father.fullName",
        father.getLastName() + " " + father.getFirstName() + " " + father.getMiddleName());
    report.addValue("Student.father.birthday", dateFormat.format(father.getBirthday()));
    report.addValue("Student.father.address", father.getAddress());
    report.addValue("Student.father.workInfo", father.getWorkInfo());
    report.addValue("Student.father.phoneNumbers", father.getPhoneNumbers());

    report.addValue(
        "Student.mother.fullName",
        mother.getLastName() + " " + mother.getFirstName() + " " + mother.getMiddleName());
    report.addValue("Student.mother.birthday", dateFormat.format(mother.getBirthday()));
    report.addValue("Student.mother.address", mother.getAddress());
    report.addValue("Student.mother.workInfo", mother.getWorkInfo());
    report.addValue("Student.mother.phoneNumbers", mother.getPhoneNumbers());

    report.addValue("Student.oldAddress", student.getAdditionalData().getOldAddress());
    report.addValue("Student.actualAddress", student.getAdditionalData().getActualAddress());
    report.addValue(
        "Student.passportAddress",
        student.getAdditionalData().getPassports().size() > 1
            ? lastPassport.getAddress()
            : firstPassport.getAddress());
  }