Search in sources :

Example 1 with PjCandidat

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

the class CandidatAdminView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    isSiScolApo = parametreController.getSiScolMode().equals(ConstanteUtils.SI_SCOL_APOGEE);
    isSiScolApoPJ = parametreController.getSiScolMode().equals(ConstanteUtils.SI_SCOL_APOGEE) && candidatPieceController.isWsPJEnable();
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    globalLayout.setSizeFull();
    globalLayout.setSpacing(true);
    addComponent(globalLayout);
    addComponent(errorLabel);
    /* Titre */
    title.addStyleName(StyleConstants.VIEW_TITLE);
    globalLayout.addComponent(title);
    /* Lock */
    lockLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    lockLabel.setVisible(false);
    globalLayout.addComponent(lockLabel);
    /* Layout pour le compte */
    VerticalLayout cptMinLayout = new VerticalLayout();
    cptMinLayout.setSizeFull();
    cptMinLayout.setSpacing(true);
    /* Layout de controle */
    controlLayout.setWidth(100, Unit.PERCENTAGE);
    controlLayout.setSpacing(true);
    cptMinLayout.addComponent(controlLayout);
    /* Boutons candidat */
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    controlLayout.addComponent(buttonsLayout);
    controlLayout.setExpandRatio(buttonsLayout, 1);
    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.addClickListener(e -> {
        candidatController.editAdminCptMin(cptMin, this);
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);
    if (isSiScolApo) {
        Button btnSyncApogee = new Button(applicationContext.getMessage("btnSyncApo", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
        btnSyncApogee.setDisableOnClick(true);
        btnSyncApogee.addClickListener(e -> {
            candidatController.synchronizeCandidat(cptMin, this);
            btnSyncApogee.setEnabled(true);
        });
        buttonsLayout.addComponent(btnSyncApogee);
        buttonsLayout.setComponentAlignment(btnSyncApogee, Alignment.MIDDLE_CENTER);
    }
    OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
    btnDelete.addClickListener(e -> {
        candidatController.deleteCandidat(cptMin, this);
    });
    buttonsLayout.addComponent(btnDelete);
    buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);
    btnDeleteCnil.setCaption(applicationContext.getMessage("candidat.delete.cnil", null, UI.getCurrent().getLocale()));
    btnDeleteCnil.addClickListener(e -> {
        candidatController.deleteCandidatCnil(cptMin, this);
    });
    controlLayout.addComponent(btnDeleteCnil);
    controlLayout.setComponentAlignment(btnDeleteCnil, Alignment.MIDDLE_RIGHT);
    /* La table */
    table.addBooleanColumn(SimpleTablePresentation.CHAMPS_VALUE, false);
    table.setVisibleColumns((Object[]) FIELDS_ORDER);
    table.setColumnCollapsingAllowed(false);
    table.setColumnReorderingAllowed(false);
    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    table.setSelectable(false);
    table.setImmediate(true);
    table.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 250);
    table.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    cptMinLayout.addComponent(table);
    cptMinLayout.setExpandRatio(table, 1);
    table.setSizeFull();
    globalLayout.addComponent(cptMinLayout);
    globalLayout.setExpandRatio(cptMinLayout, 3);
    /* Les pièces */
    if (isSiScolApoPJ) {
        VerticalLayout pjLayout = new VerticalLayout();
        pjLayout.setSizeFull();
        pjLayout.setSpacing(true);
        /* Titre */
        titlePJ.addStyleName(StyleConstants.VIEW_TITLE);
        globalLayout.addComponent(titlePJ);
        /* Boutons candidat */
        buttonsLayoutPj.setWidth(100, Unit.PERCENTAGE);
        buttonsLayoutPj.setSpacing(true);
        pjLayout.addComponent(buttonsLayoutPj);
        Button btnSyncPjApogee = new Button(applicationContext.getMessage("candidat.admin.pj.btnSyncPjApo", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
        btnSyncPjApogee.setDisableOnClick(true);
        btnSyncPjApogee.addClickListener(e -> {
            candidatPieceController.adminSynchronizePJCandidat(cptMin, this);
            btnSyncPjApogee.setEnabled(true);
        });
        buttonsLayoutPj.addComponent(btnSyncPjApogee);
        buttonsLayoutPj.setComponentAlignment(btnSyncPjApogee, Alignment.MIDDLE_CENTER);
        containerPj.addNestedContainerProperty(PjCandidat_.id.getName() + "." + PjCandidatPK_.codAnuPjCandidat.getName());
        containerPj.addNestedContainerProperty(PjCandidat_.id.getName() + "." + PjCandidatPK_.codTpjPjCandidat.getName());
        for (String fieldName : FIELDS_ORDER_PJ) {
            tablePj.setColumnHeader(fieldName, applicationContext.getMessage("candidat.admin.pj.table." + fieldName, null, UI.getCurrent().getLocale()));
        }
        tablePj.addGeneratedColumn("file", new ColumnGenerator() {

            @Override
            public Object generateCell(final Table source, final Object itemId, final Object columnId) {
                final PjCandidat pjCandidat = (PjCandidat) itemId;
                if (pjCandidat != null && pjCandidat.getNomFicPjCandidat() != null && !pjCandidat.getNomFicPjCandidat().equals("")) {
                    String nomFichier = pjCandidat.getNomFicPjCandidat();
                    OnDemandFileLayout fileLayout = new OnDemandFileLayout(pjCandidat.getNomFicPjCandidat());
                    /* Viewer si JPG */
                    if (MethodUtils.isImgFileName(nomFichier)) {
                        fileLayout.addBtnViewerClickListener(e -> {
                            InputStream is = fileController.getInputStreamFromPjCandidat(pjCandidat);
                            if (is != null) {
                                ImageViewerWindow iv = new ImageViewerWindow(new OnDemandFile(nomFichier, is), null);
                                UI.getCurrent().addWindow(iv);
                            }
                        });
                    /* Opener si PDF */
                    } else if (MethodUtils.isPdfFileName(nomFichier)) {
                        fileLayout.addBtnViewerPdfBrowserOpener(new OnDemandStreamFile() {

                            @Override
                            public OnDemandFile getOnDemandFile() {
                                InputStream is = fileController.getInputStreamFromPjCandidat(pjCandidat);
                                return new OnDemandFile(nomFichier, is);
                            }
                        });
                    }
                    /* Bouton download */
                    fileLayout.addBtnDownloadFileDownloader(new OnDemandStreamFile() {

                        @Override
                        public OnDemandFile getOnDemandFile() {
                            InputStream is = fileController.getInputStreamFromPjCandidat(pjCandidat);
                            if (is != null) {
                                return new OnDemandFile(nomFichier, is);
                            }
                            return null;
                        }
                    });
                    return fileLayout;
                }
                return null;
            }
        });
        tablePj.setVisibleColumns((Object[]) FIELDS_ORDER_PJ);
        tablePj.setColumnCollapsingAllowed(true);
        tablePj.setColumnReorderingAllowed(true);
        tablePj.setSelectable(false);
        tablePj.setImmediate(true);
        globalLayout.addComponent(tablePj);
        globalLayout.setExpandRatio(tablePj, 1);
        pjLayout.addComponent(tablePj);
        pjLayout.setExpandRatio(tablePj, 1);
        tablePj.setSizeFull();
        globalLayout.addComponent(pjLayout);
        globalLayout.setExpandRatio(pjLayout, 2);
    }
}
Also used : PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) OnDemandFileLayout(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileLayout) FontAwesome(com.vaadin.server.FontAwesome) CandidatAdminListener(fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatAdminListener) CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) Label(com.vaadin.ui.Label) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) SpringView(com.vaadin.spring.annotation.SpringView) ValoTheme(com.vaadin.ui.themes.ValoTheme) CandidatPieceController(fr.univlorraine.ecandidat.controllers.CandidatPieceController) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) PjCandidat_(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat_) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) Resource(javax.annotation.Resource) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) FileController(fr.univlorraine.ecandidat.controllers.FileController) ApplicationContext(org.springframework.context.ApplicationContext) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) PjCandidatPK_(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidatPK_) ImageViewerWindow(fr.univlorraine.ecandidat.views.windows.ImageViewerWindow) ColumnHeaderMode(com.vaadin.ui.Table.ColumnHeaderMode) ParametreController(fr.univlorraine.ecandidat.controllers.ParametreController) PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) List(java.util.List) Button(com.vaadin.ui.Button) Table(com.vaadin.ui.Table) HorizontalLayout(com.vaadin.ui.HorizontalLayout) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) PostConstruct(javax.annotation.PostConstruct) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) UserController(fr.univlorraine.ecandidat.controllers.UserController) View(com.vaadin.navigator.View) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) InputStream(java.io.InputStream) CandidatController(fr.univlorraine.ecandidat.controllers.CandidatController) OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) Table(com.vaadin.ui.Table) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) InputStream(java.io.InputStream) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) ImageViewerWindow(fr.univlorraine.ecandidat.views.windows.ImageViewerWindow) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) Button(com.vaadin.ui.Button) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) VerticalLayout(com.vaadin.ui.VerticalLayout) OnDemandFileLayout(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileLayout) PostConstruct(javax.annotation.PostConstruct)

