Search in sources :

Example 21 with PersonDAO

use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.

the class StudentsService method listActiveStudentsByAbstractStudent.

public StudentEntity[] listActiveStudentsByAbstractStudent(@WebParam(name = "abstractStudentId") Long abstractStudentId) {
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
    Person person = personDAO.findById(abstractStudentId);
    return (StudentEntity[]) EntityFactoryVault.buildFromDomainObjects(studentDAO.listActiveStudentsByPerson(person));
}
Also used : StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) Person(fi.otavanopisto.pyramus.domainmodel.base.Person)

Example 22 with PersonDAO

use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.

the class StudentsService method createAbstractStudent.

public AbstractStudentEntity createAbstractStudent(@WebParam(name = "birthday") Date birthday, @WebParam(name = "socialSecurityNumber") String socialSecurityNumber, @WebParam(name = "sex") String sex) {
    PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
    // TODO: Parameterize?
    Boolean secureInfo = Boolean.FALSE;
    Sex studentSex = EnumType.valueOf(Sex.class, sex);
    Person person = personDAO.create(birthday, socialSecurityNumber, studentSex, null, secureInfo);
    validateEntity(person);
    return EntityFactoryVault.buildFromDomainObject(person);
}
Also used : PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) Sex(fi.otavanopisto.pyramus.domainmodel.students.Sex) Person(fi.otavanopisto.pyramus.domainmodel.base.Person)

Example 23 with PersonDAO

use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.

the class StudentsService method addStudyProgramme.

public StudentEntity addStudyProgramme(@WebParam(name = "studentId") Long studentId, @WebParam(name = "studyProgrammeId") Long studyProgrammeId) {
    // TODO Generalize to StudentDAO (also used in CopyStudentStudyProgrammeJSONRequestController)
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
    AddressDAO addressDAO = DAOFactory.getInstance().getAddressDAO();
    ContactInfoDAO contactInfoDAO = DAOFactory.getInstance().getContactInfoDAO();
    EmailDAO emailDAO = DAOFactory.getInstance().getEmailDAO();
    PhoneNumberDAO phoneNumberDAO = DAOFactory.getInstance().getPhoneNumberDAO();
    PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
    Student oldStudent = studentDAO.findById(studentId);
    Person person = oldStudent.getPerson();
    String firstName = oldStudent.getFirstName();
    String lastName = oldStudent.getLastName();
    String nickname = oldStudent.getNickname();
    String additionalInfo = oldStudent.getAdditionalInfo();
    // student.getPreviousStudies();
    Double previousStudies = null;
    // student.getStudyTimeEnd();
    Date studyTimeEnd = null;
    // student.getStudyStartDate();
    Date studyStartTime = null;
    // student.getStudyEndDate();
    Date studyEndTime = null;
    // student.getStudyEndText();
    String studyEndText = null;
    Language language = oldStudent.getLanguage();
    Municipality municipality = oldStudent.getMunicipality();
    StudentActivityType activityType = oldStudent.getActivityType();
    StudentExaminationType examinationType = oldStudent.getExaminationType();
    StudentEducationalLevel educationalLevel = oldStudent.getEducationalLevel();
    String education = oldStudent.getEducation();
    Nationality nationality = oldStudent.getNationality();
    School school = oldStudent.getSchool();
    StudyProgramme studyProgramme = studyProgrammeId == null ? null : studyProgrammeDAO.findById(studyProgrammeId);
    // student.getStudyEndReason();
    StudentStudyEndReason studyEndReason = null;
    Curriculum curriculum = oldStudent.getCurriculum();
    Student newStudent = studentDAO.create(person, firstName, lastName, nickname, additionalInfo, studyTimeEnd, activityType, examinationType, educationalLevel, education, nationality, municipality, language, school, studyProgramme, curriculum, previousStudies, studyStartTime, studyEndTime, studyEndReason, studyEndText, false);
    // Contact info
    contactInfoDAO.update(newStudent.getContactInfo(), oldStudent.getContactInfo().getAdditionalInfo());
    // Default user
    personDAO.updateDefaultUser(person, newStudent);
    // Addresses
    List<Address> addresses = oldStudent.getContactInfo().getAddresses();
    for (int i = 0; i < addresses.size(); i++) {
        Address add = addresses.get(i);
        addressDAO.create(newStudent.getContactInfo(), add.getContactType(), add.getName(), add.getStreetAddress(), add.getPostalCode(), add.getCity(), add.getCountry(), add.getDefaultAddress());
    }
    // E-mail addresses
    List<Email> emails = oldStudent.getContactInfo().getEmails();
    for (int i = 0; i < emails.size(); i++) {
        Email email = emails.get(i);
        emailDAO.create(newStudent.getContactInfo(), email.getContactType(), email.getDefaultAddress(), email.getAddress());
    }
    // Phone numbers
    List<PhoneNumber> phoneNumbers = oldStudent.getContactInfo().getPhoneNumbers();
    for (int i = 0; i < phoneNumbers.size(); i++) {
        PhoneNumber phoneNumber = phoneNumbers.get(i);
        phoneNumberDAO.create(newStudent.getContactInfo(), phoneNumber.getContactType(), phoneNumber.getDefaultNumber(), phoneNumber.getNumber());
    }
    return EntityFactoryVault.buildFromDomainObject(newStudent);
}
Also used : PhoneNumberDAO(fi.otavanopisto.pyramus.dao.base.PhoneNumberDAO) Email(fi.otavanopisto.pyramus.domainmodel.base.Email) StudyProgramme(fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme) Address(fi.otavanopisto.pyramus.domainmodel.base.Address) StudentStudyEndReason(fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason) StudentEducationalLevel(fi.otavanopisto.pyramus.domainmodel.students.StudentEducationalLevel) EmailDAO(fi.otavanopisto.pyramus.dao.base.EmailDAO) PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) School(fi.otavanopisto.pyramus.domainmodel.base.School) Language(fi.otavanopisto.pyramus.domainmodel.base.Language) AddressDAO(fi.otavanopisto.pyramus.dao.base.AddressDAO) Municipality(fi.otavanopisto.pyramus.domainmodel.base.Municipality) StudentExaminationType(fi.otavanopisto.pyramus.domainmodel.students.StudentExaminationType) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StudyProgrammeDAO(fi.otavanopisto.pyramus.dao.base.StudyProgrammeDAO) Date(java.util.Date) Nationality(fi.otavanopisto.pyramus.domainmodel.base.Nationality) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) ContactInfoDAO(fi.otavanopisto.pyramus.dao.base.ContactInfoDAO) StudentActivityType(fi.otavanopisto.pyramus.domainmodel.students.StudentActivityType) Curriculum(fi.otavanopisto.pyramus.domainmodel.base.Curriculum) PhoneNumber(fi.otavanopisto.pyramus.domainmodel.base.PhoneNumber) Person(fi.otavanopisto.pyramus.domainmodel.base.Person)

