}
private ActionForward getActionForwardForRegistration(ActionMapping mapping, HttpServletRequest request,
final Registration registration) {
final StudentCurricularPlan studentCurricularPlan = registration.getLastStudentCurricularPlan();
final ExecutionSemester executionSemester = ExecutionSemester.readActualExecutionSemester();
// ----------------------------------------------------------------------
// ---------------------------------------------
// TODO: refactor this code, should be more generic
// ----------------------------------------------------------------------
// ---------------------------------------------
if (!studentCurricularPlan.isActive() && !studentCurricularPlan.getRegistration().isConcluded()) {
request.setAttribute("registrationsToEnrol", Collections.singletonList(registration));
addActionMessage(request, "error.studentCurricularPlan.is.not.active.or.concluded");
return mapping.findForward("chooseRegistration");
}
if (studentCurricularPlan.getDegreeType() == DegreeType.BOLONHA_MASTER_DEGREE) {
request.setAttribute("registration", registration);
return mapping.findForward("proceedToEnrolment");
} else {
final CycleCurriculumGroup firstCycle = studentCurricularPlan.getFirstCycle();
if (firstCycle == null || !firstCycle.isConcluded()) {
request.setAttribute("registration", registration);
return mapping.findForward("proceedToEnrolment");
} else {
final CycleCurriculumGroup secondCycle = studentCurricularPlan.getSecondCycle();
if (secondCycle == null) {
return prepareSelectAffinityToEnrol(mapping, request, studentCurricularPlan, executionSemester);
} else if (secondCycle.isExternal()) {
final Student student = studentCurricularPlan.getRegistration().getStudent();
final Registration newRegistration =
student.getActiveRegistrationFor(secondCycle.getDegreeCurricularPlanOfDegreeModule());
if (newRegistration != null) {
request.setAttribute("registration", newRegistration);