Search in sources :

Example 1 with CandidatCursusPostBac

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

the class CandidatureCtrCandController method generateExport.

/**
 * Exporte les candidatures
 * @param  liste
 * @param  allOptions
 * @param  optionChecked
 * @return               le fichier
 */
private OnDemandFile generateExport(final String code, final String libelle, final List<Candidature> liste, final LinkedHashSet<ExportListCandidatureOption> allOptions, final Set<ExportListCandidatureOption> optionChecked, final Boolean temFooter) {
    if (liste == null || liste.size() == 0) {
        return null;
    }
    final Map<String, Object> beans = new HashMap<>();
    /* Traitement des dates */
    liste.forEach(candidature -> {
        candidature.setDatCreCandStr(candidature.getDatCreCand().format(formatterDateTime));
        candidature.getCandidat().setAdresseCandidatExport(generateAdresse(candidature.getCandidat().getAdresse()));
        candidature.getCandidat().setDatNaissanceCandidatStr(MethodUtils.formatDate(candidature.getCandidat().getDatNaissCandidat(), formatterDate));
        if (candidature.getLastTypeDecision() != null) {
            candidature.getLastTypeDecision().setDatValidTypeDecCandStr(MethodUtils.formatDate(candidature.getLastTypeDecision().getDatValidTypeDecCand(), formatterDate));
            candidature.getLastTypeDecision().setPreselectStr(getComplementPreselectMail(candidature.getLastTypeDecision()));
            candidature.getLastTypeDecision().setPreselectDateTypeDecCandStr(MethodUtils.formatDate(candidature.getLastTypeDecision().getPreselectDateTypeDecCand(), formatterDate));
        }
        candidature.setDatModTypStatutCandStr(MethodUtils.formatDate(candidature.getDatModTypStatutCand(), formatterDateTime));
        candidature.setDatReceptDossierCandStr(MethodUtils.formatDate(candidature.getDatReceptDossierCand(), formatterDate));
        candidature.setDatTransDossierCandStr(MethodUtils.formatDate(candidature.getDatTransDossierCand(), formatterDateTime));
        candidature.setDatCompletDossierCandStr(MethodUtils.formatDate(candidature.getDatCompletDossierCand(), formatterDate));
        candidature.setDatAnnulCandStr(MethodUtils.formatDate(candidature.getDatAnnulCand(), formatterDateTime));
        candidature.setDatNewConfirmCandStr(MethodUtils.formatDate(candidature.getDatNewConfirmCand(), formatterDate));
        candidature.setDatNewRetourCandStr(MethodUtils.formatDate(candidature.getDatNewRetourCand(), formatterDate));
        candidature.setDatIncompletDossierCandStr(MethodUtils.formatDate(candidature.getDatIncompletDossierCand(), formatterDate));
        candidature.setDatModPjForm(getDatModPjForm(candidature));
        /* Tags */
        candidature.setTagsStr(formatLongCellSize(candidature.getTags().stream().map(e -> e.getLibTag()).collect(Collectors.joining(" / "))));
        /* Bloc note */
        if (parametreController.getIsExportBlocNote()) {
            candidature.setBlocNoteStr(formatLongCellSize(getPostIt(candidature).stream().map(e -> e.getMessagePostIt()).collect(Collectors.joining(" / "))));
        } else {
            allOptions.add(new ExportListCandidatureOption("postItHide", applicationContext.getMessage("export.option.postit", null, UI.getCurrent().getLocale())));
        }
        /* Exoneration */
        if (candidature.getSiScolCatExoExt() != null) {
            candidature.setCatExoStr(candidature.getSiScolCatExoExt().getDisplayLibelle());
        }
        candidature.setMntChargeStr(MethodUtils.parseBigDecimalAsString(candidature.getMntChargeCand()));
        /* Opi */
        if (candidature.getOpi() != null) {
            candidature.setDatPassageOpiStr(MethodUtils.formatDate(candidature.getOpi().getDatPassageOpi(), formatterDateTime));
            candidature.setCodOpiStr(candidature.getOpi().getCodOpi());
        }
        /* Definition du dernier etablissement frequenté */
        final Candidat candidat = candidature.getCandidat();
        String lastEtab = "";
        String lastDiplome = "";
        String lastLibelleDiplome = "";
        Integer annee = 0;
        for (final CandidatCursusInterne cursus : candidat.getCandidatCursusInternes()) {
            if (cursus.getAnneeUnivCursusInterne() > annee) {
                annee = cursus.getAnneeUnivCursusInterne();
                lastEtab = applicationContext.getMessage("universite.title", null, UI.getCurrent().getLocale());
                lastDiplome = cursus.getLibCursusInterne();
            }
        }
        for (final CandidatCursusPostBac cursus : candidat.getCandidatCursusPostBacs()) {
            if (cursus.getAnneeUnivCursus() > annee && cursus.getSiScolEtablissement() != null) {
                annee = cursus.getAnneeUnivCursus();
                lastEtab = cursus.getSiScolEtablissement().getLibEtb();
                lastDiplome = cursus.getSiScolDipAutCur().getLibDac();
                lastLibelleDiplome = cursus.getLibCursus();
            }
        }
        candidat.setLastEtab(lastEtab);
        candidat.setLastDiplome(lastDiplome);
        candidat.setLastLibDiplome(lastLibelleDiplome);
    });
    if (code != null) {
        beans.put("code", code);
    }
    beans.put("candidatures", liste);
    allOptions.stream().forEach(exportOption -> {
        addExportOption(exportOption, optionChecked, beans);
    });
    if (temFooter) {
        beans.put("footer", applicationContext.getMessage("export.footer", new Object[] { libelle, liste.size(), formatterDateTime.format(LocalDateTime.now()) }, UI.getCurrent().getLocale()));
    } else {
        beans.put("footer", "");
    }
    final String libFile = applicationContext.getMessage("export.nom.fichier", new Object[] { libelle, DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss").format(LocalDateTime.now()) }, UI.getCurrent().getLocale());
    return exportController.generateXlsxExport(beans, "candidatures_template", libFile, Arrays.asList(0));
}
Also used : Arrays(java.util.Arrays) TypeStatut(fr.univlorraine.ecandidat.entities.ecandidat.TypeStatut) LoggerFactory(org.slf4j.LoggerFactory) UI(com.vaadin.ui.UI) ExportListCandidatureOption(fr.univlorraine.ecandidat.utils.bean.export.ExportListCandidatureOption) PdfAttachement(fr.univlorraine.ecandidat.utils.PdfAttachement) CentreCandidature(fr.univlorraine.ecandidat.entities.ecandidat.CentreCandidature) CompteMinima(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima) Map(java.util.Map) PostItRepository(fr.univlorraine.ecandidat.repositories.PostItRepository) Campagne(fr.univlorraine.ecandidat.entities.ecandidat.Campagne) CtrCandActionCandidatureWindow(fr.univlorraine.ecandidat.views.windows.CtrCandActionCandidatureWindow) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) Resource(javax.annotation.Resource) CandidatCursusPostBac(fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusPostBac) Set(java.util.Set) TypeDecisionCandidature(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature) Collectors(java.util.stream.Collectors) List(java.util.List) Type(com.vaadin.ui.Notification.Type) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) LocalDate(java.time.LocalDate) Optional(java.util.Optional) ExportListCandidatureAdresse(fr.univlorraine.ecandidat.utils.bean.export.ExportListCandidatureAdresse) DeleteAvisWindowListener(fr.univlorraine.ecandidat.views.windows.CtrCandShowHistoWindow.DeleteAvisWindowListener) Candidature(fr.univlorraine.ecandidat.entities.ecandidat.Candidature) FormulaireCandidat(fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCandidat) PjCand(fr.univlorraine.ecandidat.entities.ecandidat.PjCand) OpiRepository(fr.univlorraine.ecandidat.repositories.OpiRepository) TypeDecision(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision) AvisMailBean(fr.univlorraine.ecandidat.utils.bean.mail.AvisMailBean) MainUI(fr.univlorraine.ecandidat.MainUI) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PostIt(fr.univlorraine.ecandidat.entities.ecandidat.PostIt) NomenclatureUtils(fr.univlorraine.ecandidat.utils.NomenclatureUtils) Notification(com.vaadin.ui.Notification) FormulaireCand(fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCand) CtrCandShowHistoWindow(fr.univlorraine.ecandidat.views.windows.CtrCandShowHistoWindow) Adresse(fr.univlorraine.ecandidat.entities.ecandidat.Adresse) LinkedHashSet(java.util.LinkedHashSet) TypeDecisionCandidatureRepository(fr.univlorraine.ecandidat.repositories.TypeDecisionCandidatureRepository) CandidatureMasseListener(fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatureMasseListener) Logger(org.slf4j.Logger) TypeTraitement(fr.univlorraine.ecandidat.entities.ecandidat.TypeTraitement) Opi(fr.univlorraine.ecandidat.entities.ecandidat.Opi) Tag(fr.univlorraine.ecandidat.entities.ecandidat.Tag) ChangeCandidatureWindowListener(fr.univlorraine.ecandidat.views.windows.CtrCandActionCandidatureWindow.ChangeCandidatureWindowListener) ApplicationContext(org.springframework.context.ApplicationContext) DroitFonctionnalite(fr.univlorraine.ecandidat.entities.ecandidat.DroitFonctionnalite) Commission(fr.univlorraine.ecandidat.entities.ecandidat.Commission) CandidatCursusInterne(fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusInterne) Component(org.springframework.stereotype.Component) CandidatureListener(fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatureListener) DateTimeFormatter(java.time.format.DateTimeFormatter) CandidatureRepository(fr.univlorraine.ecandidat.repositories.CandidatureRepository) CtrCandPostItReadWindow(fr.univlorraine.ecandidat.views.windows.CtrCandPostItReadWindow) Candidat(fr.univlorraine.ecandidat.entities.ecandidat.Candidat) Formation(fr.univlorraine.ecandidat.entities.ecandidat.Formation) InputStream(java.io.InputStream) Assert(org.springframework.util.Assert) FormulaireCandidat(fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCandidat) Candidat(fr.univlorraine.ecandidat.entities.ecandidat.Candidat) ExportListCandidatureOption(fr.univlorraine.ecandidat.utils.bean.export.ExportListCandidatureOption) CandidatCursusInterne(fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusInterne) HashMap(java.util.HashMap) CandidatCursusPostBac(fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusPostBac)

