String executionCourseId = RequestUtils.getAndSetStringToRequest(request, "executionCourseId");
String originExecutionDegreeId = RequestUtils.getAndSetStringToRequest(request, "originExecutionDegreeId");
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();
try {
ExecutionCourse destinationExecutionCourse =
SeperateExecutionCourse.run(executionCourseId, null, 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.separate.success.create.noShifts";
transferedShifts = "";
} else {
successKey = "message.manager.executionCourseManagement.separate.success.create";
transferedShifts = makeObjectStringFromArray(shiftIdsToTransfer, Shift.class);
}
addActionMessage("success", request, successKey, destinationExecutionCourseName, destinationDegreeName,
destinationExecutionCourseCode, transferedCurricularCourses, transferedShifts);
// 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.separate.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());