예제 #1
0
  public CourseEntity buildFromDomainObject(Object domainObject) {
    if (domainObject == null) return null;

    Course course = (Course) domainObject;

    UserEntity creator =
        EntityFactoryVault.buildFromDomainObject((StaffMember) course.getCreator());
    UserEntity lastModifier =
        EntityFactoryVault.buildFromDomainObject((StaffMember) course.getLastModifier());
    SubjectEntity subject = EntityFactoryVault.buildFromDomainObject(course.getSubject());
    CourseComponentEntity[] components =
        (CourseComponentEntity[])
            EntityFactoryVault.buildFromDomainObjects(course.getCourseComponents());
    CourseEducationTypeEntity[] educationTypes =
        (CourseEducationTypeEntity[])
            EntityFactoryVault.buildFromDomainObjects(course.getCourseEducationTypes());
    Double courseLengthUnits = null;
    Long courseLengthUnitId = null;
    if (course.getCourseLength() != null) {
      courseLengthUnits = course.getCourseLength().getUnits();
      if (course.getCourseLength().getUnit() != null)
        courseLengthUnitId = course.getCourseLength().getUnit().getId();
    }

    int i = 0;
    String[] tags = new String[course.getTags().size()];
    for (Tag tag : course.getTags()) {
      tags[i++] = tag.getText();
    }

    return new CourseEntity(
        course.getId(),
        course.getName(),
        course.getNameExtension(),
        tags,
        creator,
        course.getCreated(),
        lastModifier,
        course.getLastModified(),
        course.getDescription(),
        subject,
        course.getCourseNumber(),
        courseLengthUnits,
        courseLengthUnitId,
        educationTypes,
        course.getArchived(),
        components,
        course.getModule().getId(),
        course.getBeginDate(),
        course.getEndDate());
  }
  public TransferCreditEntity buildFromDomainObject(Object domainObject) {
    if (domainObject == null) return null;

    TransferCredit transferCredit = (TransferCredit) domainObject;
    GradeEntity grade = EntityFactoryVault.buildFromDomainObject(transferCredit.getGrade());
    UserEntity assessingUser =
        EntityFactoryVault.buildFromDomainObject(transferCredit.getAssessor());

    return new TransferCreditEntity(
        transferCredit.getId(),
        transferCredit.getStudent().getId(),
        transferCredit.getDate(),
        grade,
        transferCredit.getVerbalAssessment(),
        assessingUser,
        transferCredit.getArchived(),
        transferCredit.getCourseName(),
        transferCredit.getCourseNumber(),
        transferCredit.getCourseLength().getUnits(),
        transferCredit.getCourseLength().getUnit().getId(),
        transferCredit.getSchool().getId(),
        transferCredit.getSubject().getId(),
        transferCredit.getOptionality().toString());
  }
예제 #3
0
  public StudentEntity buildFromDomainObject(Object domainObject) {
    if (domainObject == null) return null;

    Student student = (Student) domainObject;

    AbstractStudentEntity personEntity =
        EntityFactoryVault.buildFromDomainObject(student.getPerson());
    NationalityEntity nationalityEntity =
        EntityFactoryVault.buildFromDomainObject(student.getNationality());
    LanguageEntity languageEntity = EntityFactoryVault.buildFromDomainObject(student.getLanguage());
    MunicipalityEntity municipalityEntity =
        EntityFactoryVault.buildFromDomainObject(student.getMunicipality());
    SchoolEntity schoolEntity = EntityFactoryVault.buildFromDomainObject(student.getSchool());
    StudyProgrammeEntity studyProgramme =
        EntityFactoryVault.buildFromDomainObject(student.getStudyProgramme());

    String[] emails = new String[student.getContactInfo().getEmails().size()];
    int i = 0;
    for (Email email : student.getContactInfo().getEmails()) {
      emails[i++] = email.getAddress();
    }

    AddressEntity[] addresses = new AddressEntity[student.getContactInfo().getAddresses().size()];
    i = 0;
    for (Address address : student.getContactInfo().getAddresses()) {
      addresses[i++] = EntityFactoryVault.buildFromDomainObject(address);
    }

    // TODO phone number, parental info...

    String phoneNumberStr = null;
    for (PhoneNumber phoneNumber : student.getContactInfo().getPhoneNumbers()) {
      if (phoneNumber.getDefaultNumber()) {
        phoneNumberStr = phoneNumber.getNumber();
        break;
      }
    }

    String parentalInfo = student.getContactInfo().getAdditionalInfo();

    i = 0;
    String[] tags = new String[student.getTags().size()];
    for (Tag tag : student.getTags()) {
      tags[i++] = tag.getText();
    }

    return new StudentEntity(
        student.getId(),
        personEntity,
        emails,
        student.getFirstName(),
        student.getLastName(),
        tags,
        addresses,
        phoneNumberStr,
        student.getAdditionalInfo(),
        parentalInfo,
        student.getStudyTimeEnd(),
        nationalityEntity,
        languageEntity,
        municipalityEntity,
        schoolEntity,
        studyProgramme,
        student.getArchived(),
        student.getStudyStartDate(),
        student.getStudyEndDate());
  }