use of fr.univlorraine.ecandidat.views.windows.CtrCandActionPjWindow in project esup-ecandidat by EsupPortail.
the class CandidaturePieceController method changeStatutPj.
/**
* Change le statut d'une liste de pj
* @param listePj
* @param candidature
* @param listener
*/
public void changeStatutPj(final List<PjPresentation> listePj, final Candidature candidature, final CandidatureListener listener) {
Assert.notNull(candidature, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
/* Verrou */
if (!lockCandidatController.getLockOrNotifyCandidature(candidature)) {
return;
}
final CtrCandActionPjWindow window = new CtrCandActionPjWindow(listePj);
window.addChangeStatutPieceWindowListener((t, c) -> {
/* Verrou */
if (!lockCandidatController.getLockOrNotifyCandidature(candidature)) {
return;
}
/* Verification de modif de piece */
for (final PjPresentation pj : listePj) {
if (isPjModified(pj, candidature, false, listener)) {
Notification.show(applicationContext.getMessage("pjs.modified", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
}
final String user = userController.getCurrentUserLogin();
listePj.forEach(e -> {
final PjCandPK pk = new PjCandPK(e.getPieceJustif().getIdPj(), e.getIdCandidature());
PjCand pjCand = pjCandRepository.findOne(pk);
if (pjCand == null) {
pjCand = new PjCand(pk, user, candidature, e.getPieceJustif());
}
pjCand.setTypeStatutPiece(t);
pjCand.setCommentPjCand(c);
pjCand.setUserModPjCand(user);
pjCand.setDatModStatutPjCand(LocalDateTime.now());
pjCand.setUserModStatutPjCand(user);
pjCandRepository.save(pjCand);
final PjCand pjCandSave = pjCandRepository.findOne(pk);
candidature.updatePjCand(pjCandSave);
if (pjCandSave.getTypeStatutPiece() != null) {
e.setLibStatut(i18nController.getI18nTraduction(pjCandSave.getTypeStatutPiece().getI18nLibTypStatutPiece()));
e.setCodStatut(pjCandSave.getTypeStatutPiece().getCodTypStatutPiece());
}
e.setCommentaire(c);
e.setDatModification(pjCandSave.getDatModPjCand());
e.setUserModStatut(getLibModStatut(pjCand.getUserModStatutPjCand(), pjCand.getDatModStatutPjCand()));
});
candidature.setUserModCand(user);
final Candidature candidatureSave = candidatureRepository.save(candidature);
listener.pjsModified(listePj, candidatureSave);
});
UI.getCurrent().addWindow(window);
}
Aggregations