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