@HandlesEvent("admitStudent")
public Resolution admitStudent() {
String message = EsimsConstants._BLANK_STRING;
Standard standardOfAdmission = this.standardService
.getById(this.standardId);
List<ReceivedApplicationForm> applicationForms = this.receivedApplicationFormService
.getByFormNumber(this.applicationFormNumber);
if ((applicationForms == null || applicationForms.size() == 0)) {
message = EsimsUtils
.createWarnMessage(this.getContext().getContextPath(),
"No details were found for the given Form #, please recheck");
return new StreamingResolution("text/html", new StringReader(
message.toString()));
} else {
StudentDetails studentDetails = EsimsUtils
.createStudentDetailsFromApplicationForm(applicationForms
.get(0));
Date dateOfAdmission = new Date();
Student studentToBeAdmitted = new Student(this.admissionNumber,
this.applicationFormNumber, standardOfAdmission,
dateOfAdmission, studentDetails);
if (this.studentService
.checkIfDuplicate(this.applicationFormNumber)) {
message = EsimsUtils.createInfoMessage(this.getContext()
.getContextPath(), "Form # "
+ studentToBeAdmitted.getApplicationFormNumber()
+ " already exists for another student");
} else {
this.studentService.save(studentToBeAdmitted);
message = EsimsUtils.createInfoMessage(this.getContext()
.getContextPath(), (studentToBeAdmitted
.getStudentDetails().getFirstName()
+ " has been admitted to " + standardOfAdmission
.getName()));
}
}
this.getContext().removeAttributeFromSession("listOfStandards");
FlashScope.getCurrent(this.getContext().getRequest(), true).put(