Example 2 with CandidatCursusPostBac

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

the class CandidatParcoursController method editCursusPostBac.

/**
 * Edition d'un cursus
 */
public void editCursusPostBac(final Candidat candidat, CandidatCursusPostBac cursus, final CandidatCursusExterneListener listener) {
    /* Verrou --> normalement le lock est géré en amont mais on vérifie qd même */
    final String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_CURSUS_EXTERNE);
    if (lockError != null) {
        Notification.show(lockError, Type.ERROR_MESSAGE);
        return;
    }
    Boolean nouveau = false;
    if (cursus == null) {
        cursus = new CandidatCursusPostBac();
        cursus.setCandidat(candidat);
        nouveau = true;
    }
    final CandidatCursusExterneWindow window = new CandidatCursusExterneWindow(cursus, nouveau);
    window.addCursusPostBacWindowListener(e -> {
        candidat.addCursusPostBac(e);
        listener.cursusModified(candidat.getCandidatCursusPostBacs());
    });
    UI.getCurrent().addWindow(window);
}
Also used : CandidatCursusExterneWindow(fr.univlorraine.ecandidat.views.windows.CandidatCursusExterneWindow) CandidatCursusPostBac(fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusPostBac)

Example 3 with CandidatCursusPostBac

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

the class CandidatCursusExterneView method init.

