use of fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision in project esup-ecandidat by EsupPortail.
the class NomenclatureController method majTypeDec.
/**
* Met a jour un type de decision
* @param typeDec
*/
private void majTypeDec(final TypeDecision typeDec) {
final TypeDecision typeDecLoad = typeDecisionRepository.findByCodTypDec(typeDec.getCodTypDec());
if (typeDecLoad == null) {
final TypeTraduction typeTrad = typeTraductionRepository.findOne(NomenclatureUtils.TYP_TRAD_TYP_DEC_LIB);
final I18n i18n = i18nRepository.saveAndFlush(new I18n(typeTrad));
final I18nTraduction trad = new I18nTraduction(typeDec.getLibTypDec(), i18n, cacheController.getLangueDefault());
i18nTraductionRepository.saveAndFlush(trad);
typeDec.setI18nLibTypDec(i18n);
typeDecisionRepository.saveAndFlush(typeDec);
}
}
use of fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision in project esup-ecandidat by EsupPortail.
the class TypeDecisionController method editNewTypeDecision.
/**
* Ouvre une fenêtre d'édition d'un nouveau typeDecision.
*/
public void editNewTypeDecision(final CentreCandidature ctrCand) {
TypeDecision typ = new TypeDecision(userController.getCurrentUserLogin());
typ.setTesTypDec(true);
typ.setCentreCandidature(ctrCand);
typ.setI18nLibTypDec(new I18n(i18nController.getTypeTraduction(NomenclatureUtils.TYP_TRAD_TYP_DEC_LIB)));
UI.getCurrent().addWindow(new TypeDecisionWindow(typ, ctrCand));
}
use of fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision in project esup-ecandidat by EsupPortail.
the class TypeDecisionViewTemplate method init.
/**
* Initialise la vue
*/
@PostConstruct
public void init() {
/* Style */
setSizeFull();
setMargin(true);
setSpacing(true);
/* Titre */
titleParam.addStyleName(StyleConstants.VIEW_TITLE);
addComponent(titleParam);
/* Boutons */
buttonsLayout.setWidth(100, Unit.PERCENTAGE);
buttonsLayout.setSpacing(true);
addComponent(buttonsLayout);
btnNew.setCaption(applicationContext.getMessage("typeDec.btnNouveau", null, UI.getCurrent().getLocale()));
btnNew.setEnabled(true);
buttonsLayout.addComponent(btnNew);
buttonsLayout.setComponentAlignment(btnNew, Alignment.MIDDLE_LEFT);
btnEdit.setCaption(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()));
btnEdit.setEnabled(false);
buttonsLayout.addComponent(btnEdit);
buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_CENTER);
OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
btnDelete.setEnabled(false);
btnDelete.addClickListener(e -> {
if (typeDecisionTable.getValue() instanceof TypeDecision) {
typeDecisionController.deleteTypeDecision((TypeDecision) typeDecisionTable.getValue());
}
});
buttonsLayout.addComponent(btnDelete);
buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);
/* Table des typeDecisions */
container.addNestedContainerProperty(TypeDecision_.typeAvis.getName() + "." + TypeAvis_.libelleTypAvis.getName());
container.addNestedContainerProperty(TypeDecision_.mail.getName() + "." + Mail_.libMail.getName());
typeDecisionTable.setContainerDataSource(container);
typeDecisionTable.addBooleanColumn(TypeDecision_.tesTypDec.getName());
typeDecisionTable.addBooleanColumn(TypeDecision_.temDeverseOpiTypDec.getName());
typeDecisionTable.addBooleanColumn(TypeDecision_.temDefinitifTypDec.getName());
typeDecisionTable.setSizeFull();
typeDecisionTable.setVisibleColumns((Object[]) FIELDS_ORDER);
for (String fieldName : FIELDS_ORDER) {
typeDecisionTable.setColumnHeader(fieldName, applicationContext.getMessage("typeDec.table." + fieldName, null, UI.getCurrent().getLocale()));
}
typeDecisionTable.setSortContainerPropertyId(TypeDecision_.codTypDec.getName());
typeDecisionTable.setColumnCollapsingAllowed(true);
typeDecisionTable.setColumnReorderingAllowed(true);
typeDecisionTable.setSelectable(true);
typeDecisionTable.setImmediate(true);
typeDecisionTable.addItemSetChangeListener(e -> typeDecisionTable.sanitizeSelection());
typeDecisionTable.addValueChangeListener(e -> {
/* Les boutons d'édition et de suppression de typeDecision sont actifs seulement si une typeDecision est sélectionnée. */
boolean typeDecisionIsSelectedEdit = typeDecisionTable.getValue() instanceof TypeDecision;
boolean typeDecisionIsSelectedDel = typeDecisionTable.getValue() instanceof TypeDecision && !((TypeDecision) typeDecisionTable.getValue()).getTemModelTypDec();
btnEdit.setEnabled(typeDecisionIsSelectedEdit);
btnDelete.setEnabled(typeDecisionIsSelectedDel);
});
addComponent(typeDecisionTable);
setExpandRatio(typeDecisionTable, 1);
}
use of fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision in project esup-ecandidat by EsupPortail.
the class CtrCandActionCandidatureWindow method majAvisComponent.
/**
* Mise à jour des composants pour les avis
*/
private void majAvisComponent() {
final ComboBoxTypeDecision cbTypeDecision = (ComboBoxTypeDecision) fieldGroupDecision.getField(TypeDecisionCandidature_.typeDecision.getName());
final ComboBoxMotivationAvis cbMotivation = (ComboBoxMotivationAvis) fieldGroupDecision.getField(TypeDecisionCandidature_.motivationAvis.getName());
final RequiredIntegerField fieldRang = (RequiredIntegerField) fieldGroupDecision.getField(TypeDecisionCandidature_.listCompRangTypDecCand.getName());
final RequiredTextField fieldLieuPreselect = (RequiredTextField) fieldGroupDecision.getField(TypeDecisionCandidature_.preselectLieuTypeDecCand.getName());
final RequiredDateField fieldDatePreselect = (RequiredDateField) fieldGroupDecision.getField(TypeDecisionCandidature_.preselectDateTypeDecCand.getName());
final RequiredCheckBox fieldAppel = (RequiredCheckBox) fieldGroupDecision.getField(TypeDecisionCandidature_.temAppelTypeDecCand.getName());
final LocalTimeField fieldHeurePreselect = (LocalTimeField) fieldGroupDecision.getField(TypeDecisionCandidature_.preselectHeureTypeDecCand.getName());
final RequiredTextArea fieldComment = (RequiredTextArea) fieldGroupDecision.getField(TypeDecisionCandidature_.commentTypeDecCand.getName());
if (cbTypeDecision.getValue() != null) {
if (candidature != null && candidature.getLastTypeDecision() != null && candidature.getLastTypeDecision().getTemValidTypeDecCand() && candidature.getLastTypeDecision().getTypeDecision().getTemDefinitifTypDec() && parametreController.getIsAppel()) {
fieldAppel.setVisible(true);
} else {
fieldAppel.setVisible(false);
fieldAppel.setValue(false);
}
fieldComment.setVisible(true);
final TypeDecision typeDecision = (TypeDecision) cbTypeDecision.getValue();
if (typeDecision.getTypeAvis().getCodTypAvis().equals(NomenclatureUtils.TYP_AVIS_DEF)) {
cbMotivation.setBoxNeeded(true, null);
} else {
cbMotivation.setBoxNeeded(false, null);
}
if (typeDecision.getTypeAvis().getCodTypAvis().equals(NomenclatureUtils.TYP_AVIS_LISTE_COMP)) {
fieldRang.setVisible(true);
fieldRang.setRequired(true);
fieldRang.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
} else {
fieldRang.setVisible(false);
fieldRang.setRequired(false);
fieldRang.setRequiredError(null);
fieldRang.setValue(null);
}
if (typeDecision.getTypeAvis().getCodTypAvis().equals(NomenclatureUtils.TYP_AVIS_PRESELECTION)) {
fieldLieuPreselect.setVisible(true);
fieldDatePreselect.setVisible(true);
fieldHeurePreselect.setVisible(true);
if (candidature != null) {
fieldLieuPreselect.setValue(candidature.getFormation().getPreselectLieuForm());
fieldDatePreselect.setValue((candidature.getFormation().getPreselectDateForm() != null) ? Date.valueOf(candidature.getFormation().getPreselectDateForm()) : null);
fieldHeurePreselect.setValue(candidature.getFormation().getPreselectHeureForm());
} else {
fieldLieuPreselect.setValue(null);
fieldDatePreselect.setValue(null);
fieldHeurePreselect.setValue(null);
}
} else {
fieldLieuPreselect.setVisible(false);
fieldDatePreselect.setVisible(false);
fieldHeurePreselect.setVisible(false);
}
} else {
cbMotivation.setBoxNeeded(false, null);
fieldRang.setVisible(false);
fieldRang.setRequired(false);
fieldRang.setRequiredError(null);
fieldRang.setValue(null);
fieldLieuPreselect.setVisible(false);
fieldDatePreselect.setVisible(false);
fieldHeurePreselect.setVisible(false);
fieldLieuPreselect.setValue(null);
fieldDatePreselect.setValue(null);
fieldHeurePreselect.setValue(null);
fieldAppel.setVisible(false);
fieldAppel.setValue(false);
fieldComment.setValue(null);
fieldComment.setVisible(false);
}
center();
}
use of fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision in project esup-ecandidat by EsupPortail.
the class CandidatureCtrCandController method validAvis.
/**
* Valide les avis de candidatures
* @param listeCandidature
* @return true si tout s'est bien passé
*/
public Boolean validAvis(final List<Candidature> listeCandidature) {
if (checkLockListCandidature(listeCandidature)) {
return false;
}
for (final Candidature candidature : listeCandidature) {
if (candidature.getLastTypeDecision() == null) {
Notification.show(applicationContext.getMessage("candidature.validAvis.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return false;
}
}
/* Bug sur la validation d'avis --> des candidatures ont recu le mail mais la candidature n'a pas été validée */
/* On vérifie qu'il n'y a pas de candidature en double */
final Long sizelistId = listeCandidature.stream().map(Candidature::getIdCand).distinct().count();
if (listeCandidature.size() != sizelistId.intValue()) {
logger.warn(applicationContext.getMessage("candidature.validAvis.doublon", null, UI.getCurrent().getLocale()) + " : erreur size list");
Notification.show(applicationContext.getMessage("candidature.validAvis.doublon", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return false;
}
final String user = userController.getCurrentUserLogin();
/* Bug sur la validation d'avis --> des candidatures ont recu le mail mais la candidature n'a pas été validée */
final Map<Integer, Integer> mapIdCandTraite = new HashMap<>();
int errorDoublon = 0;
/* Si l'avis donné est un avis LC, il faut recalculer le rang reel pour chaque formation */
final List<Formation> listeFormLC = new ArrayList<>();
for (final Candidature candidature : listeCandidature) {
Assert.notNull(candidature, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
/* Verrou */
if (!lockCandidatController.getLockOrNotifyCandidature(candidature)) {
continue;
}
TypeDecisionCandidature typeDecision = candidature.getLastTypeDecision().cloneCompletTypeDecisionCandidature();
if (typeDecision.getTypeDecision() != null && typeDecision.getTypeDecision().getTypeAvis().equals(tableRefController.getTypeAvisListComp())) {
final Formation formLc = candidature.getFormation();
if (formLc.getTemListCompForm() && !listeFormLC.contains(formLc)) {
listeFormLC.add(candidature.getFormation());
}
}
typeDecision.setTemValidTypeDecCand(true);
typeDecision.setDatValidTypeDecCand(LocalDateTime.now());
typeDecision.setUserValidTypeDecCand(user);
typeDecision.setCandidature(candidature);
/* On vérifie que la candidature de l'avis n'a pas déjà été enregistré avant enregistrement */
if (mapIdCandTraite.get(typeDecision.getCandidature().getIdCand()) != null) {
errorDoublon++;
continue;
} else {
mapIdCandTraite.put(typeDecision.getCandidature().getIdCand(), typeDecision.getCandidature().getIdCand());
}
typeDecision = typeDecisionCandidatureRepository.save(typeDecision);
final String localeCandidat = candidature.getCandidat().getLangue().getCodLangue();
candidature.setUserModCand(user);
candidature.setDatModCand(LocalDateTime.now());
candidature.setTypeDecision(typeDecision);
candidature.setLastTypeDecision(typeDecision);
candidatureRepository.save(candidature);
String motif = "";
if (typeDecision.getTypeDecision().getTypeAvis().equals(tableRefController.getTypeAvisDefavorable()) && typeDecision.getMotivationAvis() != null) {
motif = i18nController.getI18nTraduction(typeDecision.getMotivationAvis().getI18nLibMotiv(), localeCandidat);
}
String complementAppel = "";
if (typeDecision.getTemAppelTypeDecCand()) {
complementAppel = applicationContext.getMessage("candidature.mail.complement.appel", null, UI.getCurrent().getLocale());
}
String rang = "";
if (typeDecision.getListCompRangTypDecCand() != null) {
rang = String.valueOf(typeDecision.getListCompRangTypDecCand());
}
String commentaire = "";
if (typeDecision.getTypeDecision().getTemAffCommentTypDec()) {
commentaire = typeDecision.getCommentTypeDecCand();
}
final AvisMailBean mailBean = new AvisMailBean(motif, commentaire, getComplementPreselectMail(typeDecision), complementAppel, rang);
PdfAttachement attachement = null;
final InputStream is = candidatureController.downloadLettre(candidature, ConstanteUtils.TYP_LETTRE_MAIL, localeCandidat, true);
if (is != null) {
try {
attachement = new PdfAttachement(is, candidatureController.getNomFichierLettre(candidature, ConstanteUtils.TYP_LETTRE_MAIL, localeCandidat));
} catch (final Exception e) {
attachement = null;
}
}
mailController.sendMail(candidature.getCandidat().getCompteMinima().getMailPersoCptMin(), typeDecision.getTypeDecision().getMail(), mailBean, candidature, localeCandidat, attachement);
}
/* Recalcul des rang LC si besoin */
if (parametreController.isCalculRangReelLc()) {
final List<TypeDecisionCandidature> listeTypDecRangReel = candidatureGestionController.calculRangReelListForm(listeFormLC);
/* Pour chaque candidature recalculée, on ajouter le rang reel */
listeTypDecRangReel.forEach(td -> {
/* On cherche la candidature associée */
final Optional<Candidature> optCand = listeCandidature.stream().filter(cand -> cand.equals(td.getCandidature())).findFirst();
if (optCand.isPresent()) {
optCand.get().setTypeDecision(td);
optCand.get().setLastTypeDecision(td);
}
});
}
/* Bug sur la validation d'avis --> des candidatures ont recu le mail mais la candidature n'a pas été validée */
if (errorDoublon > 0) {
logger.warn(applicationContext.getMessage("candidature.validAvis.doublon", null, UI.getCurrent().getLocale()) + " : erreur map", Type.WARNING_MESSAGE);
Notification.show(applicationContext.getMessage("candidature.validAvis.doublon", null, UI.getCurrent().getLocale()));
} else {
Notification.show(applicationContext.getMessage("candidature.validAvis.success", null, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
}
return true;
}
Aggregations