use of fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason in project pyramus by otavanopisto.
the class StudentsService method createStudent.
public StudentEntity createStudent(@WebParam(name = "abstractStudentId") Long abstractStudentId, @WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName, @WebParam(name = "nickname") String nickname, @WebParam(name = "phone") String phone, @WebParam(name = "additionalInfo") String additionalInfo, @WebParam(name = "parentalInfo") String parentalInfo, @WebParam(name = "studyTimeEnd") Date studyTimeEnd, @WebParam(name = "activityTypeId") Long activityTypeId, @WebParam(name = "examinationTypeId") Long examinationTypeId, @WebParam(name = "educationalLevelId") Long educationalLevelId, @WebParam(name = "education") String education, @WebParam(name = "nationalityId") Long nationalityId, @WebParam(name = "municipalityId") Long municipalityId, @WebParam(name = "languageId") Long languageId, @WebParam(name = "schoolId") Long schoolId, @WebParam(name = "studyProgrammeId") Long studyProgrammeId, @WebParam(name = "previousStudies") Double previousStudies, @WebParam(name = "studyStartDate") Date studyStartDate, @WebParam(name = "studyEndDate") Date studyEndDate, @WebParam(name = "studyEndReasonId") Long studyEndReasonId, @WebParam(name = "studyEndText") String studyEndText, @WebParam(name = "lodging") Boolean lodging) {
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
StudentActivityTypeDAO activityTypeDAO = DAOFactory.getInstance().getStudentActivityTypeDAO();
StudentExaminationTypeDAO examinationTypeDAO = DAOFactory.getInstance().getStudentExaminationTypeDAO();
StudentEducationalLevelDAO educationalLevelDAO = DAOFactory.getInstance().getStudentEducationalLevelDAO();
StudentStudyEndReasonDAO studyEndReasonDAO = DAOFactory.getInstance().getStudentStudyEndReasonDAO();
LanguageDAO languageDAO = DAOFactory.getInstance().getLanguageDAO();
MunicipalityDAO municipalityDAO = DAOFactory.getInstance().getMunicipalityDAO();
NationalityDAO nationalityDAO = DAOFactory.getInstance().getNationalityDAO();
SchoolDAO schoolDAO = DAOFactory.getInstance().getSchoolDAO();
StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
ContactInfoDAO contactInfoDAO = DAOFactory.getInstance().getContactInfoDAO();
PhoneNumberDAO phoneNumberDAO = DAOFactory.getInstance().getPhoneNumberDAO();
ContactTypeDAO contactTypeDAO = DAOFactory.getInstance().getContactTypeDAO();
StudentLodgingPeriodDAO studentLodgingPeriodDAO = DAOFactory.getInstance().getStudentLodgingPeriodDAO();
Person person = personDAO.findById(abstractStudentId);
Nationality nationality = nationalityId == null ? null : nationalityDAO.findById(nationalityId);
Municipality municipality = municipalityId == null ? null : municipalityDAO.findById(municipalityId);
Language language = languageId == null ? null : languageDAO.findById(languageId);
StudentActivityType activityType = activityTypeId == null ? null : activityTypeDAO.findById(activityTypeId);
StudentExaminationType examinationType = examinationTypeId == null ? null : examinationTypeDAO.findById(examinationTypeId);
StudentEducationalLevel educationalLevel = educationalLevelId == null ? null : educationalLevelDAO.findById(educationalLevelId);
School school = schoolId == null ? null : schoolDAO.findById(schoolId);
StudyProgramme studyProgramme = studyProgrammeId == null ? null : studyProgrammeDAO.findById(studyProgrammeId);
StudentStudyEndReason studyEndReason = studyEndReasonId == null ? null : studyEndReasonDAO.findById(studyEndReasonId);
firstName = StringUtils.trim(firstName);
lastName = StringUtils.trim(lastName);
nickname = StringUtils.trim(nickname);
Student student = studentDAO.create(person, firstName, lastName, nickname, additionalInfo, studyTimeEnd, activityType, examinationType, educationalLevel, education, nationality, municipality, language, school, studyProgramme, null, previousStudies, studyStartDate, studyEndDate, studyEndReason, studyEndText, false);
if (lodging && studyStartDate != null)
studentLodgingPeriodDAO.create(student, studyStartDate, studyEndDate);
if (phone != null) {
ContactType contactType = contactTypeDAO.findById(new Long(1));
phoneNumberDAO.create(student.getContactInfo(), contactType, Boolean.TRUE, phone);
}
contactInfoDAO.update(student.getContactInfo(), parentalInfo);
// Default user
personDAO.updateDefaultUser(person, student);
validateEntity(student);
return EntityFactoryVault.buildFromDomainObject(student);
}
use of fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason in project pyramus by otavanopisto.
the class StudentsService method updateStudent.
public void updateStudent(@WebParam(name = "studentId") Long studentId, @WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName, @WebParam(name = "nickname") String nickname, @WebParam(name = "phone") String phone, @WebParam(name = "additionalInfo") String additionalInfo, @WebParam(name = "parentalInfo") String parentalInfo, @WebParam(name = "studyTimeEnd") Date studyTimeEnd, @WebParam(name = "activityTypeId") Long activityTypeId, @WebParam(name = "examinationTypeId") Long examinationTypeId, @WebParam(name = "educationalLevelId") Long educationalLevelId, @WebParam(name = "education") String education, @WebParam(name = "nationalityId") Long nationalityId, @WebParam(name = "municipalityId") Long municipalityId, @WebParam(name = "languageId") Long languageId, @WebParam(name = "schoolId") Long schoolId, @WebParam(name = "studyProgrammeId") Long studyProgrammeId, @WebParam(name = "previousStudies") Double previousStudies, @WebParam(name = "studyStartDate") Date studyStartDate, @WebParam(name = "studyEndDate") Date studyEndDate, @WebParam(name = "studyEndReasonId") Long studyEndReasonId, @WebParam(name = "studyEndText") String studyEndText, @WebParam(name = "lodging") Boolean lodging) {
// TODO Get rid of phone number and parental info
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
StudentActivityTypeDAO activityTypeDAO = DAOFactory.getInstance().getStudentActivityTypeDAO();
StudentExaminationTypeDAO examinationTypeDAO = DAOFactory.getInstance().getStudentExaminationTypeDAO();
StudentEducationalLevelDAO educationalLevelDAO = DAOFactory.getInstance().getStudentEducationalLevelDAO();
StudentStudyEndReasonDAO studyEndReasonDAO = DAOFactory.getInstance().getStudentStudyEndReasonDAO();
LanguageDAO languageDAO = DAOFactory.getInstance().getLanguageDAO();
MunicipalityDAO municipalityDAO = DAOFactory.getInstance().getMunicipalityDAO();
NationalityDAO nationalityDAO = DAOFactory.getInstance().getNationalityDAO();
SchoolDAO schoolDAO = DAOFactory.getInstance().getSchoolDAO();
StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
Student student = studentDAO.findById(studentId);
Nationality nationality = nationalityId == null ? null : nationalityDAO.findById(nationalityId);
Municipality municipality = municipalityId == null ? null : municipalityDAO.findById(municipalityId);
Language language = languageId == null ? null : languageDAO.findById(languageId);
StudentActivityType activityType = activityTypeId == null ? null : activityTypeDAO.findById(activityTypeId);
StudentExaminationType examinationType = activityTypeId == null ? null : examinationTypeDAO.findById(examinationTypeId);
StudentEducationalLevel educationalLevel = educationalLevelId == null ? null : educationalLevelDAO.findById(educationalLevelId);
School school = schoolId == null ? null : schoolDAO.findById(schoolId);
StudyProgramme studyProgramme = studyProgrammeId == null ? null : studyProgrammeDAO.findById(studyProgrammeId);
StudentStudyEndReason studyEndReason = studyEndReasonId == null ? null : studyEndReasonDAO.findById(studyEndReasonId);
Curriculum curriculum = student.getCurriculum();
firstName = StringUtils.trim(firstName);
lastName = StringUtils.trim(lastName);
nickname = StringUtils.trim(nickname);
// TODO lodging cannot be updated with a single boolean (remove parameter)
studentDAO.update(student, firstName, lastName, nickname, additionalInfo, studyTimeEnd, activityType, examinationType, educationalLevel, education, nationality, municipality, language, school, studyProgramme, curriculum, previousStudies, studyStartDate, studyEndDate, studyEndReason, studyEndText);
validateEntity(student);
}
use of fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason in project pyramus by otavanopisto.
the class StudentsService method endStudentStudies.
public void endStudentStudies(@WebParam(name = "studentId") Long studentId, @WebParam(name = "endDate") Date endDate, @WebParam(name = "endReasonId") Long endReasonId, @WebParam(name = "endReasonText") String endReasonText) {
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
StudentStudyEndReasonDAO endReasonDAO = DAOFactory.getInstance().getStudentStudyEndReasonDAO();
Student student = studentDAO.findById(studentId);
if (student != null) {
StudentStudyEndReason endReason = endReasonId == null ? null : endReasonDAO.findById(endReasonId);
studentDAO.endStudentStudies(student, endDate, endReason, endReasonText);
}
}
use of fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason in project pyramus by otavanopisto.
the class EditStudyEndReasonPropertiesDialogViewController method process.
public void process(PageRequestContext requestContext) {
StudentStudyEndReasonDAO studentStudyEndReasonDAO = DAOFactory.getInstance().getStudentStudyEndReasonDAO();
Long studyEndReasonId = requestContext.getLong("studyEndReasonId");
StudentStudyEndReason studyEndReason = studentStudyEndReasonDAO.findById(studyEndReasonId);
JSONArray propertiesJSON = new JSONArray();
for (EntityProperty prop : StudentStudyEndReasonProperties.listProperties()) {
String value = studyEndReason.getProperties().get(prop.getKey());
JSONObject propertyJSON = new JSONObject();
propertyJSON.put("type", prop.getType());
propertyJSON.put("name", Messages.getInstance().getText(requestContext.getRequest().getLocale(), prop.getLocaleKey()));
propertyJSON.put("key", prop.getKey());
propertyJSON.put("value", value != null ? value : "");
propertiesJSON.add(propertyJSON);
}
setJsDataVariable(requestContext, "properties", propertiesJSON.toString());
requestContext.getRequest().setAttribute("studyEndReason", studyEndReason);
requestContext.setIncludeJSP("/templates/settings/editstudyendreasonpropertiesdialog.jsp");
}
use of fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason in project pyramus by otavanopisto.
the class StudyEndReasonsViewController method process.
@Override
public void process(PageRequestContext pageRequestContext) {
StudentStudyEndReasonDAO studentStudyEndReasonDAO = DAOFactory.getInstance().getStudentStudyEndReasonDAO();
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
List<StudentStudyEndReason> studyEndReasons = studentStudyEndReasonDAO.listAll();
JSONArray jsonStudyEndReasons = new JSONArray();
JSONArray jsonReasonsInUse = new JSONArray();
for (StudentStudyEndReason reason : studyEndReasons) {
JSONObject jsonReason = new JSONObject();
jsonReason.put("id", reason.getId());
jsonReason.put("name", reason.getName());
if (reason.getParentReason() != null) {
jsonReason.put("parentId", reason.getParentReason().getId());
}
jsonStudyEndReasons.add(jsonReason);
}
for (StudentStudyEndReason reason : studyEndReasons) {
if (studentDAO.countByStudyEndReason(reason) > 0) {
JSONObject jsonReason = new JSONObject();
jsonReason.put("id", reason.getId());
jsonReasonsInUse.add(jsonReason);
}
}
this.setJsDataVariable(pageRequestContext, "studyEndReasons", jsonStudyEndReasons.toString());
this.setJsDataVariable(pageRequestContext, "reasonsInUse", jsonReasonsInUse.toString());
pageRequestContext.setIncludeJSP("/templates/settings/studyendreasons.jsp");
}
Aggregations