ServiceSecurityHelper.hasAuthority(ProfileHelper.SPECIFIC_PROGRAMS_EDITION, getSession());
hasSpecificRights = true;
}
if (hasRights) {
Program program = (document.getId() == null ? new Program() : programDAO.find(document.getId()));
applyDiffProgram(program, document);
Program programWithId = programDAO.save(program);
UzerDTO user = (UzerDTO) getSession().getAttribute("user");
alertManagement.alert(user);
ProgramDTO programIdAndEnableGC4LaunchButton = new ProgramDTO();
programIdAndEnableGC4LaunchButton.setId(programWithId.getId());
if (isAdmin || (programWithId.getEcmManager() != null && programWithId.getEcmManager().getId() == user.getId())
|| (programWithId.getProgramManager() != null && programWithId.getProgramManager().getId() == user.getId())) {
programIdAndEnableGC4LaunchButton.enableGC4LaunchButton();
}
return programIdAndEnableGC4LaunchButton;
}
if (hasSpecificRights) {
UzerDTO user = (UzerDTO) getSession().getAttribute("user");
Set<ProgramDTO> specPrograms = new HashSet<ProgramDTO>();
specPrograms.addAll(user.getProgramsWithConsultationRights());
specPrograms.addAll(user.getProgramsWithEditionRights());
List<Long> programsId = new ArrayList<Long>();
for (ProgramDTO program : specPrograms) {
programsId.add(program.getId());
}
if (programsId.contains(document.getId())) {
Program program = programDAO.find(document.getId());
applyDiffProgram(program, document);
Program programWithId = programDAO.save(program);
// programDAO.getSessionFactory().getCurrentSession().flush();
alertManagement.alert(user);
ProgramDTO programIdAndEnableGC4LaunchButton = new ProgramDTO();
programIdAndEnableGC4LaunchButton.setId(programWithId.getId());
if (isAdmin || (programWithId.getEcmManager() != null && programWithId.getEcmManager().getId() == user.getId())
|| (programWithId.getProgramManager() != null && programWithId.getProgramManager().getId() == user.getId())) {
programIdAndEnableGC4LaunchButton.enableGC4LaunchButton();
}
return programIdAndEnableGC4LaunchButton;
}
}