Search in sources :

Example 1 with CtrCandActionPjWindow

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);
}
Also used : PjPresentation(fr.univlorraine.ecandidat.utils.bean.presentation.PjPresentation) CtrCandActionPjWindow(fr.univlorraine.ecandidat.views.windows.CtrCandActionPjWindow) PjCand(fr.univlorraine.ecandidat.entities.ecandidat.PjCand) PjCandPK(fr.univlorraine.ecandidat.entities.ecandidat.PjCandPK) Candidature(fr.univlorraine.ecandidat.entities.ecandidat.Candidature) FormulaireCandidature(fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCandidature)

Aggregations

Candidature (fr.univlorraine.ecandidat.entities.ecandidat.Candidature)1 FormulaireCandidature (fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCandidature)1 PjCand (fr.univlorraine.ecandidat.entities.ecandidat.PjCand)1 PjCandPK (fr.univlorraine.ecandidat.entities.ecandidat.PjCandPK)1 PjPresentation (fr.univlorraine.ecandidat.utils.bean.presentation.PjPresentation)1 CtrCandActionPjWindow (fr.univlorraine.ecandidat.views.windows.CtrCandActionPjWindow)1