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);
}
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));
}
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);
}
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);
}
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);
}
Aggregations