use of fi.otavanopisto.pyramus.events.CourseStudentCreatedEvent in project pyramus by otavanopisto.
the class CourseStudentDAO method create.
/**
* Adds a course student to the database.
*
* @param course The course
* @param student The student
* @param courseEnrolmentType Student enrolment type
* @param participationType Student participation type
* @param enrolmentDate The enrolment date
* @param optionality
* @param billingDetails
* @param archived
* @param room
*
* @return The created course student
* @throws DuplicateCourseStudentException
*/
public CourseStudent create(Course course, Student student, CourseEnrolmentType courseEnrolmentType, CourseParticipationType participationType, Date enrolmentDate, Boolean lodging, CourseOptionality optionality, BillingDetails billingDetails, String organization, String additionalInfo, Room room, BigDecimal lodgingFee, Currency lodgingFeeCurrency, BigDecimal reservationFee, Currency reservationFeeCurrency, Boolean archived) throws DuplicateCourseStudentException {
List<CourseStudent> courseStudents = listByCourseAndStudent(course, student);
if (!courseStudents.isEmpty())
throw new DuplicateCourseStudentException();
CourseStudent courseStudent = new CourseStudent();
courseStudent.setCourse(course);
courseStudent.setArchived(archived);
courseStudent.setBillingDetails(billingDetails);
courseStudent.setCourseEnrolmentType(courseEnrolmentType);
courseStudent.setEnrolmentTime(enrolmentDate);
courseStudent.setParticipationType(participationType);
courseStudent.setLodging(lodging);
courseStudent.setOptionality(optionality);
courseStudent.setStudent(student);
courseStudent.setRoom(room);
courseStudent.setLodgingFee(lodgingFee);
courseStudent.setLodgingFeeCurrency(lodgingFeeCurrency);
courseStudent.setReservationFee(reservationFee);
courseStudent.setReservationFeeCurrency(reservationFeeCurrency);
courseStudent.setOrganization(organization);
courseStudent.setAdditionalInfo(additionalInfo);
persist(courseStudent);
courseStudentCreatedEvent.fire(new CourseStudentCreatedEvent(courseStudent.getId(), courseStudent.getCourse().getId(), courseStudent.getStudent().getId()));
return courseStudent;
}
Aggregations