if (RenderUtils.getViewState("person") != null) { // Postback
request.setAttribute("personBean", RenderUtils.getViewState("person").getMetaObject().getObject());
return mapping.findForward("fillNewPersonData");
}
ChoosePersonBean choosePersonBean =
(ChoosePersonBean) RenderUtils.getViewState("choosePerson").getMetaObject().getObject();
final String identificationNumber = choosePersonBean.getIdentificationNumber();
final YearMonthDay dateOfBirth = choosePersonBean.getDateOfBirth();
if (choosePersonBean.getPerson() == null) {
Collection<Person> persons = Person.findPersonByDocumentID(identificationNumber);
if (choosePersonBean.isFirstTimeSearch()) {
choosePersonBean.setFirstTimeSearch(false);
if (!persons.isEmpty()
|| !Person.findByDateOfBirth(dateOfBirth,
Person.findPersonMatchingFirstAndLastName(choosePersonBean.getName())).isEmpty()
|| (choosePersonBean.getStudentNumber() != null && Student.readStudentByNumber(choosePersonBean
.getStudentNumber()) != null)) {
// show similar persons
RenderUtils.invalidateViewState();
request.setAttribute("choosePersonBean", choosePersonBean);
return mapping.findForward("chooseNewStudentExecutionDegreeAndIdentification");
}
}
} else {
person = choosePersonBean.getPerson();
}
if (!checkIngression(request, executionDegreeBean, ingressionInformationBean, person, choosePersonBean)) {
return mapping.findForward("chooseNewStudentExecutionDegreeAndIdentification");
}
if (person != null) {
personBean = new PersonBean(person);
personBean.setStudentNumber(person.getStudent() != null ? person.getStudent().getNumber() : choosePersonBean
.getStudentNumber());
} else {
personBean =
new PersonBean(choosePersonBean.getName(), identificationNumber, choosePersonBean.getDocumentType(),
dateOfBirth, choosePersonBean.getStudentNumber());
}
request.setAttribute("personBean", personBean);
return mapping.findForward("fillNewPersonData");
}