use of fi.otavanopisto.pyramus.dao.courses.CourseDAO in project pyramus by otavanopisto.
the class CoursesService method listCourseDescriptionsByCourseId.
public CourseDescriptionEntity[] listCourseDescriptionsByCourseId(@WebParam(name = "courseId") Long courseId) {
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
CourseBase courseBase = courseDAO.findById(courseId);
CourseDescriptionDAO descriptionDAO = DAOFactory.getInstance().getCourseDescriptionDAO();
return (CourseDescriptionEntity[]) EntityFactoryVault.buildFromDomainObjects(descriptionDAO.listByCourseBase(courseBase));
}
use of fi.otavanopisto.pyramus.dao.courses.CourseDAO in project pyramus by otavanopisto.
the class CoursesService method archiveCourse.
public void archiveCourse(@WebParam(name = "courseId") Long courseId) {
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
courseDAO.archive(courseDAO.findById(courseId));
}
use of fi.otavanopisto.pyramus.dao.courses.CourseDAO in project pyramus by otavanopisto.
the class CoursesService method listCourseComponents.
public CourseComponentEntity[] listCourseComponents(@WebParam(name = "courseId") Long courseId) {
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
CourseComponentDAO componentDAO = DAOFactory.getInstance().getCourseComponentDAO();
return (CourseComponentEntity[]) EntityFactoryVault.buildFromDomainObjects(componentDAO.listByCourse(courseDAO.findById(courseId)));
}
use of fi.otavanopisto.pyramus.dao.courses.CourseDAO 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);
}
use of fi.otavanopisto.pyramus.dao.courses.CourseDAO in project pyramus by otavanopisto.
the class CoursesService method setCourseVariable.
public void setCourseVariable(@WebParam(name = "courseId") Long courseId, @WebParam(name = "key") String key, @WebParam(name = "value") String value) {
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
CourseBaseVariableDAO variableDAO = DAOFactory.getInstance().getCourseBaseVariableDAO();
variableDAO.setCourseVariable(courseDAO.findById(courseId), key, value);
}
Aggregations