private void build(ReportXml report, Student student, String purpose) {
    if (purpose == null) {
      purpose = "";
    }
    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_dat",
        student.getLastNameDative()
            + " "
            + student.getFirstNameDative()
            + " "
            + student.getMiddleNameDative());
    report.addValue("Student.lastName_dat", student.getLastNameDative());
    report.addValue("Student.firstName_dat", student.getFirstNameDative());
    report.addValue("Student.middleName_dat", student.getMiddleNameDative());

    report.addValue("Student.courseNumber", student.getGroup().getCourse().toString());

    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);

    String startDate = "";
    String endDate = "";
    String orderNumber = "";
    String orderDate = "";

    if (order != null) {
      Date date = order.getEnrollmentDate();
      SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");

      startDate = dateFormat.format(date);

      endDate = dateFormat.format(student.getReleaseDate());
      orderNumber = order.getNumber();
      orderDate = dateFormat.format(order.getSignedDate());
    }

    report.addValue("Student.startDate", startDate); // "01.09.2007"
    report.addValue("Student.endDate", endDate); // "01.07.2012"
    report.addValue("Student.order.number", orderNumber); // "22-0107"
    report.addValue("Student.order.date", orderDate); // "12.08.2007"

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

    switch (student.getStudyForm()) {
      case BUDGET:
        studyForm = "бюджетная";
        break;
      case COMMERCIAL:
        studyForm = "коммерческая";
        break;
    }
    report.addValue("Student.studyForm", studyForm);
    report.addValue("Purpose", purpose);
  }
  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());
  }