use of fi.otavanopisto.pyramus.domainmodel.base.EducationalLength 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.domainmodel.base.EducationalLength in project pyramus by otavanopisto.
the class CourseDAO method update.
/**
* Updates a course to the database.
*
* @param course The course to be updated
* @param organization Course organization
* @param name Course name
* @param subject Course subject
* @param courseNumber Course number
* @param beginDate Course begin date
* @param endDate Course end date
* @param courseLength Course length
* @param courseLengthTimeUnit Course length unit
* @param description Course description
* @param user The user making the update, stored as the last modifier of the course
*/
public void update(Course course, Organization organization, String name, String nameExtension, CourseState courseState, CourseType type, Subject subject, Integer courseNumber, Date beginDate, Date endDate, Double courseLength, EducationalTimeUnit courseLengthTimeUnit, Double distanceTeachingDays, Double localTeachingDays, Double teachingHours, Double distanceTeachingHours, Double planningHours, Double assessingHours, String description, Long maxParticipantCount, Date enrolmentTimeEnd, User user) {
EntityManager entityManager = getEntityManager();
Date now = new Date(System.currentTimeMillis());
EducationalLength educationalLength = course.getCourseLength();
if (educationalLength == null) {
educationalLength = new EducationalLength();
}
educationalLength.setUnit(courseLengthTimeUnit);
educationalLength.setUnits(courseLength);
course.setOrganization(organization);
course.setName(name);
course.setNameExtension(nameExtension);
course.setState(courseState);
course.setType(type);
course.setDescription(description);
course.setSubject(subject);
course.setCourseNumber(courseNumber);
course.setBeginDate(beginDate);
course.setEndDate(endDate);
course.setCourseLength(educationalLength);
course.setDistanceTeachingDays(distanceTeachingDays);
course.setLocalTeachingDays(localTeachingDays);
course.setTeachingHours(teachingHours);
course.setPlanningHours(planningHours);
course.setAssessingHours(assessingHours);
course.setMaxParticipantCount(maxParticipantCount);
course.setEnrolmentTimeEnd(enrolmentTimeEnd);
course.setLastModifier(user);
course.setLastModified(now);
course.setDistanceTeachingHours(distanceTeachingHours);
entityManager.persist(course);
courseUpdatedEvent.fire(new CourseUpdatedEvent(course.getId()));
}
use of fi.otavanopisto.pyramus.domainmodel.base.EducationalLength in project pyramus by otavanopisto.
the class ModuleDAO method create.
public Module create(String name, Subject subject, Integer courseNumber, Double moduleLength, EducationalTimeUnit moduleLengthTimeUnit, String description, Long maxParticipantCount, User creatingUser) {
EntityManager entityManager = getEntityManager();
Date now = new Date(System.currentTimeMillis());
EducationalLength educationalLength = new EducationalLength();
educationalLength.setUnit(moduleLengthTimeUnit);
educationalLength.setUnits(moduleLength);
Module module = new Module();
module.setName(name);
module.setDescription(description);
module.setSubject(subject);
module.setCourseNumber(courseNumber);
module.setCourseLength(educationalLength);
module.setMaxParticipantCount(maxParticipantCount);
module.setCreator(creatingUser);
module.setCreated(now);
module.setLastModifier(creatingUser);
module.setLastModified(now);
entityManager.persist(module);
return module;
}
use of fi.otavanopisto.pyramus.domainmodel.base.EducationalLength in project pyramus by otavanopisto.
the class TransferCreditDAO method create.
public TransferCredit create(String courseName, Integer courseNumber, Double courseLength, EducationalTimeUnit courseLengthUnit, School school, Subject subject, CourseOptionality optionality, Student student, StaffMember assessingUser, Grade grade, Date date, String verbalAssessment, Curriculum curriculum, boolean offCurriculum, TransferCreditFunding funding) {
TransferCredit transferCredit = new TransferCredit();
EducationalLength length = new EducationalLength();
length.setUnits(courseLength);
length.setUnit(courseLengthUnit);
transferCredit.setAssessor(assessingUser);
transferCredit.setDate(date);
transferCredit.setGrade(grade);
transferCredit.setCourseLength(length);
transferCredit.setCourseName(courseName);
transferCredit.setCourseNumber(courseNumber);
transferCredit.setSchool(school);
transferCredit.setStudent(student);
transferCredit.setSubject(subject);
transferCredit.setOptionality(optionality);
transferCredit.setVerbalAssessment(verbalAssessment);
transferCredit.setCurriculum(curriculum);
transferCredit.setOffCurriculum(offCurriculum);
transferCredit.setFunding(funding);
transferCredit.setArchived(Boolean.FALSE);
EntityManager entityManager = getEntityManager();
entityManager.persist(length);
entityManager.persist(transferCredit);
if (student != null)
transferCreditCreatedEvent.fire(new TransferCreditEvent(student.getId(), transferCredit.getId()));
return transferCredit;
}
use of fi.otavanopisto.pyramus.domainmodel.base.EducationalLength in project pyramus by otavanopisto.
the class ModuleDAO method update.
public Module update(Module module, String name, Subject subject, Integer courseNumber, Double length, EducationalTimeUnit lengthTimeUnit, String description, Long maxParticipantCount, User user) {
EntityManager entityManager = getEntityManager();
Date now = new Date(System.currentTimeMillis());
EducationalLength educationalLength = module.getCourseLength();
if (educationalLength == null) {
educationalLength = new EducationalLength();
}
educationalLength.setUnit(lengthTimeUnit);
educationalLength.setUnits(length);
module.setName(name);
module.setDescription(description);
module.setSubject(subject);
module.setCourseNumber(courseNumber);
module.setCourseLength(educationalLength);
module.setLastModifier(user);
module.setLastModified(now);
module.setMaxParticipantCount(maxParticipantCount);
entityManager.persist(module);
return module;
}
Aggregations