Search in sources :

Example 6 with Course

use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.

the class CoursesService method searchCourses.

public CourseEntitySearchResult searchCourses(@WebParam(name = "resultsPerPage") Integer resultsPerPage, @WebParam(name = "page") Integer page, @WebParam(name = "name") String name, @WebParam(name = "tags") String tags, @WebParam(name = "nameExtension") String nameExtension, @WebParam(name = "description") String description, @WebParam(name = "courseStateId") Long courseStateId, @WebParam(name = "subjectId") Long subjectId, @WebParam(name = "timeFilterMode") String timeFilterMode, @WebParam(name = "timeframeStart") Date timeframeStart, @WebParam(name = "timeframeEnd") Date timeframeEnd) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseStateDAO courseStateDAO = DAOFactory.getInstance().getCourseStateDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    CourseState courseState = courseStateId != null ? courseStateDAO.findById(courseStateId) : null;
    Subject subject = subjectId != null ? subjectDAO.findById(subjectId) : null;
    SearchTimeFilterMode tFilterMode = timeFilterMode != null ? SearchTimeFilterMode.valueOf(timeFilterMode) : null;
    SearchResult<Course> searchResult = courseDAO.searchCourses(resultsPerPage, page, name, tags, nameExtension, description, courseState, subject, tFilterMode, timeframeStart, timeframeEnd, true);
    return new CourseEntitySearchResult(searchResult.getPage(), searchResult.getPages(), searchResult.getTotalHitCount(), (CourseEntity[]) EntityFactoryVault.buildFromDomainObjects(searchResult.getResults()));
}
Also used : CourseStateDAO(fi.otavanopisto.pyramus.dao.courses.CourseStateDAO) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) SearchTimeFilterMode(fi.otavanopisto.pyramus.persistence.search.SearchTimeFilterMode) CourseEntitySearchResult(fi.pyramus.services.entities.courses.CourseEntitySearchResult) CourseState(fi.otavanopisto.pyramus.domainmodel.courses.CourseState) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) CourseEntity(fi.pyramus.services.entities.courses.CourseEntity)

Example 7 with Course

use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.

the class CoursesService method createCourse.