Example 2 with PjCandidat

use of fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat 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)

Example 3 with PjCandidat

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

the class CandidaturePieceController method getPjPresentation.

/**
 * @param  pj
 * @param  candidature
 * @param  statutAtt
 * @param  statutValide
 * @param  isDemat
 * @return              une piece de presentation
 */
private PjPresentation getPjPresentation(final PieceJustif pj, final Candidature candidature, final TypeStatutPiece statutAtt, final TypeStatutPiece statutValide, final Integer order, final Boolean isDemat) {
    final String libPj = i18nController.getI18nTraduction(pj.getI18nLibPj());
    final PjCand pjCand = getPjCandFromList(pj, candidature, isDemat);
    String libStatut = null;
    String codStatut = null;
    String commentaire = null;
    LocalDateTime datModification = null;
    Integer idCandidature = null;
    PjCandidat pjCandidatFromApogee = null;
    String userMod = null;
    Fichier fichier = null;
    if (pjCand != null) {
        fichier = pjCand.getFichier();
        if (pjCand.getTypeStatutPiece() != null) {
            libStatut = i18nController.getI18nTraduction(pjCand.getTypeStatutPiece().getI18nLibTypStatutPiece());
            codStatut = pjCand.getTypeStatutPiece().getCodTypStatutPiece();
        }
        commentaire = pjCand.getCommentPjCand();
        datModification = pjCand.getDatModPjCand();
        idCandidature = pjCand.getCandidature().getIdCand();
        userMod = getLibModStatut(pjCand.getUserModStatutPjCand(), pjCand.getDatModStatutPjCand());
    } else {
        if (isDemat) {
            pjCandidatFromApogee = candidatPieceController.getPjCandidat(pj.getCodApoPj(), candidature.getCandidat());
            if (pjCandidatFromApogee != null) {
                fichier = new Fichier();
                fichier.setFileFichier(pjCandidatFromApogee.getNomFicPjCandidat());
                fichier.setNomFichier(pjCandidatFromApogee.getNomFicPjCandidat());
                commentaire = applicationContext.getMessage("file.from.another.system", null, UI.getCurrent().getLocale());
                libStatut = i18nController.getI18nTraduction(statutValide.getI18nLibTypStatutPiece());
                codStatut = statutValide.getCodTypStatutPiece();
            } else {
                libStatut = i18nController.getI18nTraduction(statutAtt.getI18nLibTypStatutPiece());
                codStatut = statutAtt.getCodTypStatutPiece();
                idCandidature = candidature.getIdCand();
            }
        } else {
            libStatut = i18nController.getI18nTraduction(statutAtt.getI18nLibTypStatutPiece());
            codStatut = statutAtt.getCodTypStatutPiece();
            idCandidature = candidature.getIdCand();
        }
    }
    final Boolean commun = pj.getTemCommunPj() && !pj.getTemUnicitePj();
    return new PjPresentation(pj, libPj, fichier, codStatut, libStatut, commentaire, pj.getTemConditionnelPj(), commun, datModification, idCandidature, order, pjCandidatFromApogee, userMod);
}
Also used : LocalDateTime(java.time.LocalDateTime) PjCandidat(fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat) PjPresentation(fr.univlorraine.ecandidat.utils.bean.presentation.PjPresentation) PjCand(fr.univlorraine.ecandidat.entities.ecandidat.PjCand) Fichier(fr.univlorraine.ecandidat.entities.ecandidat.Fichier)

Aggregations

PjCandidat (fr.univlorraine.ecandidat.entities.ecandidat.PjCandidat)3 UI (com.vaadin.ui.UI)2 CompteMinima (fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima)2 ConstanteUtils (fr.univlorraine.ecandidat.utils.ConstanteUtils)2 CandidatAdminListener (fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatAdminListener)2 MethodUtils (fr.univlorraine.ecandidat.utils.MethodUtils)2 InputStream (java.io.InputStream)2 LocalDateTime (java.time.LocalDateTime)2 List (java.util.List)2 Resource (javax.annotation.Resource)2 ApplicationContext (org.springframework.context.ApplicationContext)2 BeanItemContainer (com.vaadin.data.util.BeanItemContainer)1 View (com.vaadin.navigator.View)1 ViewChangeEvent (com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)1 FontAwesome (com.vaadin.server.FontAwesome)1 SpringView (com.vaadin.spring.annotation.SpringView)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1