Search in sources :

Example 1 with CourseParticipationTypeDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.

the class CoursesService method listCourseParticipationTypes.

public CourseParticipationTypeEntity[] listCourseParticipationTypes() {
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    List<CourseParticipationType> courseParticipationTypes = participationTypeDAO.listUnarchived();
    Collections.sort(courseParticipationTypes, new Comparator<CourseParticipationType>() {

        public int compare(CourseParticipationType o1, CourseParticipationType o2) {
            return o1.getIndexColumn() == null ? -1 : o2.getIndexColumn() == null ? 1 : o1.getIndexColumn().compareTo(o2.getIndexColumn());
        }
    });
    return (CourseParticipationTypeEntity[]) EntityFactoryVault.buildFromDomainObjects(courseParticipationTypes);
}
Also used : CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)

Example 2 with CourseParticipationTypeDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.

the class CoursesService method addCourseStudent.

public CourseStudentEntity addCourseStudent(@WebParam(name = "courseId") Long courseId, @WebParam(name = "studentId") Long studentId, @WebParam(name = "courseEnrolmentTypeId") Long courseEnrolmentTypeId, @WebParam(name = "participationTypeId") Long participationTypeId, @WebParam(name = "enrolmentDate") Date enrolmentDate, @WebParam(name = "lodging") Boolean lodging, @WebParam(name = "optionality") String optionality) throws DuplicateCourseStudentException {
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    CourseEnrolmentTypeDAO enrolmentTypeDAO = DAOFactory.getInstance().getCourseEnrolmentTypeDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
    Defaults defaults = defaultsDAO.getDefaults();
    Course course = courseDAO.findById(courseId);
    Student student = studentDAO.findById(studentId);
    CourseEnrolmentType courseEnrolmentType = courseEnrolmentTypeId == null ? defaults.getInitialCourseEnrolmentType() : enrolmentTypeDAO.findById(courseEnrolmentTypeId);
    CourseParticipationType participationType = participationTypeId == null ? defaults.getInitialCourseParticipationType() : participationTypeDAO.findById(participationTypeId);
    CourseOptionality cOptionality = null;
    if (!StringUtils.isBlank(optionality))
        cOptionality = CourseOptionality.valueOf(optionality);
    Room room = null;
    BigDecimal lodgingFee = null;
    Currency lodgingFeeCurrency = null;
    BigDecimal reservationFee = null;
    Currency reservationFeeCurrency = null;
    String organization = null;
    String additionalInfo = null;
    CourseStudent courseStudent = courseStudentDAO.create(course, student, courseEnrolmentType, participationType, enrolmentDate, lodging, cOptionality, null, organization, additionalInfo, room, lodgingFee, lodgingFeeCurrency, reservationFee, reservationFeeCurrency, Boolean.FALSE);
    validateEntity(courseStudent);
    return EntityFactoryVault.buildFromDomainObject(courseStudent);
}
Also used : CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) CourseOptionality(fi.otavanopisto.pyramus.domainmodel.base.CourseOptionality) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseEnrolmentType(fi.otavanopisto.pyramus.domainmodel.courses.CourseEnrolmentType) DefaultsDAO(fi.otavanopisto.pyramus.dao.base.DefaultsDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) BigDecimal(java.math.BigDecimal) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) CourseEnrolmentTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseEnrolmentTypeDAO) Defaults(fi.otavanopisto.pyramus.domainmodel.base.Defaults) Currency(java.util.Currency) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType) Room(fi.otavanopisto.pyramus.domainmodel.accommodation.Room)

Example 3 with CourseParticipationTypeDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.

the class CourseParticipationTypesSetupWizardViewController method save.

@Override
public void save(PageRequestContext requestContext) throws SetupWizardException {
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
    CourseParticipationType initialCourseParticipationType = null;
    int rowCount = requestContext.getInteger("courseParticipationTypesTable.rowCount");
    for (int i = 0; i < rowCount; i++) {
        String colPrefix = "courseParticipationTypesTable." + i;
        Boolean initialType = "true".equals(requestContext.getString(colPrefix + ".initialType"));
        String name = requestContext.getString(colPrefix + ".name");
        CourseParticipationType courseParticipationType = participationTypeDAO.create(name);
        if (initialType) {
            if (initialCourseParticipationType != null) {
                throw new SetupWizardException("Two or more initial course participation types defined");
            }
            initialCourseParticipationType = courseParticipationType;
        }
    }
    if (initialCourseParticipationType != null) {
        defaultsDAO.updateInitialCourseParticipationType(initialCourseParticipationType);
    } else {
        throw new SetupWizardException("Initial course participation is not defined");
    }
}
Also used : CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) DefaultsDAO(fi.otavanopisto.pyramus.dao.base.DefaultsDAO) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)

