Search in sources :

Example 1 with JobExecutionFailure

use of cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure in project RecordManager2 by moravianlibrary.

the class HarvestingFacadeImpl method incrementalHarvest.

public void incrementalHarvest(long conf_id, String job_name) {
    LocalDateTime lastHarvestTime = getLastHarvest(conf_id, job_name);
    Map<String, JobParameter> parameters = new HashMap<>();
    parameters.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(conf_id));
    if (lastHarvestTime != null) {
        Date lastHarvest = Date.from(lastHarvestTime.atZone(ZoneId.systemDefault()).toInstant());
        logger.trace("Starting harvest from {}", lastHarvest);
        parameters.put(Constants.JOB_PARAM_FROM_DATE, new JobParameter(lastHarvest));
    }
    parameters.put(Constants.JOB_PARAM_UNTIL_DATE, new JobParameter(new Date()));
    parameters.put(Constants.JOB_PARAM_START_TIME, new JobParameter(new Date()));
    JobParameters params = new JobParameters(parameters);
    JobExecution exec = jobExecutor.execute(job_name, params);
    if (!ExitStatus.COMPLETED.equals(exec.getExitStatus())) {
        throw new JobExecutionFailure("Incremental harvest failed", exec);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) JobParameters(org.springframework.batch.core.JobParameters) JobParameter(org.springframework.batch.core.JobParameter) JobExecutionFailure(cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure) Date(java.util.Date)

Example 2 with JobExecutionFailure

use of cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure in project RecordManager2 by moravianlibrary.

the class ImportRecordFacadeImpl method downloadAndImportRecordSJob.

@Override
public void downloadAndImportRecordSJob(DownloadImportConfiguration dic) {
    Map<String, JobParameter> parameters = new HashMap<>();
    parameters.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(dic.getId()));
    parameters.put(Constants.JOB_PARAM_REPEAT, new JobParameter(Constants.JOB_PARAM_ONE_VALUE));
    JobParameters params = new JobParameters(parameters);
    JobExecution exec = jobExecutor.execute(dic.getJobName(), params);
    if (!ExitStatus.COMPLETED.equals(exec.getExitStatus())) {
        throw new JobExecutionFailure("Download and import failed", exec);
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) JobParameters(org.springframework.batch.core.JobParameters) JobParameter(org.springframework.batch.core.JobParameter) JobExecutionFailure(cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)

Example 3 with JobExecutionFailure

use of cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure in project RecordManager2 by moravianlibrary.

the class ImportRecordFacadeImpl method importFile.

@Override
public void importFile(long importConfId, File file, String format) {
    Map<String, JobParameter> parameters = new HashMap<>();
    parameters.put(Constants.JOB_PARAM_IN_FILE, new JobParameter(file.getAbsolutePath()));
    parameters.put(Constants.JOB_PARAM_FORMAT, new JobParameter(format));
    parameters.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(importConfId));
    JobParameters params = new JobParameters(parameters);
    JobExecution exec = jobExecutor.execute(Constants.JOB_ID_IMPORT, params);
    if (!ExitStatus.COMPLETED.equals(exec.getExitStatus())) {
        throw new JobExecutionFailure("Incremental harvest failed", exec);
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) JobParameters(org.springframework.batch.core.JobParameters) JobParameter(org.springframework.batch.core.JobParameter) JobExecutionFailure(cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)

Example 4 with JobExecutionFailure

use of cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure in project RecordManager2 by moravianlibrary.

the class ImportRecordFacadeImpl method importOaiRecordsJob.

@Override
public void importOaiRecordsJob(long impotrConfId, String fileName) {
    Map<String, JobParameter> parameters = new HashMap<>();
    parameters.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(impotrConfId));
    parameters.put(Constants.JOB_PARAM_IN_FILE, new JobParameter(fileName));
    parameters.put(Constants.JOB_PARAM_REPEAT, new JobParameter(Constants.JOB_PARAM_ONE_VALUE));
    JobParameters params = new JobParameters(parameters);
    JobExecution exec = jobExecutor.execute(Constants.JOB_ID_IMPORT_OAI, params);
    if (!ExitStatus.COMPLETED.equals(exec.getExitStatus())) {
        throw new JobExecutionFailure("ImportOaiRecords failed", exec);
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) JobParameters(org.springframework.batch.core.JobParameters) JobParameter(org.springframework.batch.core.JobParameter) JobExecutionFailure(cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)

Example 5 with JobExecutionFailure

use of cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure in project RecordManager2 by moravianlibrary.

the class ZakonyProLidiFacadeImpl method runZakonyProLidiHarvestJob.

@Override
public void runZakonyProLidiHarvestJob() {
    Map<String, JobParameter> parameters = new HashMap<>();
    parameters.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(Constants.IMPORT_CONF_ID_ZAKONY));
    parameters.put(Constants.JOB_PARAM_REPEAT, new JobParameter(Constants.JOB_PARAM_ONE_VALUE));
    JobParameters params = new JobParameters(parameters);
    JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_ZAKONYPROLIDI, params);
    if (!ExitStatus.COMPLETED.equals(exec.getExitStatus())) {
        throw new JobExecutionFailure("ZakonyProLidi harvest failed", exec);
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) HashMap(java.util.HashMap) JobParameters(org.springframework.batch.core.JobParameters) JobParameter(org.springframework.batch.core.JobParameter) JobExecutionFailure(cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)

Aggregations

JobExecutionFailure (cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)6 HashMap (java.util.HashMap)6 JobExecution (org.springframework.batch.core.JobExecution)6 JobParameter (org.springframework.batch.core.JobParameter)6 JobParameters (org.springframework.batch.core.JobParameters)6 LocalDateTime (java.time.LocalDateTime)1 Date (java.util.Date)1