public CourseEntity createCourse(@WebParam(name = "moduleId") Long moduleId, @WebParam(name = "name") String name, @WebParam(name = "nameExtension") String nameExtension, @WebParam(name = "subjectId") Long subjectId, @WebParam(name = "courseNumber") Integer courseNumber, @WebParam(name = "beginDate") Date beginDate, @WebParam(name = "endDate") Date endDate, @WebParam(name = "courseLength") Double courseLength, @WebParam(name = "courseLengthTimeUnitId") Long courseLengthTimeUnitId, @WebParam(name = "description") String description, @WebParam(name = "creatingUserId") Long creatingUserId) {
    StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    ModuleDAO moduleDAO = DAOFactory.getInstance().getModuleDAO();
    CourseComponentDAO componentDAO = DAOFactory.getInstance().getCourseComponentDAO();
    CourseDescriptionDAO descriptionDAO = DAOFactory.getInstance().getCourseDescriptionDAO();
    CourseEducationTypeDAO educationTypeDAO = DAOFactory.getInstance().getCourseEducationTypeDAO();
    CourseEducationSubtypeDAO educationSubtypeDAO = DAOFactory.getInstance().getCourseEducationSubtypeDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
    Module module = moduleId == null ? null : moduleDAO.findById(moduleId);
    Subject subject = subjectId == null ? null : subjectDAO.findById(subjectId);
    EducationalTimeUnit courseLengthTimeUnit = courseLengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(courseLengthTimeUnitId);
    User creatingUser = userDAO.findById(creatingUserId);
    if (module != null) {
        name = name == null ? module.getName() : name;
        subject = subject == null ? module.getSubject() : subject;
        courseNumber = courseNumber == null ? module.getCourseNumber() : courseNumber;
        if (courseLength == null && module.getCourseLength() != null) {
            courseLength = module.getCourseLength().getUnits();
            courseLengthTimeUnit = module.getCourseLength().getUnit();
        }
        description = description == null ? module.getDescription() : description;
    }
    CourseState state = defaultsDAO.getDefaults().getInitialCourseState();
    CourseType type = null;
    // Course creation
    Course course = courseDAO.create(module, name, nameExtension, state, type, subject, courseNumber, beginDate, endDate, courseLength, courseLengthTimeUnit, null, null, null, null, null, null, description, null, null, null, null, creatingUser);
    validateEntity(course);
    if (module != null) {
        // Course Description copying from module to course
        descriptionDAO.copy(module, course);
        // Curriculums
        courseDAO.updateCurriculums(course, new HashSet<Curriculum>(module.getCurriculums()));
        // Components
        List<ModuleComponent> moduleComponents = module.getModuleComponents();
        if (moduleComponents != null) {
            for (ModuleComponent moduleComponent : moduleComponents) {
                EducationalLength educationalLength = moduleComponent.getLength();
                CourseComponent courseComponent = componentDAO.create(course, educationalLength == null ? null : educationalLength.getUnits(), educationalLength == null ? null : educationalLength.getUnit(), moduleComponent.getName(), moduleComponent.getDescription());
                validateEntity(courseComponent);
            }
        }
        // Education types
        List<CourseEducationType> typesInModule = module.getCourseEducationTypes();
        if (typesInModule != null) {
            for (CourseEducationType typeInModule : typesInModule) {
                CourseEducationType typeInCourse = educationTypeDAO.create(course, typeInModule.getEducationType());
                validateEntity(typeInCourse);
                // Education subtypes
                List<CourseEducationSubtype> subTypesInModule = typeInModule.getCourseEducationSubtypes();
                if (subTypesInModule != null) {
                    for (CourseEducationSubtype subtypeInModule : subTypesInModule) {
                        CourseEducationSubtype courseEducationSubtype = educationSubtypeDAO.create(typeInCourse, subtypeInModule.getEducationSubtype());
                        validateEntity(courseEducationSubtype);
                    }
                }
            }
        }
    }
    return EntityFactoryVault.buildFromDomainObject(course);
}
Also used : User(fi.otavanopisto.pyramus.domainmodel.users.User) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseDescriptionDAO(fi.otavanopisto.pyramus.dao.courses.CourseDescriptionDAO) ModuleDAO(fi.otavanopisto.pyramus.dao.modules.ModuleDAO) CourseComponent(fi.otavanopisto.pyramus.domainmodel.courses.CourseComponent) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) CourseState(fi.otavanopisto.pyramus.domainmodel.courses.CourseState) CourseType(fi.otavanopisto.pyramus.domainmodel.courses.CourseType) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) EducationalLength(fi.otavanopisto.pyramus.domainmodel.base.EducationalLength) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit) CourseEducationType(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationType) CourseComponentDAO(fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) CourseEducationSubtype(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationSubtype) CourseEducationTypeDAO(fi.otavanopisto.pyramus.dao.base.CourseEducationTypeDAO) DefaultsDAO(fi.otavanopisto.pyramus.dao.base.DefaultsDAO) CourseEducationSubtypeDAO(fi.otavanopisto.pyramus.dao.base.CourseEducationSubtypeDAO) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) ModuleComponent(fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent) Curriculum(fi.otavanopisto.pyramus.domainmodel.base.Curriculum) Module(fi.otavanopisto.pyramus.domainmodel.modules.Module)

Example 8 with Course

use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.

the class CoursesService method createCourseUser.

public CourseUserEntity createCourseUser(@WebParam(name = "courseId") Long courseId, @WebParam(name = "userId") Long userId, @WebParam(name = "courseUserRoleId") Long courseUserRoleId) {
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseStaffMemberDAO courseStaffMemberDAO = DAOFactory.getInstance().getCourseStaffMemberDAO();
    CourseStaffMemberRoleDAO courseStaffMemberRoleDAO = DAOFactory.getInstance().getCourseStaffMemberRoleDAO();
    Course course = courseDAO.findById(courseId);
    StaffMember staffMember = staffMemberDAO.findById(userId);
    CourseStaffMemberRole role = courseStaffMemberRoleDAO.findById(courseUserRoleId);
    CourseStaffMember courseUser = courseStaffMemberDAO.create(course, staffMember, role);
    validateEntity(courseUser);
    return EntityFactoryVault.buildFromDomainObject(courseUser);
}
Also used : CourseStaffMemberRole(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMemberRole) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStaffMember(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseStaffMember(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) CourseStaffMemberRoleDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberRoleDAO)

Example 9 with Course

use of fi.otavanopisto.pyramus.domainmodel.courses.Course 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 10 with Course

use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.

the class CoursesService method listCourseEducationTypes.

public CourseEducationTypeEntity[] listCourseEducationTypes(@WebParam(name = "courseId") Long courseId) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    Course course = courseDAO.findById(courseId);
    return (CourseEducationTypeEntity[]) EntityFactoryVault.buildFromDomainObjects(course.getCourseEducationTypes());
}
Also used : CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Aggregations

Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)111 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)50 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)44 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)44 Path (javax.ws.rs.Path)44 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)34 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)25 GET (javax.ws.rs.GET)23 Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)20 Date (java.util.Date)20 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)18 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)18 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)17 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)16 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)14 EntityManager (javax.persistence.EntityManager)14 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)13 CourseAssessmentRequest (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)13 StudentGroupStudent (fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent)13