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);
}
}
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);
}
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);
}
Aggregations