/* Composants */
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    super.init();
    setNavigationButton((parametreController.getIsGetCursusInterne() ? CandidatCursusInterneView.NAME : CandidatBacView.NAME), CandidatStageView.NAME);
    String indication;
    if (parametreController.getIsGetCursusInterne()) {
        indication = applicationContext.getMessage("cursusexterne.indication", new Object[] { applicationContext.getMessage("universite.title", null, UI.getCurrent().getLocale()) }, UI.getCurrent().getLocale());
    } else {
        indication = applicationContext.getMessage("cursusexterne.indication.withoutCursusInterne", new Object[] { applicationContext.getMessage("universite.title", null, UI.getCurrent().getLocale()) }, UI.getCurrent().getLocale());
    }
    /*Indications pour le cursus*/
    setSubtitle(indication);
    OneClickButton btnNewPostBac = new OneClickButton(applicationContext.getMessage("cursusexterne.btn.new", null, UI.getCurrent().getLocale()), FontAwesome.PLUS);
    btnNewPostBac.addClickListener(e -> {
        candidatParcoursController.editCursusPostBac(candidat, null, this);
    });
    addGenericButton(btnNewPostBac, Alignment.MIDDLE_LEFT);
    OneClickButton btnEditPostBac = new OneClickButton(applicationContext.getMessage("btnModifier", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEditPostBac.setEnabled(false);
    btnEditPostBac.addClickListener(e -> {
        if (postBacTable.getValue() instanceof CandidatCursusPostBac) {
            candidatParcoursController.editCursusPostBac(candidat, (CandidatCursusPostBac) postBacTable.getValue(), this);
        }
    });
    addGenericButton(btnEditPostBac, Alignment.MIDDLE_CENTER);
    OneClickButton btnDeletePostBac = new OneClickButton(FontAwesome.TRASH_O);
    btnDeletePostBac.setEnabled(false);
    btnDeletePostBac.setCaption(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()));
    btnDeletePostBac.addClickListener(e -> {
        if (postBacTable.getValue() instanceof CandidatCursusPostBac) {
            candidatParcoursController.deleteCursusPostBac(candidat, (CandidatCursusPostBac) postBacTable.getValue(), this);
        }
    });
    addGenericButton(btnDeletePostBac, Alignment.MIDDLE_RIGHT);
    /*Table post Bac*/
    postBacContainer.addNestedContainerProperty(CandidatCursusPostBac_.siScolMention.getName() + "." + SiScolMention_.libMen.getName());
    postBacContainer.addNestedContainerProperty(CandidatCursusPostBac_.siScolEtablissement.getName() + "." + SiScolEtablissement_.libEtb.getName());
    postBacContainer.addNestedContainerProperty(CandidatCursusPostBac_.siScolPays.getName() + "." + SiScolPays_.libPay.getName());
    postBacContainer.addNestedContainerProperty(CandidatCursusPostBac_.siScolDepartement.getName() + "." + SiScolDepartement_.libDep.getName());
    postBacContainer.addNestedContainerProperty(CandidatCursusPostBac_.siScolCommune.getName() + "." + SiScolCommune_.libCom.getName());
    postBacContainer.addNestedContainerProperty(CandidatCursusPostBac_.siScolDipAutCur.getName() + "." + SiScolDipAutCur_.libDac.getName());
    postBacTable.setSizeFull();
    postBacTable.setVisibleColumns((Object[]) FIELDS_ORDER_POST_BAC);
    for (String fieldName : FIELDS_ORDER_POST_BAC) {
        postBacTable.setColumnHeader(fieldName, applicationContext.getMessage("cursusexterne." + fieldName, null, UI.getCurrent().getLocale()));
    }
    postBacTable.addGeneratedColumn(CandidatCursusPostBac_.obtenuCursus.getName(), new ColumnGenerator() {

        /**
         *serialVersionUID *
         */
        private static final long serialVersionUID = -6382571666110400875L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            CandidatCursusPostBac post = (CandidatCursusPostBac) itemId;
            return tableRefController.getLibelleObtenuCursusByCode(post.getObtenuCursus());
        }
    });
    postBacTable.setSortContainerPropertyId(CandidatCursusPostBac_.anneeUnivCursus.getName());
    postBacTable.setColumnCollapsingAllowed(true);
    postBacTable.setColumnReorderingAllowed(true);
    postBacTable.setSelectable(true);
    postBacTable.setImmediate(true);
    postBacTable.addItemSetChangeListener(e -> postBacTable.sanitizeSelection());
    postBacTable.addValueChangeListener(e -> {
        /* Les boutons d'édition et de suppression de CandidatCursusPostBac sont actifs seulement si une CandidatCursusPostBac est sélectionnée. */
        boolean postBacIsSelected = postBacTable.getValue() instanceof CandidatCursusPostBac;
        btnEditPostBac.setEnabled(postBacIsSelected);
        btnDeletePostBac.setEnabled(postBacIsSelected);
    });
    postBacTable.addItemClickListener(e -> {
        if (e.isDoubleClick() && !isLectureSeule && !isArchive) {
            postBacTable.select(e.getItemId());
            btnEditPostBac.click();
        }
    });
    addGenericComponent(postBacTable);
    setGenericExpandRatio(postBacTable);
}
Also used : Table(com.vaadin.ui.Table) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) CandidatCursusPostBac(fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusPostBac) PostConstruct(javax.annotation.PostConstruct)

