use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.
the class CoursesService method listCourseParticipationTypes.
public CourseParticipationTypeEntity[] listCourseParticipationTypes() {
CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
List<CourseParticipationType> courseParticipationTypes = participationTypeDAO.listUnarchived();
Collections.sort(courseParticipationTypes, new Comparator<CourseParticipationType>() {
public int compare(CourseParticipationType o1, CourseParticipationType o2) {
return o1.getIndexColumn() == null ? -1 : o2.getIndexColumn() == null ? 1 : o1.getIndexColumn().compareTo(o2.getIndexColumn());
}
});
return (CourseParticipationTypeEntity[]) EntityFactoryVault.buildFromDomainObjects(courseParticipationTypes);
}
use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.
the class CoursesService method addCourseStudent.
public CourseStudentEntity addCourseStudent(@WebParam(name = "courseId") Long courseId, @WebParam(name = "studentId") Long studentId, @WebParam(name = "courseEnrolmentTypeId") Long courseEnrolmentTypeId, @WebParam(name = "participationTypeId") Long participationTypeId, @WebParam(name = "enrolmentDate") Date enrolmentDate, @WebParam(name = "lodging") Boolean lodging, @WebParam(name = "optionality") String optionality) throws DuplicateCourseStudentException {
StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
CourseEnrolmentTypeDAO enrolmentTypeDAO = DAOFactory.getInstance().getCourseEnrolmentTypeDAO();
CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
Defaults defaults = defaultsDAO.getDefaults();
Course course = courseDAO.findById(courseId);
Student student = studentDAO.findById(studentId);
CourseEnrolmentType courseEnrolmentType = courseEnrolmentTypeId == null ? defaults.getInitialCourseEnrolmentType() : enrolmentTypeDAO.findById(courseEnrolmentTypeId);
CourseParticipationType participationType = participationTypeId == null ? defaults.getInitialCourseParticipationType() : participationTypeDAO.findById(participationTypeId);
CourseOptionality cOptionality = null;
if (!StringUtils.isBlank(optionality))
cOptionality = CourseOptionality.valueOf(optionality);
Room room = null;
BigDecimal lodgingFee = null;
Currency lodgingFeeCurrency = null;
BigDecimal reservationFee = null;
Currency reservationFeeCurrency = null;
String organization = null;
String additionalInfo = null;
CourseStudent courseStudent = courseStudentDAO.create(course, student, courseEnrolmentType, participationType, enrolmentDate, lodging, cOptionality, null, organization, additionalInfo, room, lodgingFee, lodgingFeeCurrency, reservationFee, reservationFeeCurrency, Boolean.FALSE);
validateEntity(courseStudent);
return EntityFactoryVault.buildFromDomainObject(courseStudent);
}
use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.
the class CourseParticipationTypesSetupWizardViewController method save.
@Override
public void save(PageRequestContext requestContext) throws SetupWizardException {
CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
CourseParticipationType initialCourseParticipationType = null;
int rowCount = requestContext.getInteger("courseParticipationTypesTable.rowCount");
for (int i = 0; i < rowCount; i++) {
String colPrefix = "courseParticipationTypesTable." + i;
Boolean initialType = "true".equals(requestContext.getString(colPrefix + ".initialType"));
String name = requestContext.getString(colPrefix + ".name");
CourseParticipationType courseParticipationType = participationTypeDAO.create(name);
if (initialType) {
if (initialCourseParticipationType != null) {
throw new SetupWizardException("Two or more initial course participation types defined");
}
initialCourseParticipationType = courseParticipationType;
}
}
if (initialCourseParticipationType != null) {
defaultsDAO.updateInitialCourseParticipationType(initialCourseParticipationType);
} else {
throw new SetupWizardException("Initial course participation is not defined");
}
}
use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.
the class ManageCourseAssessmentsViewController method process.
/**
* Processes the page request by including the corresponding JSP page to the response.
*
* @param pageRequestContext Page request context
*/
public void process(PageRequestContext pageRequestContext) {
CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
Course course = courseDAO.findById(NumberUtils.createLong(pageRequestContext.getRequest().getParameter("course")));
List<GradingScale> gradingScales = gradingScaleDAO.listUnarchived();
List<CourseStudent> courseStudents = courseStudentDAO.listByCourse(course);
Collections.sort(courseStudents, new Comparator<CourseStudent>() {
@Override
public int compare(CourseStudent o1, CourseStudent o2) {
int cmp = o1.getStudent().getLastName().compareToIgnoreCase(o2.getStudent().getLastName());
if (cmp == 0)
cmp = o1.getStudent().getFirstName().compareToIgnoreCase(o2.getStudent().getFirstName());
return cmp;
}
});
Map<Long, CourseAssessment> courseAssessments = new HashMap<>();
Map<Long, String> verbalAssessments = new HashMap<>();
Iterator<CourseStudent> students = courseStudents.iterator();
while (students.hasNext()) {
CourseStudent courseStudent = students.next();
CourseAssessment courseAssessment = courseAssessmentDAO.findLatestByCourseStudentAndArchived(courseStudent, Boolean.FALSE);
if (courseAssessment != null) {
courseAssessments.put(courseStudent.getId(), courseAssessment);
// Shortened descriptions
String description = courseAssessment.getVerbalAssessment();
if (description != null) {
description = StringEscapeUtils.unescapeHtml(description.replaceAll("\\<.*?>", ""));
description = description.replaceAll("\\n", "");
verbalAssessments.put(courseAssessment.getId(), description);
}
}
}
List<CourseParticipationType> courseParticipationTypes = participationTypeDAO.listUnarchived();
Collections.sort(courseParticipationTypes, new Comparator<CourseParticipationType>() {
public int compare(CourseParticipationType o1, CourseParticipationType o2) {
return o1.getIndexColumn() == null ? -1 : o2.getIndexColumn() == null ? 1 : o1.getIndexColumn().compareTo(o2.getIndexColumn());
}
});
pageRequestContext.getRequest().setAttribute("course", course);
pageRequestContext.getRequest().setAttribute("courseStudents", courseStudents);
pageRequestContext.getRequest().setAttribute("courseParticipationTypes", courseParticipationTypes);
pageRequestContext.getRequest().setAttribute("assessments", courseAssessments);
pageRequestContext.getRequest().setAttribute("verbalAssessments", verbalAssessments);
pageRequestContext.getRequest().setAttribute("gradingScales", gradingScales);
pageRequestContext.setIncludeJSP("/templates/courses/managecourseassessments.jsp");
}
use of fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO in project pyramus by otavanopisto.
the class CoursesService method createCourseParticipationType.
public CourseParticipationTypeEntity createCourseParticipationType(@WebParam(name = "name") String name) {
CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
CourseParticipationType courseParticipationType = participationTypeDAO.create(name);
validateEntity(courseParticipationType);
return EntityFactoryVault.buildFromDomainObject(courseParticipationType);
}
Aggregations