Example 4 with CourseParticipationTypeDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.

the class ManageCourseAssessmentsViewController method process.

/**
 * Processes the page request by including the corresponding JSP page to the response.
 *
 * @param pageRequestContext Page request context
 */
public void process(PageRequestContext pageRequestContext) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
    CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
    Course course = courseDAO.findById(NumberUtils.createLong(pageRequestContext.getRequest().getParameter("course")));
    List<GradingScale> gradingScales = gradingScaleDAO.listUnarchived();
    List<CourseStudent> courseStudents = courseStudentDAO.listByCourse(course);
    Collections.sort(courseStudents, new Comparator<CourseStudent>() {

        @Override
        public int compare(CourseStudent o1, CourseStudent o2) {
            int cmp = o1.getStudent().getLastName().compareToIgnoreCase(o2.getStudent().getLastName());
            if (cmp == 0)
                cmp = o1.getStudent().getFirstName().compareToIgnoreCase(o2.getStudent().getFirstName());
            return cmp;
        }
    });
    Map<Long, CourseAssessment> courseAssessments = new HashMap<>();
    Map<Long, String> verbalAssessments = new HashMap<>();
    Iterator<CourseStudent> students = courseStudents.iterator();
    while (students.hasNext()) {
        CourseStudent courseStudent = students.next();
        CourseAssessment courseAssessment = courseAssessmentDAO.findLatestByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
        if (courseAssessment != null) {
            courseAssessments.put(courseStudent.getId(), courseAssessment);
            // Shortened descriptions
            String description = courseAssessment.getVerbalAssessment();
            if (description != null) {
                description = StringEscapeUtils.unescapeHtml(description.replaceAll("\\<.*?>", ""));
                description = description.replaceAll("\\n", "");
                verbalAssessments.put(courseAssessment.getId(), description);
            }
        }
    }
    List<CourseParticipationType> courseParticipationTypes = participationTypeDAO.listUnarchived();
    Collections.sort(courseParticipationTypes, new Comparator<CourseParticipationType>() {

        public int compare(CourseParticipationType o1, CourseParticipationType o2) {
            return o1.getIndexColumn() == null ? -1 : o2.getIndexColumn() == null ? 1 : o1.getIndexColumn().compareTo(o2.getIndexColumn());
        }
    });
    pageRequestContext.getRequest().setAttribute("course", course);
    pageRequestContext.getRequest().setAttribute("courseStudents", courseStudents);
    pageRequestContext.getRequest().setAttribute("courseParticipationTypes", courseParticipationTypes);
    pageRequestContext.getRequest().setAttribute("assessments", courseAssessments);
    pageRequestContext.getRequest().setAttribute("verbalAssessments", verbalAssessments);
    pageRequestContext.getRequest().setAttribute("gradingScales", gradingScales);
    pageRequestContext.setIncludeJSP("/templates/courses/managecourseassessments.jsp");
}
Also used : GradingScale(fi.otavanopisto.pyramus.domainmodel.grading.GradingScale) CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) GradingScaleDAO(fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO) HashMap(java.util.HashMap) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)

Example 5 with CourseParticipationTypeDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.

the class CoursesService method createCourseParticipationType.

public CourseParticipationTypeEntity createCourseParticipationType(@WebParam(name = "name") String name) {
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    CourseParticipationType courseParticipationType = participationTypeDAO.create(name);
    validateEntity(courseParticipationType);
    return EntityFactoryVault.buildFromDomainObject(courseParticipationType);
}
Also used : CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)

Aggregations

CourseParticipationTypeDAO (fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO)14 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)13 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)7 DefaultsDAO (fi.otavanopisto.pyramus.dao.base.DefaultsDAO)6 CourseEnrolmentTypeDAO (fi.otavanopisto.pyramus.dao.courses.CourseEnrolmentTypeDAO)6 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)6 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)5 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)5 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)5 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)5 Currency (java.util.Currency)5 HashMap (java.util.HashMap)5 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)4 CurriculumDAO (fi.otavanopisto.pyramus.dao.base.CurriculumDAO)4 EducationSubtypeDAO (fi.otavanopisto.pyramus.dao.base.EducationSubtypeDAO)4 EducationTypeDAO (fi.otavanopisto.pyramus.dao.base.EducationTypeDAO)4 EducationalTimeUnitDAO (fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO)4 OrganizationDAO (fi.otavanopisto.pyramus.dao.base.OrganizationDAO)4 SubjectDAO (fi.otavanopisto.pyramus.dao.base.SubjectDAO)4 CourseDescriptionCategoryDAO (fi.otavanopisto.pyramus.dao.courses.CourseDescriptionCategoryDAO)4