use of fr.univlorraine.ecandidat.entities.ecandidat.Opi 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));
}
use of fr.univlorraine.ecandidat.entities.ecandidat.Opi in project esup-ecandidat by EsupPortail.
the class OpiController method traiteListOpiCandidat.
/**
* Traite la liste des OPI
* @param candidat
* @param listeOpi
* @param isCodOpiIntEpoFromEcandidat
* @param codOpiIntEpo
*/
public void traiteListOpiCandidat(final Candidat candidat, final List<Opi> listeOpi, final Boolean isCodOpiIntEpoFromEcandidat, final String codOpiIntEpo, final String logComp) {
logger.debug("traiteListOpiCandidat " + codOpiIntEpo + " fromEcv2 = " + isCodOpiIntEpoFromEcandidat + logComp + " - " + listeOpi.size() + " opi");
String libFormation = "";
for (final Opi opi : listeOpi) {
/* On enregistre la date de passage */
opi.setDatPassageOpi(LocalDateTime.now());
opi.setCodOpi(codOpiIntEpo);
opiRepository.save(opi);
if (!isCodOpiIntEpoFromEcandidat) {
libFormation = libFormation + "<li>" + opi.getCandidature().getFormation().getLibForm() + "</li>";
}
}
/* Si le code OPI est different de celui de eCandidat, on envoi un mail au
* candidat */
if (!isCodOpiIntEpoFromEcandidat && libFormation != null && !libFormation.equals("")) {
logger.debug("Envoi du mail de modification" + logComp);
sendMailChangeCodeOpi(candidat, codOpiIntEpo, "<ul>" + libFormation + "</ul>");
}
}
use of fr.univlorraine.ecandidat.entities.ecandidat.Opi in project esup-ecandidat by EsupPortail.
the class SiScolApogeeWSServiceImpl method creerOpiViaWS.
/* (non-Javadoc)
*
* @see
* fr.univlorraine.ecandidat.services.siscol.SiScolGenericService#creerOpiViaWS(
* fr.univlorraine.ecandidat.entities.ecandidat.Candidat) */
@Override
public void creerOpiViaWS(final Candidat candidat, final Boolean isBatch) {
/* Erreur à afficher dans les logs */
final String logComp = " - candidat " + candidat.getCompteMinima().getNumDossierOpiCptMin();
/* Instanciation du service */
if (opiService == null) {
try {
opiService = ServiceProvider.getService(OpiMetierServiceInterface.class);
} catch (final Exception e) {
logger.error("Erreur OPI : Probleme d'insertion des voeux dans Apogée" + logComp, e);
// Affichage message dans l'interface
return;
}
}
logger.debug("creerOpiViaWS" + logComp);
// Test que l'année d'obtention du bac est correcte.
final CandidatBacOuEqu bacOuEqu = candidat.getCandidatBacOuEqu();
if (bacOuEqu != null && bacOuEqu.getAnneeObtBac() != null) {
final int anneeObtBac = candidat.getCandidatBacOuEqu().getAnneeObtBac();
final int anneeEnCours = (LocalDate.now()).getYear();
if (anneeObtBac > anneeEnCours) {
mailController.sendErrorToAdminFonctionnel("Erreur OPI, bac non conforme" + logComp, "Erreur OPI : bac non conforme, la date est supérieur à l'année courante" + logComp, logger);
logger.debug("bac non conforme" + logComp);
return;
}
}
// Donnees de l'individu
final String codOpiIntEpo = parametreController.getPrefixeOPI() + candidat.getCompteMinima().getNumDossierOpiCptMin();
// Voeux-->On cherche tout les voeuyx soumis à OPI-->Recherche des OPI du
// candidat
final List<Opi> listeOpi = opiController.getListOpiByCandidat(candidat, isBatch);
final List<MAJOpiVoeuDTO3> listeMAJOpiVoeuDTO = new ArrayList<>();
/* Au moins 1 opi n'est pas passé pour lancer l'opi */
Boolean opiToPass = false;
for (final Opi opi : listeOpi) {
final MAJOpiVoeuDTO3 mAJOpiVoeuDTO = getVoeuByCandidature(opi.getCandidature());
if (opi.getDatPassageOpi() == null) {
opiToPass = true;
}
if (mAJOpiVoeuDTO != null) {
listeMAJOpiVoeuDTO.add(mAJOpiVoeuDTO);
}
}
/* Au moins 1 opi n'est pas passé pour lancer l'opi */
if (!opiToPass) {
logger.debug("aucun OPI a passer" + logComp);
return;
}
/* Creation des objets DTO */
final DonneesOpiDTO10 donneesOPI = new DonneesOpiDTO10();
final MAJOpiIndDTO6 individu = new MAJOpiIndDTO6();
final MAJEtatCivilDTO2 etatCivil = getEtatCivil(candidat);
final MAJDonneesNaissanceDTO2 donneesNaissance = getDonneesNaissance(candidat);
final MAJDonneesPersonnellesDTO3 donneesPersonnelles = new MAJDonneesPersonnellesDTO3();
final MAJOpiBacDTO2 bac = new MAJOpiBacDTO2();
/* Informations de verification */
individu.setCodOpiIntEpo(codOpiIntEpo);
individu.setCodEtuOpi(null);
if (candidat.getCompteMinima() != null && candidat.getCompteMinima().getSupannEtuIdCptMin() != null) {
try {
individu.setCodEtuOpi(Integer.valueOf(candidat.getCompteMinima().getSupannEtuIdCptMin()));
} catch (final Exception e) {
}
}
// donnees personnelles
donneesPersonnelles.setAdrMailOpi(candidat.getCompteMinima().getMailPersoCptMin());
donneesPersonnelles.setNumTelPorOpi(candidat.getTelPortCandidat());
// BAC
if (bacOuEqu != null && bacOuEqu.getSiScolBacOuxEqu() != null) {
bac.setCodBac(bacOuEqu.getSiScolBacOuxEqu().getCodBac());
bac.setCodDep((bacOuEqu.getSiScolDepartement()) != null ? bacOuEqu.getSiScolDepartement().getCodDep() : null);
bac.setCodEtb((bacOuEqu.getSiScolEtablissement()) != null ? bacOuEqu.getSiScolEtablissement().getCodEtb() : null);
bac.setCodTpe((bacOuEqu.getSiScolEtablissement()) != null ? bacOuEqu.getSiScolEtablissement().getCodTpeEtb() : null);
bac.setCodMention((bacOuEqu.getSiScolMentionNivBac()) != null ? bacOuEqu.getSiScolMentionNivBac().getCodMnb() : null);
// calcul de l'année
if (bacOuEqu.getAnneeObtBac() != null) {
logger.debug("bac avec annee" + logComp);
bac.setDaaObtBacOba(bacOuEqu.getAnneeObtBac().toString());
} else {
logger.debug("bac sans annee" + logComp);
bac.setDaaObtBacOba(getDefaultBacAnneeObt());
}
/* Specialités / Options */
bac.setCodSpe1BacTer(Optional.ofNullable(bacOuEqu.getSiScolSpe1BacTer()).map(SiScolSpecialiteBac::getCodSpeBac).orElse(null));
bac.setCodSpe2BacTer(Optional.ofNullable(bacOuEqu.getSiScolSpe2BacTer()).map(SiScolSpecialiteBac::getCodSpeBac).orElse(null));
bac.setCodSpeBacPre(Optional.ofNullable(bacOuEqu.getSiScolSpeBacPre()).map(SiScolSpecialiteBac::getCodSpeBac).orElse(null));
bac.setCodOpt1Bac(Optional.ofNullable(bacOuEqu.getSiScolOpt1Bac()).map(SiScolOptionBac::getCodOptBac).orElse(null));
bac.setCodOpt2Bac(Optional.ofNullable(bacOuEqu.getSiScolOpt2Bac()).map(SiScolOptionBac::getCodOptBac).orElse(null));
bac.setCodOpt3Bac(Optional.ofNullable(bacOuEqu.getSiScolOpt3Bac()).map(SiScolOptionBac::getCodOptBac).orElse(null));
bac.setCodOpt4Bac(Optional.ofNullable(bacOuEqu.getSiScolOpt4Bac()).map(SiScolOptionBac::getCodOptBac).orElse(null));
} else {
final String codNoBac = parametreController.getSiscolCodeSansBac();
if (codNoBac != null && !codNoBac.equals("")) {
logger.debug("bac par defaut" + logComp);
bac.setCodBac(codNoBac);
bac.setDaaObtBacOba(getDefaultBacAnneeObt());
} else {
logger.debug("aucun bac" + logComp);
}
}
individu.setEtatCivil(etatCivil);
individu.setDonneesNaissance(donneesNaissance);
individu.setDonneesPersonnelles(donneesPersonnelles);
donneesOPI.setIndividu(individu);
donneesOPI.setBac(bac);
/* Donnes d'adresse */
if (parametreController.getIsUtiliseOpiAdr()) {
donneesOPI.setAdresseFixe(getAdresseOPI(candidat.getAdresse(), candidat));
}
/* Les voeux */
int rang = 0;
if (listeMAJOpiVoeuDTO != null) {
final TableauVoeu3 tabDonneesVoeux = new TableauVoeu3();
for (final MAJOpiVoeuDTO3 v : listeMAJOpiVoeuDTO) {
tabDonneesVoeux.getItem().add(v);
rang++;
}
/**
* TODO Voir avec l'amue pour la supression des voeux --> hack : passer un
* tableau avec un voeu vide
*/
if (tabDonneesVoeux.getItem().size() == 0) {
tabDonneesVoeux.getItem().add(new MAJOpiVoeuDTO3());
logger.debug("suppression des voeux" + logComp);
}
/**
* Fin TODO
*/
donneesOPI.setVoeux(tabDonneesVoeux);
}
/* else{ logger.debug("aucun OPI a passer"+logComp); return; } */
logger.debug("listVoeux " + rang + logComp);
boolean actionWSok = false;
try {
logger.debug("lancement ws OPI" + logComp);
opiService.mettreajourDonneesOpiV10(donneesOPI);
logger.debug("fin ws OPI" + logComp);
actionWSok = true;
} catch (final Exception e) {
logger.error("erreur ws OPI" + logComp, e);
return;
}
// Si l'appel au WS s'est bien passé
if (actionWSok) {
// Vérifie si l'OPI est passé
final List<IndOpi> listIndOpi = findNneIndOpiByCodOpiIntEpo(codOpiIntEpo, individu.getCodEtuOpi(), etatCivil, candidat.getDatNaissCandidat());
// dans apogee
if (listIndOpi == null || listIndOpi.size() == 0) {
mailController.sendErrorToAdminFonctionnel("Erreur OPI" + logComp, "Erreur OPI : Probleme d'insertion de l'OPI dans Apogée, pas de données OPI" + logComp, logger);
return;
}
IndOpi indOpi = null;
// Test si plusieurs indopi trouvé
if (listIndOpi.size() > 1) {
// on recherche celui qu'on vient d'inserer
final List<IndOpi> listeFromEcandidat = listIndOpi.stream().filter(e -> e.getCodOpiIntEpo() != null && e.getCodOpiIntEpo().toUpperCase().equals(codOpiIntEpo.toUpperCase())).collect(Collectors.toList());
// si il y en a plusieurs-->erreur
if (listeFromEcandidat.size() > 1) {
mailController.sendErrorToAdminFonctionnel("Erreur OPI" + logComp, "Erreur OPI : Probleme d'insertion de l'OPI dans Apogée, plusieurs données OPI trouvées avec le même CodOpiIntEpo = " + codOpiIntEpo.toUpperCase() + logComp, logger);
return;
} else // candiature
if (listeFromEcandidat.size() == 0) {
mailController.sendErrorToAdminFonctionnel("Erreur OPI" + logComp, "Erreur OPI : Probleme d'insertion de l'OPI dans Apogée, plusieurs données OPI trouvées" + logComp, logger);
return;
} else // si un seul, on a raccroché la candiature sur celui-ci
if (listeFromEcandidat.size() == 1) {
indOpi = listeFromEcandidat.get(0);
}
} else /* On a trouvé un seul OPI, c'est ok, on continue avec celui là */
if (listIndOpi.size() == 1) {
indOpi = listIndOpi.get(0);
}
/* Verification que l'opi est bien trouvé et que son code n'ets pas null */
if (indOpi == null) {
logger.error("Erreur OPI : opi null ou non trouvé " + logComp);
return;
}
/* On vérifie aussi que tout s'est bien passé */
try {
final List<VoeuxIns> listeVoeux = getVoeuxApogee(indOpi);
final List<Opi> listeOpiATraiter = new ArrayList<>();
listeVoeux.forEach(voeu -> {
listeOpi.stream().filter(opi -> opi.getDatPassageOpi() == null && voeu.getId().getCodEtp().equals(opi.getCandidature().getFormation().getCodEtpVetApoForm()) && String.valueOf(voeu.getId().getCodVrsVet()).equals(opi.getCandidature().getFormation().getCodVrsVetApoForm()) && voeu.getId().getCodCge().equals(opi.getCandidature().getFormation().getSiScolCentreGestion().getCodCge())).collect(Collectors.toList()).forEach(opiFiltre -> {
listeOpiATraiter.add(opiFiltre);
});
});
/* Traitement des desistements apres confirmation */
final List<Opi> listeOpiDesistementATraiter = new ArrayList<>();
listeOpi.stream().filter(opi -> opi.getDatPassageOpi() == null && opi.getCandidature().getTemAcceptCand() != null && !opi.getCandidature().getTemAcceptCand()).forEach(opiDesist -> {
final long nbvoeuxDesist = listeVoeux.stream().filter(voeu -> voeu.getId().getCodEtp().equals(opiDesist.getCandidature().getFormation().getCodEtpVetApoForm()) && String.valueOf(voeu.getId().getCodVrsVet()).equals(opiDesist.getCandidature().getFormation().getCodVrsVetApoForm()) && voeu.getId().getCodCge().equals(opiDesist.getCandidature().getFormation().getSiScolCentreGestion().getCodCge())).count();
// sinon on le traite
if (nbvoeuxDesist == 0) {
listeOpiDesistementATraiter.add(opiDesist);
}
});
/* On verifie que le code OPI provient de ecandidat */
final Boolean isCodOpiIntEpoFromEcandidat = codOpiIntEpo.toUpperCase().equals(indOpi.getCodOpiIntEpo().toUpperCase());
/* On traite les OPI */
opiController.traiteListOpiCandidat(candidat, listeOpiATraiter, isCodOpiIntEpoFromEcandidat, indOpi.getCodOpiIntEpo(), logComp);
/* On traite les OPI en desistement */
opiController.traiteListOpiDesistCandidat(candidat, listeOpiDesistementATraiter, logComp);
/* Traitement des PJ */
opiController.traiteListOpiPjCandidat(listeOpiATraiter, indOpi.getCodOpiIntEpo(), indOpi.getCodIndOpi(), logComp, isBatch);
} catch (final SiScolException e) {
logger.error("Erreur OPI : Probleme d'insertion des voeux dans Apogée" + logComp, e);
// Affichage message dans l'interface
return;
}
}
return;
}
use of fr.univlorraine.ecandidat.entities.ecandidat.Opi in project esup-ecandidat by EsupPortail.
the class CandidatureCtrCandController method editOpi.
/**
* Modifie un numero opi
* @param listeCandidature
* @param newOpi
* @param isSendMail
* @return true si tout s'est bien passé
*/
public Boolean editOpi(final List<Candidature> listeCandidature, final Opi newOpi, final Boolean isSendMail) {
if (listeCandidature.size() > 1) {
return false;
}
if (checkLockListCandidature(listeCandidature)) {
return false;
}
final String user = userController.getCurrentUserLogin();
for (Candidature candidature : listeCandidature) {
Assert.notNull(candidature, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
/* Verrou */
if (!lockCandidatController.getLockOrNotifyCandidature(candidature)) {
continue;
}
final String newCodeOpi = newOpi.getCodOpi();
Opi opi = candidature.getOpi();
if (opi == null) {
opi = new Opi(candidature);
}
opi.setCodOpi(newCodeOpi);
opi.setDatPassageOpi(LocalDateTime.now());
final Opi opiSave = opiRepository.save(opi);
candidature.setOpi(opiSave);
candidature.setUserModCand(user);
candidature = candidatureRepository.save(candidature);
if (isSendMail) {
opiController.sendMailChangeCodeOpi(candidature.getCandidat(), newCodeOpi, "<ul><li>" + candidature.getFormation().getLibForm() + "</li></ul>");
}
}
Notification.show(applicationContext.getMessage("candidature.action.opi.notif", null, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
return true;
}
use of fr.univlorraine.ecandidat.entities.ecandidat.Opi in project esup-ecandidat by EsupPortail.
the class OpiController method generateOpi.
/**
* Genere un opi si besoin
* @param candidature
* @param confirm
*/
public void generateOpi(final Candidature candidature, final Boolean confirm) {
logger.debug("Generation de l'opi");
if (candidature == null) {
return;
}
final TypeDecisionCandidature lastTypeDecision = candidatureController.getLastTypeDecisionCandidature(candidature);
if (parametreController.getIsUtiliseOpi() && lastTypeDecision.getTypeDecision().getTemDeverseOpiTypDec() && !demoController.getDemoMode()) {
Opi opi = opiRepository.findOne(candidature.getIdCand());
// cas de la confirmation
if (opi == null && confirm) {
opi = opiRepository.save(new Opi(candidature));
candidature.setOpi(opi);
if (parametreController.getIsOpiImmediat()) {
logger.debug("Lancement OPI immédiat après confirmation");
siScolService.creerOpiViaWS(candidature.getCandidat(), false);
}
} else if (opi != null && !confirm) {
if (opi.getDatPassageOpi() == null) {
opiRepository.delete(opi);
} else {
opi.setDatPassageOpi(null);
opiRepository.save(opi);
candidature.setOpi(opi);
if (parametreController.getIsOpiImmediat()) {
logger.debug("Lancement OPI immédiat après desistement");
siScolService.creerOpiViaWS(candidature.getCandidat(), false);
}
}
}
}
}
Aggregations