Search in sources :

Example 1 with PjCandidatPK

use of fr.univlorraine.ecandidat.entities.ecandidat.PjCandidatPK in project esup-ecandidat by EsupPortail.

the class CandidatPieceController method recordPjFromApo.

/**
 * Insere les nouvelles pièces
 * @param candidat
 * @throws SiScolException
 */
@Transactional(rollbackFor = SiScolException.class)
private void recordPjFromApo(final Candidat candidat) throws SiScolException {
    if (candidat == null || candidat.getCompteMinima().getSupannEtuIdCptMin() == null || !isWsPJEnable()) {
        return;
    }
    // on collecte les code Apogee de pieces et on constitue une liste de codeApogee distinct
    List<String> listeCodeApo = pieceJustifController.getAllPieceJustifs().stream().filter(piece -> piece.getCodApoPj() != null && !piece.getCodApoPj().equals("")).map(PieceJustif::getCodApoPj).distinct().collect(Collectors.toList());
    List<PjCandidat> liste = new ArrayList<>();
    // on ajoute ses nouvelles pieces
    for (String codeTpj : listeCodeApo) {
        WSPjInfo info = siScolService.getPjInfoFromApogee(null, candidat.getCompteMinima().getSupannEtuIdCptMin(), codeTpj);
        if (info != null) {
            PjCandidatPK pk = new PjCandidatPK(candidat.getIdCandidat(), info.getCodAnu(), info.getCodTpj());
            PjCandidat pjCandidat = new PjCandidat();
            pjCandidat.setId(pk);
            pjCandidat.setNomFicPjCandidat(info.getNomFic());
            pjCandidat.setCandidat(candidat);
            if (info.getDatExp() != null) {
                pjCandidat.setDatExpPjCandidat(LocalDateTime.parse(info.getDatExp(), formatterDateTimeApoWsPj));
            }
            if (MethodUtils.validateBean(pjCandidat, logger)) {
                liste.add(pjCandidatRepository.save(pjCandidat));
            } else {
                throw new SiScolException("Erreur de validation");
            }
        }
    }
    candidat.setPjCandidats(liste);
}
Also used : SiScolGenericService(fr.univlorraine.ecandidat.services.siscol.SiScolGenericService) PieceJustif(fr.univlorraine.ecandidat.entities.ecandidat.PieceJustif) LocalDateTime(java.time.LocalDateTime) LoggerFactory(org.slf4j.LoggerFactory) UI(com.vaadin.ui.UI) WSPjInfo(fr.univlorraine.ecandidat.entities.siscol.WSPjInfo) ArrayList(java.util.ArrayList) PjCandidatRepository(fr.univlorraine.ecandidat.repositories.PjCandidatRepository) PjCandidatPK(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidatPK) Notification(com.vaadin.ui.Notification) CandidatAdminListener(fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatAdminListener) CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) Logger(org.slf4j.Logger) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) Resource(javax.annotation.Resource) SiScolException(fr.univlorraine.ecandidat.services.siscol.SiScolException) Collectors(java.util.stream.Collectors) ApplicationContext(org.springframework.context.ApplicationContext) PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) List(java.util.List) Component(org.springframework.stereotype.Component) Type(com.vaadin.ui.Notification.Type) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) Candidat(fr.univlorraine.ecandidat.entities.ecandidat.Candidat) ConfirmWindow(fr.univlorraine.ecandidat.views.windows.ConfirmWindow) InputStream(java.io.InputStream) Transactional(org.springframework.transaction.annotation.Transactional) PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) WSPjInfo(fr.univlorraine.ecandidat.entities.siscol.WSPjInfo) ArrayList(java.util.ArrayList) PieceJustif(fr.univlorraine.ecandidat.entities.ecandidat.PieceJustif) SiScolException(fr.univlorraine.ecandidat.services.siscol.SiScolException) PjCandidatPK(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidatPK) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Notification (com.vaadin.ui.Notification)1 Type (com.vaadin.ui.Notification.Type)1 UI (com.vaadin.ui.UI)1 Candidat (fr.univlorraine.ecandidat.entities.ecandidat.Candidat)1 CompteMinima (fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima)1 PieceJustif (fr.univlorraine.ecandidat.entities.ecandidat.PieceJustif)1 PjCandidat (fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat)1 PjCandidatPK (fr.univlorraine.ecandidat.entities.ecandidat.PjCandidatPK)1 WSPjInfo (fr.univlorraine.ecandidat.entities.siscol.WSPjInfo)1 PjCandidatRepository (fr.univlorraine.ecandidat.repositories.PjCandidatRepository)1 SiScolException (fr.univlorraine.ecandidat.services.siscol.SiScolException)1 SiScolGenericService (fr.univlorraine.ecandidat.services.siscol.SiScolGenericService)1 ConstanteUtils (fr.univlorraine.ecandidat.utils.ConstanteUtils)1 CandidatAdminListener (fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatAdminListener)1 MethodUtils (fr.univlorraine.ecandidat.utils.MethodUtils)1 ConfirmWindow (fr.univlorraine.ecandidat.views.windows.ConfirmWindow)1 InputStream (java.io.InputStream)1 LocalDateTime (java.time.LocalDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ArrayList (java.util.ArrayList)1