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));
}
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);
}
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);
}
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()));
}
}
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()));
}
}
Aggregations