String originExecutionDegreeId = RequestUtils.getAndSetStringToRequest(request, "originExecutionDegreeId");
String curricularYearId = (String) dynaActionForm.get("curricularYearId");
String[] shiftIdsToTransfer = (String[]) dynaActionForm.get("shiftIdsToTransfer");
String[] curricularCourseIdsToTransfer = (String[]) dynaActionForm.get("curricularCourseIdsToTransfer");
ExecutionDegree originExecutionDegree = FenixFramework.getDomainObject(originExecutionDegreeId);
ExecutionCourse originExecutionCourse = FenixFramework.getDomainObject(executionCourseId);
String originExecutionDegreesString = originExecutionCourse.getDegreePresentationString();
String destinationExecutionCourseId = null;
try {
if (!StringUtils.isEmpty(destinationExecutionCourseIdString)
&& StringUtils.isNumeric(destinationExecutionCourseIdString)) {
destinationExecutionCourseId = destinationExecutionCourseIdString;
} else {
throw new DomainException("error.selection.noDestinationExecutionCourse");
}
ExecutionCourse destinationExecutionCourse =
SeperateExecutionCourse.run(executionCourseId, destinationExecutionCourseId, shiftIdsToTransfer,
curricularCourseIdsToTransfer);
String destinationExecutionCourseName = destinationExecutionCourse.getNameI18N().getContent();
if (StringUtils.isEmpty(destinationExecutionCourseName)) {
destinationExecutionCourseName = destinationExecutionCourse.getName();
}
String destinationExecutionCourseCode = destinationExecutionCourse.getSigla();
String destinationDegreeName = destinationExecutionCourse.getDegreePresentationString();
String transferedCurricularCourses = makeObjectStringFromArray(curricularCourseIdsToTransfer, CurricularCourse.class);
String transferedShifts;
String successKey;
if (shiftIdsToTransfer.length == 0) {
successKey = "message.manager.executionCourseManagement.transferCourse.success.many.noShifts";
transferedShifts = "";
} else {
successKey = "message.manager.executionCourseManagement.transferCourse.success.many";
transferedShifts = makeObjectStringFromArray(shiftIdsToTransfer, Shift.class);
}
addActionMessage("success", request, successKey, transferedCurricularCourses, transferedShifts,
destinationExecutionCourseName, destinationDegreeName, destinationExecutionCourseCode);
// check if degree context has changed
if (!originExecutionCourse.getExecutionDegrees().contains(originExecutionDegree)) {
// origin execution course degree has changed (no longer on original degree)
String originCourseName = originExecutionCourse.getNameI18N().getContent();
if (StringUtils.isEmpty(originCourseName)) {
originCourseName = originExecutionCourse.getName();
}
addActionMessage("info", request,
"message.manager.executionCourseManagement.transferCourse.success.switchContext", originCourseName,
originExecutionDegreesString, originExecutionCourse.getDegreePresentationString(),
destinationExecutionCourseName, destinationExecutionCourse.getDegreePresentationString(),
originExecutionDegree.getDegree().getSigla());
request.setAttribute("executionCourseId", destinationExecutionCourse.getExternalId().toString());
}
} catch (DomainException e) {
addActionMessage("error", request, e.getMessage(), e.getArgs());
if (request.getAttribute("destinationExecutionDegreeId") != null) {