Example 24 with PersonDAO

use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.

the class StudentDAO method unarchive.

/**
 * Unarchives a student.
 *
 * @param student
 *          The student to be unarchived
 */
@Override
public void unarchive(ArchivableEntity entity, User modifier) {
    super.unarchive(entity, modifier);
    PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
    if (entity instanceof Student) {
        // This is necessary because Person entity does not really
        // change in this operation but it still needs to be reindexed
        Student student = (Student) entity;
        personDAO.forceReindex(student.getPerson());
        studentUpdatedEvent.fire(new StudentUpdatedEvent(student.getId()));
    }
}
Also used : PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) StudentUpdatedEvent(fi.otavanopisto.pyramus.events.StudentUpdatedEvent) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentGroupStudent(fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student)

Example 25 with PersonDAO

use of fi.otavanopisto.pyramus.dao.base.PersonDAO in project pyramus by otavanopisto.

the class StudentDAO method archive.

/**
 * Archives a student.
 *
 * @param student
 *          The student to be archived
 */
@Override
public void archive(ArchivableEntity entity, User modifier) {
    super.archive(entity, modifier);
    if (entity instanceof Student) {
        Student student = (Student) entity;
        CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
        PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
        // Also archive course students of the archived student
        List<CourseStudent> courseStudents = courseStudentDAO.listByStudent(student);
        if (!courseStudents.isEmpty()) {
            for (CourseStudent courseStudent : courseStudents) {
                courseStudentDAO.archive(courseStudent);
            }
        }
        // This is necessary because Person entity does not really
        // change in this operation but it still needs to be reindexed
        personDAO.forceReindex(student.getPerson());
        studentArchivedEvent.fire(new StudentArchivedEvent(student.getId()));
    }
}
Also used : PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) StudentArchivedEvent(fi.otavanopisto.pyramus.events.StudentArchivedEvent) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentGroupStudent(fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student)

Aggregations

PersonDAO (fi.otavanopisto.pyramus.dao.base.PersonDAO)47 Person (fi.otavanopisto.pyramus.domainmodel.base.Person)42 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)25 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)21 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)17 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)14 User (fi.otavanopisto.pyramus.domainmodel.users.User)14 HashMap (java.util.HashMap)12 EmailDAO (fi.otavanopisto.pyramus.dao.base.EmailDAO)11 ContactTypeDAO (fi.otavanopisto.pyramus.dao.base.ContactTypeDAO)10 UserVariableDAO (fi.otavanopisto.pyramus.dao.users.UserVariableDAO)10 ContactType (fi.otavanopisto.pyramus.domainmodel.base.ContactType)10 StudyProgramme (fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme)10 UserDAO (fi.otavanopisto.pyramus.dao.users.UserDAO)9 Language (fi.otavanopisto.pyramus.domainmodel.base.Language)9 Municipality (fi.otavanopisto.pyramus.domainmodel.base.Municipality)9 Nationality (fi.otavanopisto.pyramus.domainmodel.base.Nationality)9 School (fi.otavanopisto.pyramus.domainmodel.base.School)9 PhoneNumberDAO (fi.otavanopisto.pyramus.dao.base.PhoneNumberDAO)8 StudyProgrammeDAO (fi.otavanopisto.pyramus.dao.base.StudyProgrammeDAO)8