use of fr.univlorraine.ecandidat.utils.bean.export.ExportListCandidatureOption 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));
}
Aggregations