public static JobSchedulerType getById(final Long id) { final JobSchedulerType type; if (CRON.getId().equals(id)) { type = CRON; } else if (PERIOD.getId().equals(id)) { type = PERIOD; } else { throw new SpringBatchLightminConfigurationException("Unknown id for JobSchedulerConfiguration:" + id); } return type; }
private String generateSchedulerBeanName(final String jobName, final Long id, final JobSchedulerType jobSchedulerType) { return jobName + jobSchedulerType.name() + id; }
void validate() { if (this.jobSchedulerType == null) { this.throwExceptionAndLogError("jobSchedulerType must not be null"); } if (this.taskExecutorType == null) { this.throwExceptionAndLogError("taskExecutorType must not be null"); } if (JobSchedulerType.CRON.equals(this.jobSchedulerType)) { this.validateCron(); } else if (JobSchedulerType.PERIOD.equals(this.jobSchedulerType)) { this.validatePeriod(); } else { this.throwExceptionAndLogError("Unknown jobSchedulerType: " + this.jobSchedulerType); } }
public static JobSchedulerConfiguration map(final Map<String, Object> values) { final JobSchedulerConfiguration jobSchedulerConfiguration = new JobSchedulerConfiguration(); jobSchedulerConfiguration.setBeanName(getValueOrNull(values, JobSchedulerConfigurationKey.BEAN_NAME, String.class)); final JobSchedulerType jobSchedulerType = JobSchedulerType.getById(getValueOrNull(values, JobSchedulerConfigurationKey.SCHEDULER_TYPE, Long.class)); if (JobSchedulerType.CRON == jobSchedulerType) { jobSchedulerConfiguration.setCronExpression(getValueOrNull(values, JobSchedulerConfigurationKey.CRON_EXPRESSION, String.class)); } else if (JobSchedulerType.PERIOD == jobSchedulerType) { jobSchedulerConfiguration.setFixedDelay(getValueOrNull(values, JobSchedulerConfigurationKey.FIXED_DELAY, Long.class)); jobSchedulerConfiguration.setInitialDelay(getValueOrNull(values, JobSchedulerConfigurationKey.INITIAL_DELAY, Long.class)); } jobSchedulerConfiguration.setJobSchedulerType(jobSchedulerType); final SchedulerStatus schedulerStatus = SchedulerStatus.getByValue(getValueOrNull(values, JobSchedulerConfigurationKey.STATUS, String.class)); jobSchedulerConfiguration.setSchedulerStatus(schedulerStatus); final TaskExecutorType taskExecutorType = TaskExecutorType.getById(getValueOrNull(values, JobSchedulerConfigurationKey.TASK_EXECUTOR_TYPE, Long.class)); jobSchedulerConfiguration.setTaskExecutorType(taskExecutorType); return jobSchedulerConfiguration; }
public static List<ValueRecord> map(final JobSchedulerConfiguration jobSchedulerConfiguration, final Long jobConfigurationId) { final List<ValueRecord> valueRecords = new ArrayList<>(); final ValueRecord beanName = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.BEAN_NAME, jobSchedulerConfiguration.getBeanName()); final ValueRecord cronExpression = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.CRON_EXPRESSION, jobSchedulerConfiguration.getCronExpression()); final ValueRecord fixedDelay = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.FIXED_DELAY, jobSchedulerConfiguration.getFixedDelay()); final ValueRecord initialDelay = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.INITIAL_DELAY, jobSchedulerConfiguration.getInitialDelay()); final ValueRecord schedulerStatus = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.STATUS, jobSchedulerConfiguration.getSchedulerStatus().getValue()); final ValueRecord schedulerType = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.SCHEDULER_TYPE, jobSchedulerConfiguration.getJobSchedulerType().getId()); final ValueRecord executorType = new ValueRecord(jobConfigurationId, JobSchedulerConfigurationKey.TASK_EXECUTOR_TYPE, jobSchedulerConfiguration.getTaskExecutorType().getId()); valueRecords.add(beanName); valueRecords.add(cronExpression); valueRecords.add(fixedDelay); valueRecords.add(initialDelay); valueRecords.add(schedulerStatus); valueRecords.add(schedulerType); valueRecords.add(executorType); return valueRecords; } }
private String generateSchedulerBeanName(final String jobName, final Long id, final JobSchedulerType jobSchedulerType) { return jobName + jobSchedulerType.name() + id; }