Aggregations

CandidatCursusPostBac (fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusPostBac)3 Notification (com.vaadin.ui.Notification)1 Type (com.vaadin.ui.Notification.Type)1 Table (com.vaadin.ui.Table)1 ColumnGenerator (com.vaadin.ui.Table.ColumnGenerator)1 UI (com.vaadin.ui.UI)1 MainUI (fr.univlorraine.ecandidat.MainUI)1 Adresse (fr.univlorraine.ecandidat.entities.ecandidat.Adresse)1 Campagne (fr.univlorraine.ecandidat.entities.ecandidat.Campagne)1 Candidat (fr.univlorraine.ecandidat.entities.ecandidat.Candidat)1 CandidatCursusInterne (fr.univlorraine.ecandidat.entities.ecandidat.CandidatCursusInterne)1 Candidature (fr.univlorraine.ecandidat.entities.ecandidat.Candidature)1 CentreCandidature (fr.univlorraine.ecandidat.entities.ecandidat.CentreCandidature)1 Commission (fr.univlorraine.ecandidat.entities.ecandidat.Commission)1 CompteMinima (fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima)1 DroitFonctionnalite (fr.univlorraine.ecandidat.entities.ecandidat.DroitFonctionnalite)1 Formation (fr.univlorraine.ecandidat.entities.ecandidat.Formation)1 FormulaireCand (fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCand)1 FormulaireCandidat (fr.univlorraine.ecandidat.entities.ecandidat.FormulaireCandidat)1 Opi (fr.univlorraine.ecandidat.entities.ecandidat.Opi)1