Search in sources :

Example 6 with Subject

use of fi.otavanopisto.pyramus.domainmodel.base.Subject 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 Subject

use of fi.otavanopisto.pyramus.domainmodel.base.Subject 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 Subject

use of fi.otavanopisto.pyramus.domainmodel.base.Subject in project pyramus by otavanopisto.

the class ModulesService method createModule.

public ModuleEntity createModule(@WebParam(name = "name") String name, @WebParam(name = "subjectId") Long subjectId, @WebParam(name = "courseNumber") Integer courseNumber, @WebParam(name = "moduleLength") Double moduleLength, @WebParam(name = "moduleLengthTimeUnitId") Long moduleLengthTimeUnitId, @WebParam(name = "description") String description, @WebParam(name = "creatingUserId") Long creatingUserId) {
    StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
    ModuleDAO moduleDAO = DAOFactory.getInstance().getModuleDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    Subject subject = subjectDAO.findById(subjectId);
    User creatingUser = userDAO.findById(creatingUserId);
    EducationalTimeUnit moduleLengthTimeUnit = moduleLengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(moduleLengthTimeUnitId);
    Module module = moduleDAO.create(name, subject, courseNumber, moduleLength, moduleLengthTimeUnit, description, null, creatingUser);
    validateEntity(module);
    return EntityFactoryVault.buildFromDomainObject(module);
}
Also used : StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) User(fi.otavanopisto.pyramus.domainmodel.users.User) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) ModuleDAO(fi.otavanopisto.pyramus.dao.modules.ModuleDAO) Module(fi.otavanopisto.pyramus.domainmodel.modules.Module) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)

Example 9 with Subject

use of fi.otavanopisto.pyramus.domainmodel.base.Subject in project pyramus by otavanopisto.

the class SubjectEntityFactory method buildFromDomainObject.

public SubjectEntity buildFromDomainObject(Object domainObject) {
    if (domainObject == null)
        return null;
    Subject subject = (Subject) domainObject;
    EducationTypeEntity educationTypeEntity = EntityFactoryVault.buildFromDomainObject(subject.getEducationType());
    return new SubjectEntity(subject.getId(), subject.getCode(), subject.getName(), educationTypeEntity, subject.getArchived());
}
Also used : Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject)

Example 10 with Subject

use of fi.otavanopisto.pyramus.domainmodel.base.Subject in project pyramus by otavanopisto.

the class StudentTORController method addTORCredit.

private static void addTORCredit(StudentTOR tor, Student student, Subject subject, Credit credit, Integer courseNumber, Set<Curriculum> creditCurriculums, Double courseLength, TORCourseLengthUnit courseLengthUnit, TORProblems problems) {
    if (credit.getGrade() == null) {
        return;
    }
    if (student.getCurriculum() != null) {
        Long studentCurriculumId = student.getCurriculum().getId();
        if (!creditCurriculums.isEmpty()) {
            boolean matchingCurriculum = creditCurriculums.stream().map(Curriculum::getId).anyMatch(studentCurriculumId::equals);
            // Both student and credit have curriculums set, but they didn't match -> skip the credit
            if (!matchingCurriculum) {
                return;
            }
        }
    }
    Long educationTypeId = subject.getEducationType() != null ? subject.getEducationType().getId() : null;
    fi.otavanopisto.pyramus.tor.Subject subjectModel = new fi.otavanopisto.pyramus.tor.Subject(subject.getId(), subject.getCode(), subject.getName(), educationTypeId, subject.getArchived());
    TORSubject torSubject = tor.findSubject(subject.getId());
    if (torSubject == null) {
        torSubject = TORSubject.from(subjectModel);
        tor.addSubject(torSubject);
        StudentSubjectGradeDAO studentSubjectGradeDAO = DAOFactory.getInstance().getStudentSubjectGradeDAO();
        StudentSubjectGrade studentSubjectGrade = studentSubjectGradeDAO.findBy(student, subject);
        if (studentSubjectGrade != null && studentSubjectGrade.getGrade() != null) {
            fi.otavanopisto.pyramus.domainmodel.grading.Grade grade = studentSubjectGrade.getGrade();
            Grade gradeModel = new Grade(grade.getId(), grade.getName(), grade.getDescription(), grade.getGradingScale().getId(), grade.getPassingGrade(), grade.getQualification(), grade.getGPA(), grade.getArchived());
            torSubject.setMeanGrade(gradeModel);
        }
    }
    TORCourse torCourse = torSubject.findCourse(courseNumber);
    if (torCourse == null) {
        torCourse = new TORCourse(subjectModel, courseNumber, courseLength, courseLengthUnit);
        torSubject.addCourse(torCourse);
    } else {
        if (torCourse.getLengthUnit() != courseLengthUnit) {
            problems.add(new TORProblem(TORProblemType.INCOMPATIBLE_LENGTHUNITS, String.format("%s%d", subjectModel.getCode(), courseNumber)));
        }
    }
    String gradeName = credit.getGrade().getName();
    Double gpa = credit.getGrade().getGPA();
    torCourse.addCredit(new TORCredit(credit.getGrade().getId(), gradeName, gpa, credit.getDate(), TORCreditType.COURSEASSESSMENT, credit.getGrade().getPassingGrade()));
}
Also used : StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) StudentSubjectGradeDAO(fi.otavanopisto.pyramus.dao.students.StudentSubjectGradeDAO) StudentSubjectGrade(fi.otavanopisto.pyramus.domainmodel.students.StudentSubjectGrade)

Aggregations

Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)62 SubjectDAO (fi.otavanopisto.pyramus.dao.base.SubjectDAO)38 EducationType (fi.otavanopisto.pyramus.domainmodel.base.EducationType)26 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)24 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)22 HashMap (java.util.HashMap)22 EducationTypeDAO (fi.otavanopisto.pyramus.dao.base.EducationTypeDAO)18 EducationalTimeUnitDAO (fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO)18 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)17 Module (fi.otavanopisto.pyramus.domainmodel.modules.Module)17 Date (java.util.Date)17 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)16 List (java.util.List)16 CurriculumDAO (fi.otavanopisto.pyramus.dao.base.CurriculumDAO)15 EducationSubtype (fi.otavanopisto.pyramus.domainmodel.base.EducationSubtype)15 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)15 HashSet (java.util.HashSet)15 ModuleDAO (fi.otavanopisto.pyramus.dao.modules.ModuleDAO)14 Map (java.util.Map)14 EducationSubtypeDAO (fi.otavanopisto.pyramus.dao.base.EducationSubtypeDAO)12