Search in sources :

Example 21 with CourseDAO

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

the class CourseAPI method getVariable.

public String getVariable(Long courseId, String key) throws InvalidScriptException {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseBaseVariableDAO courseBaseVariableDAO = DAOFactory.getInstance().getCourseBaseVariableDAO();
    Course course = courseDAO.findById(courseId);
    if (course == null) {
        throw new InvalidScriptException(String.format("Course #%d could not be found", courseId));
    }
    return courseBaseVariableDAO.findByCourseAndVariableKey(course, key);
}
Also used : InvalidScriptException(fi.otavanopisto.pyramus.util.dataimport.scripting.InvalidScriptException) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseBaseVariableDAO(fi.otavanopisto.pyramus.dao.base.CourseBaseVariableDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Example 22 with CourseDAO

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

the class CoursesService method listCourseStudentsByCourse.

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

Example 23 with CourseDAO

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

the class CoursesService method updateCourse.

public void updateCourse(@WebParam(name = "courseId") Long courseId, @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 = "modifyingUserId") Long modifyingUserId) {
    StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    Course course = courseDAO.findById(courseId);
    Subject subject = subjectId == null ? null : subjectDAO.findById(subjectId);
    EducationalTimeUnit courseLengthTimeUnit = courseLengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(courseLengthTimeUnitId);
    User modifyingUser = userDAO.findById(modifyingUserId);
    courseDAO.update(course, name, nameExtension, course.getState(), course.getType(), subject, courseNumber, beginDate, endDate, courseLength, courseLengthTimeUnit, course.getDistanceTeachingDays(), course.getLocalTeachingDays(), course.getTeachingHours(), course.getDistanceTeachingHours(), course.getPlanningHours(), course.getAssessingHours(), description, course.getMaxParticipantCount(), course.getEnrolmentTimeEnd(), modifyingUser);
    validateEntity(course);
}
Also used : StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) User(fi.otavanopisto.pyramus.domainmodel.users.User) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)

Example 24 with CourseDAO

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

the class CoursesService method unarchiveCourseStudent.

public void unarchiveCourseStudent(@WebParam(name = "courseId") Long courseId, @WebParam(name = "studentId") Long studentId) {
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    Course course = courseDAO.findById(courseId);
    Student student = studentDAO.findById(studentId);
    CourseStudent courseStudent = courseStudentDAO.findByCourseAndStudent(course, student);
    courseDAO.unarchive(courseStudent);
}
Also used : CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student)

Example 25 with CourseDAO

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

the class CoursesService method createCourseComponent.

public CourseComponentEntity createCourseComponent(@WebParam(name = "courseId") Long courseId, @WebParam(name = "componentLength") Double componentLength, @WebParam(name = "componentLengthTimeUnitId") Long componentLengthTimeUnitId, @WebParam(name = "name") String name, @WebParam(name = "description") String description) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    CourseComponentDAO componentDAO = DAOFactory.getInstance().getCourseComponentDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    Course course = courseDAO.findById(courseId);
    EducationalTimeUnit componentLengthTimeUnit = componentLengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(componentLengthTimeUnitId);
    CourseComponent courseComponent = componentDAO.create(course, componentLength, componentLengthTimeUnit, name, description);
    validateEntity(courseComponent);
    return EntityFactoryVault.buildFromDomainObject(courseComponent);
}
Also used : CourseComponentDAO(fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseComponent(fi.otavanopisto.pyramus.domainmodel.courses.CourseComponent) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)

Aggregations

CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)43 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)32 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)16 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)12 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)12 SubjectDAO (fi.otavanopisto.pyramus.dao.base.SubjectDAO)9 CourseDescriptionDAO (fi.otavanopisto.pyramus.dao.courses.CourseDescriptionDAO)9 ModuleDAO (fi.otavanopisto.pyramus.dao.modules.ModuleDAO)9 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)9 Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)9 HashMap (java.util.HashMap)9 EducationalTimeUnitDAO (fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO)8 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)8 Module (fi.otavanopisto.pyramus.domainmodel.modules.Module)8 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)8 Date (java.util.Date)8 EducationTypeDAO (fi.otavanopisto.pyramus.dao.base.EducationTypeDAO)7 CourseComponentDAO (fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO)7 CourseStaffMemberDAO (fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO)7 EducationType (fi.otavanopisto.pyramus.domainmodel.base.EducationType)7