use of fr.univlorraine.ecandidat.entities.ecandidat.BatchHisto in project esup-ecandidat by EsupPortail.
the class CandidatureGestionController method launchBatchDestructDossier.
/**
* Lance le batch de destruction des dossiers
*/
public void launchBatchDestructDossier(final BatchHisto batchHisto) throws FileException {
final Boolean deleteFileManualy = enableDeleteFileManuallyBatchDestruct != null && enableDeleteFileManuallyBatchDestruct;
final Boolean deleteRootManualy = enableDeleteRootFolderManuallyBatchDestruct != null && enableDeleteRootFolderManuallyBatchDestruct;
final List<Campagne> listeCamp = campagneController.getCampagnes().stream().filter(e -> (e.getDatDestructEffecCamp() == null && e.getDatArchivCamp() != null)).collect(Collectors.toList());
batchController.addDescription(batchHisto, "Lancement batch de destruction");
batchController.addDescription(batchHisto, "Batch de destruction, option enableDeleteFileManuallyBatchDestruct=" + deleteFileManualy);
batchController.addDescription(batchHisto, "Batch de destruction, option enableDeleteRootFolderManuallyBatchDestruct=" + deleteRootManualy);
for (final Campagne campagne : listeCamp) {
if (campagneController.getDateDestructionDossier(campagne).isBefore(LocalDateTime.now())) {
batchController.addDescription(batchHisto, "Batch de destruction, destruction dossiers campagne : " + campagne.getCodCamp() + " - " + campagne.getCompteMinimas().size() + " comptes à supprimer");
Integer i = 0;
Integer cpt = 0;
for (final CompteMinima cptMin : campagne.getCompteMinimas()) {
if (cptMin.getCandidat() != null) {
for (final Candidature candidature : cptMin.getCandidat().getCandidatures()) {
for (final PjCand pjCand : candidature.getPjCands()) {
if (deleteFileManualy) {
candidaturePieceController.removeFileToPjManually(pjCand);
} else {
candidaturePieceController.removeFileToPj(pjCand);
}
}
}
}
compteMinimaRepository.delete(cptMin);
i++;
cpt++;
if (i.equals(ConstanteUtils.BATCH_LOG_NB_LONG)) {
batchController.addDescription(batchHisto, "Batch de destruction, destruction de " + cpt + " comptes ok");
i = 0;
}
}
/* Lancement du batch de fiabilisation des fichiers */
fileController.launchFiabilisationFichier(campagne.getDatArchivCamp());
/* Destruction du dossier de la campagne et les sous-repertoire */
if (!deleteRootManualy) {
batchController.addDescription(batchHisto, "Batch de destruction, destruction dossier root campagne : " + campagne.getCodCamp());
fileController.deleteCampagneFolder(campagne.getCodCamp());
}
campagneController.saveDateDestructionCampagne(campagne);
/* Enregistre la date de suppression */
batchController.addDescription(batchHisto, "Batch de destruction, fin destruction campagne : " + campagne.getCodCamp() + ", " + cpt + " comptes supprimés");
}
batchController.addDescription(batchHisto, "Fin batch de destruction");
}
}
use of fr.univlorraine.ecandidat.entities.ecandidat.BatchHisto in project esup-ecandidat by EsupPortail.
the class BatchController method runJob.
/**
* Lance un batch
* @param batch
*/
private void runJob(Batch batch) {
logger.trace("Début du log");
BatchHisto batchHisto = new BatchHisto();
batchHisto.setDateDebBatchHisto(LocalDateTime.now());
batchHisto.setBatch(batch);
batchHisto.setStateBatchHisto(ConstanteUtils.BATCH_RUNNING);
batchHisto = batchHistoRepository.saveAndFlush(batchHisto);
batch.setLastDatExecutionBatch(LocalDateTime.now());
batch = batchRepository.save(batch);
try {
if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_SI_SCOL)) {
siScolController.syncSiScol(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_NETTOYAGE)) {
nettoyageBatch(4);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_APP_EN_MAINT)) {
parametreController.changeMaintenanceParam(true);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_APP_EN_SERVICE)) {
parametreController.changeMaintenanceParam(false);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_NETTOYAGE_CPT)) {
candidatController.nettoyageCptMinInvalides(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_ARCHIVAGE)) {
campagneController.archiveCampagne(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_SYNCHRO_LIMESURVEY)) {
formulaireController.launchBatchSyncLimeSurvey();
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_DESTRUCT_DOSSIER)) {
candidatureGestionController.launchBatchDestructDossier(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_ASYNC_OPI)) {
opiController.launchBatchAsyncOPI(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_DESTRUCT_HISTO)) {
cleanHistoBatch();
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_DEMO) && demoController.getDemoMode()) {
demoController.launchDemoBatch();
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_ASYNC_OPI_PJ)) {
opiController.launchBatchAsyncOPIPj(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_DESIST_AUTO)) {
candidatureGestionController.desistAutoCandidature(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_RELANCE_FAVO)) {
candidatureGestionController.relanceFavorableNotConfirm(batchHisto);
} else if (batch.getCodBatch().equals(NomenclatureUtils.BATCH_CALCUL_RANG_LC)) {
candidatureGestionController.calculRangLcAllFormation(batchHisto);
}
batchHisto.setStateBatchHisto(ConstanteUtils.BATCH_FINISH);
} catch (final Exception e) {
logger.error("Erreur de lancement du batch " + batch.getCodBatch(), e);
batchHisto.setStateBatchHisto(ConstanteUtils.BATCH_ERROR);
}
batchHisto.setDateFinBatchHisto(LocalDateTime.now());
batchHistoRepository.saveAndFlush(batchHisto);
batch.setLastDatExecutionBatch(LocalDateTime.now());
batch = batchRepository.save(batch);
logger.trace("Fin du log");
}
use of fr.univlorraine.ecandidat.entities.ecandidat.BatchHisto in project esup-ecandidat by EsupPortail.
the class BatchController method runImmediatly.
/**
* Lancement immediat du batch
* @param batch
*/
public void runImmediatly(final Batch batch) {
final ConfirmWindow win = new ConfirmWindow(applicationContext.getMessage("batch.immediat.ok", new Object[] { batch.getCodBatch() }, UI.getCurrent().getLocale()));
win.addBtnOuiListener(e -> {
final BatchHisto histo = batchHistoRepository.findByBatchCodBatchAndStateBatchHisto(batch.getCodBatch(), ConstanteUtils.BATCH_RUNNING);
if (histo == null) {
batch.setTemIsLaunchImediaBatch(true);
batchRepository.saveAndFlush(batch);
Notification.show(applicationContext.getMessage("batch.immediat.launch", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
} else {
Notification.show(applicationContext.getMessage("batch.immediat.nok", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
}
});
UI.getCurrent().addWindow(win);
}
use of fr.univlorraine.ecandidat.entities.ecandidat.BatchHisto in project esup-ecandidat by EsupPortail.
the class BatchController method checkBatchRun.
/**
* Vérifie si un batch doit etre lancé depuis la dernière date de verification
*/
@Scheduled(fixedDelayString = "${batch.fixedRate}")
public void checkBatchRun() {
if (!loadBalancingController.isLoadBalancingCandidatMode()) {
final List<BatchRun> liste = batchRunRepository.findAll();
if (liste != null && liste.size() == 1) {
final BatchRun lastBatchRun = liste.get(0);
final List<Batch> listeBatch = batchRepository.findByTesBatch(true);
logger.trace("Vérification lancement lastChek = " + lastBatchRun.getDatLastCheckRun() + " - Now = " + LocalDateTime.now());
/* Suppression du dernier batch run */
nettoyageBatchRun();
listeBatch.forEach(batch -> {
final BatchHisto histo = batchHistoRepository.findByBatchCodBatchAndStateBatchHisto(batch.getCodBatch(), ConstanteUtils.BATCH_RUNNING);
if (histo == null && isNeededToLaunch(batch, lastBatchRun.getDatLastCheckRun())) {
logger.debug("Le batch " + batch.getCodBatch() + " doit être lancé");
runJob(batch);
}
});
} else {
nettoyageBatchRun();
}
}
}
use of fr.univlorraine.ecandidat.entities.ecandidat.BatchHisto in project esup-ecandidat by EsupPortail.
the class BatchController method nettoyageBatch.
/**
* Batch de nettoyage des batchs
*/
public void nettoyageBatch(final Integer plusHour) {
final List<BatchHisto> listHisto = batchHistoRepository.findByStateBatchHisto(ConstanteUtils.BATCH_RUNNING);
listHisto.forEach(batchHisto -> {
if (plusHour.equals(0)) {
interruptBatch(batchHisto);
} else {
final LocalDateTime histPlusHour = batchHisto.getDateDebBatchHisto().plusHours(Long.valueOf(plusHour));
if (histPlusHour.isBefore(LocalDateTime.now())) {
interruptBatch(batchHisto);
}
}
});
}
Aggregations