Java Code Examples for org.springframework.batch.core.JobParametersBuilder#toJobParameters()
The following examples show how to use
org.springframework.batch.core.JobParametersBuilder#toJobParameters() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceUtil.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
static JobParameters mapToJobParameters(final Map<String, Object> parameters) { final JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); if (parameters != null) { for (final Map.Entry<String, Object> parameter : parameters.entrySet()) { final String parameterName = parameter.getKey(); final Object parameterValue = parameter.getValue(); attachJobParameter(jobParametersBuilder, parameterName, parameterValue); } } return jobParametersBuilder.toJobParameters(); }
Example 2
Source File: ProductImportSeviceBatchImpl.java From website with GNU Affero General Public License v3.0 | 5 votes |
@Override public void importProductsFromFile(String filename) throws Exception { JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); jobParametersBuilder.addString("input.file.name", filename); JobParameters jobParameters = jobParametersBuilder.toJobParameters(); jobLauncher.run(job, jobParameters); }
Example 3
Source File: FileMessageToJobRequest.java From spring-batch-performance-tuning with Apache License 2.0 | 5 votes |
public JobLaunchRequest toRequest(Message<File> message) { JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); jobParametersBuilder .addString(fileName, message.getPayload().getAbsolutePath()) .addDate("run.date", new Date()); return new JobLaunchRequest(job, jobParametersBuilder.toJobParameters()); }
Example 4
Source File: JobLauncherDetails.java From spring-batch-quartz-admin with Apache License 2.0 | 5 votes |
private JobParameters getJobParametersFromJobMap(Map<String, Object> jobDataMap) { JobParametersBuilder builder = new JobParametersBuilder(); for (Entry<String, Object> entry : jobDataMap.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof String && !key.equals(Constants.JOB_NAME)) { builder.addString(key, (String) value); } else if (value instanceof Float || value instanceof Double) { builder.addDouble(key, ((Number) value).doubleValue()); } else if (value instanceof Integer || value instanceof Long) { builder.addLong(key, ((Number) value).longValue()); } else if (value instanceof Date) { builder.addDate(key, (Date) value); } else { // JobDataMap contains values which are not job parameters // (ignoring) } } // Needs a unique job parameter to rerun the completed job builder.addDate(Constants.JOB_RUN_DATE, new Date()); return builder.toJobParameters(); }
Example 5
Source File: DomainParameterParser.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
/** * maps a String a parameters to Spring Batch {@link JobParameters}. * The String has to have the following format: * <ul> * <li> * name(type)=value, name(type2)=value2 * </li> * </ul> * The name is the job parameter name, the type, the Java type to the value. * Following Types are supported * <ul> * <li> * {@link String} * </li> * <li> * {@link Long} * </li> * <li> * {@link Double} * </li> * <li> * {@link Date} * </li> * </ul> * * @param parameters String of parameters * @return Spring Batch {@link JobParameters} */ public static JobParameters parseParametersToJobParameters(final String parameters) { final JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); final Map<String, Object> parametersMap = parseParameters(parameters); for (final Entry<String, Object> entry : parametersMap.entrySet()) { final Object value = entry.getValue(); if (value instanceof String) { jobParametersBuilder.addString(entry.getKey(), (String) value); } else if (value instanceof Long) { jobParametersBuilder.addLong(entry.getKey(), (Long) value); } else if (value instanceof Date) { jobParametersBuilder.addDate(entry.getKey(), (Date) value); } else if (value instanceof Double) { jobParametersBuilder.addDouble(entry.getKey(), (Double) value); } else { throw new SpringBatchLightminApplicationException("Unknown Parameter type:" + value.getClass().getName()); } } return jobParametersBuilder.toJobParameters(); }
Example 6
Source File: BatchJobLauncher.java From pinpoint with Apache License 2.0 | 4 votes |
private JobParameters createTimeParameter() { JobParametersBuilder builder = new JobParametersBuilder(); Date now = new Date(); builder.addDate("schedule.date", now); return builder.toJobParameters(); }
Example 7
Source File: SpringBatchRetryIntegrationTest.java From tutorials with MIT License | 4 votes |
private JobParameters defaultJobParameters() { JobParametersBuilder paramsBuilder = new JobParametersBuilder(); paramsBuilder.addString("jobID", String.valueOf(System.currentTimeMillis())); return paramsBuilder.toJobParameters(); }
Example 8
Source File: SpringBatchStepScopeIntegrationTest.java From tutorials with MIT License | 4 votes |
private JobParameters defaultJobParameters() { JobParametersBuilder paramsBuilder = new JobParametersBuilder(); paramsBuilder.addString("file.input", TEST_INPUT_ONE); paramsBuilder.addString("file.output", TEST_OUTPUT); return paramsBuilder.toJobParameters(); }
Example 9
Source File: SpringBatchIntegrationTest.java From tutorials with MIT License | 4 votes |
private JobParameters defaultJobParameters() { JobParametersBuilder paramsBuilder = new JobParametersBuilder(); paramsBuilder.addString("file.input", TEST_INPUT); paramsBuilder.addString("file.output", TEST_OUTPUT); return paramsBuilder.toJobParameters(); }