本文整理汇总了Java中org.springframework.batch.core.JobParameter类的典型用法代码示例。如果您正苦于以下问题:Java JobParameter类的具体用法?Java JobParameter怎么用?Java JobParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JobParameter类属于org.springframework.batch.core包,在下文中一共展示了JobParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWriteTaxonFile
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
/**
* @throws Exception
*/
@Test
public void testWriteTaxonFile() throws Exception {
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("query", new JobParameter(""));
parameters.put("selected.facets", new JobParameter("taxon.family_ss=Araceae"));
parameters.put("download.taxon", new JobParameter(toParameter(DarwinCorePropertyMap.getConceptTerms(DwcTerm.Taxon))));
parameters.put("download.file", new JobParameter(UUID.randomUUID().toString() + ".txt"));
parameters.put("download.limit", new JobParameter(new Integer(Integer.MAX_VALUE).toString()));
parameters.put("download.fieldsTerminatedBy", new JobParameter("\t"));
parameters.put("download.fieldsEnclosedBy", new JobParameter("\""));
parameters.put("download.format", new JobParameter("taxon"));
JobParameters jobParameters = new JobParameters(parameters);
Job archiveCreatorJob = jobLocator.getJob("FlatFileCreation");
assertNotNull("flatFileCreatorJob must exist", archiveCreatorJob);
JobExecution jobExecution = jobLauncher.run(archiveCreatorJob,
jobParameters);
assertEquals("The Job should be sucessful", ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
示例2: testCreateGenericArchive
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
@Test
public void testCreateGenericArchive() throws NoSuchJobException,
JobExecutionAlreadyRunningException, JobRestartException,
JobInstanceAlreadyCompleteException, JobParametersInvalidException, IOException {
Map<String, JobParameter> parameters =
new HashMap<String, JobParameter>();
JobParameters jobParameters = new JobParameters(parameters);
Job palmwebArchive = jobLocator.getJob("PalmWeb");
assertNotNull("Palmweb must not be null", palmwebArchive);
JobExecution jobExecution = jobLauncher.run(palmwebArchive, jobParameters);
assertEquals("The job should complete successfully",jobExecution.getExitStatus().getExitCode(),"COMPLETED");
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
logger.info(stepExecution.getStepName() + " "
+ stepExecution.getReadCount() + " "
+ stepExecution.getFilterCount() + " "
+ stepExecution.getWriteCount() + " " + stepExecution.getCommitCount());
}
}
示例3: convertParameterEntryToParameter
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
protected Parameter convertParameterEntryToParameter(Map.Entry<String, JobParameter> entry) {
Parameter paramToAdd = new Parameter().setKey(entry.getKey());
JobParameter parameter = entry.getValue();
if (parameter.getType() == JobParameter.ParameterType.DATE) {
paramToAdd.setParameterType(ParameterType.DATE);
Date param = (Date) parameter.getValue();
if (param != null) {
paramToAdd.value(DateUtil.getDate(param));
}
return paramToAdd;
}
return paramToAdd
.value(parameter.getValue().toString())
.parameterType(parameter.getType() == JobParameter.ParameterType.STRING ?
ParameterType.STRING : ParameterType.NUMBER);
}
示例4: createSampleJob
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
private static void createSampleJob(String jobName, int jobExecutionCount) {
JobInstance instance = jobRepository.createJobInstance(jobName, new JobParameters());
jobInstances.add(instance);
TaskExecution taskExecution = dao.createTaskExecution(jobName, new Date(), new ArrayList<String>(), null);
Map<String, JobParameter> jobParameterMap = new HashMap<>();
jobParameterMap.put("foo", new JobParameter("FOO", true));
jobParameterMap.put("bar", new JobParameter("BAR", false));
JobParameters jobParameters = new JobParameters(jobParameterMap);
JobExecution jobExecution = null;
for (int i = 0; i < jobExecutionCount; i++) {
jobExecution = jobRepository.createJobExecution(instance, jobParameters, null);
taskBatchDao.saveRelationship(taskExecution, jobExecution);
StepExecution stepExecution = new StepExecution("foobar", jobExecution);
jobRepository.add(stepExecution);
}
}
示例5: assertCorrectMixins
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
private void assertCorrectMixins(RestTemplate restTemplate) {
boolean containsMappingJackson2HttpMessageConverter = false;
for (HttpMessageConverter<?> converter : restTemplate.getMessageConverters()) {
if (converter instanceof MappingJackson2HttpMessageConverter) {
containsMappingJackson2HttpMessageConverter = true;
final MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
final ObjectMapper objectMapper = jacksonConverter.getObjectMapper();
assertNotNull(objectMapper.findMixInClassFor(JobExecution.class));
assertNotNull(objectMapper.findMixInClassFor(JobParameters.class));
assertNotNull(objectMapper.findMixInClassFor(JobParameter.class));
assertNotNull(objectMapper.findMixInClassFor(JobInstance.class));
assertNotNull(objectMapper.findMixInClassFor(ExitStatus.class));
assertNotNull(objectMapper.findMixInClassFor(StepExecution.class));
assertNotNull(objectMapper.findMixInClassFor(ExecutionContext.class));
assertNotNull(objectMapper.findMixInClassFor(StepExecutionHistory.class));
}
}
if (!containsMappingJackson2HttpMessageConverter) {
fail("Expected that the restTemplate's list of Message Converters contained a "
+ "MappingJackson2HttpMessageConverter");
}
}
示例6: createJobInstance
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
/**
* @param jobId
* Set the job id
* @param jobName
* Set the job name
* @param authorityName
* Set the authority name
* @param version
* Set the version
*/
public void createJobInstance(String jobId,
String jobName, String authorityName,
String version) {
enableAuthentication();
Long id = null;
if (jobId != null && jobId.length() > 0) {
id = Long.parseLong(jobId);
}
Integer v = null;
if (version != null && version.length() > 0) {
v = Integer.parseInt(version);
}
Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
if (authorityName != null && authorityName.length() > 0) {
jobParameterMap.put("authority.name", new JobParameter(
authorityName));
}
JobParameters jobParameters = new JobParameters(jobParameterMap);
JobInstance jobInstance = new JobInstance(id, jobParameters, jobName);
jobInstance.setVersion(v);
data.push(jobInstance);
jobInstanceService.save(jobInstance);
disableAuthentication();
}
示例7: launch
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
@Override
public void launch(JobLaunchRequest request) {
Job job;
try {
job = jobLocator.getJob(request.getJob());
Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
for(String parameterName : request.getParameters().keySet()) {
jobParameterMap.put(parameterName, new JobParameter(request.getParameters().get(parameterName)));
}
JobParameters jobParameters = new JobParameters(jobParameterMap);
try {
jobLauncher.run(job, jobParameters);
} catch (JobExecutionAlreadyRunningException jeare) {
jobStatusNotifier.notify(new JobExecutionException(jeare.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
} catch (JobRestartException jre) {
jobStatusNotifier.notify(new JobExecutionException(jre.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
} catch (JobInstanceAlreadyCompleteException jiace) {
jobStatusNotifier.notify(new JobExecutionException(jiace.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
} catch (JobParametersInvalidException jpie) {
jobStatusNotifier.notify(new JobExecutionException(jpie.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
}
} catch (NoSuchJobException nsje) {
jobStatusNotifier.notify(new JobExecutionException(nsje.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
}
}
示例8: testWriteChecklistPdf
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
@Test
public void testWriteChecklistPdf() throws Exception {
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("query", new JobParameter(""));
parameters.put("selected.facets", new JobParameter("taxon.family_ss=Araceae"));
parameters.put("download.taxon", new JobParameter(toParameter(DarwinCorePropertyMap.getConceptTerms(DwcTerm.Taxon))));
parameters.put("download.file", new JobParameter(UUID.randomUUID().toString() + ".pdf"));
parameters.put("download.limit", new JobParameter(new Integer(Integer.MAX_VALUE).toString()));
parameters.put("download.fieldsTerminatedBy", new JobParameter("\t"));
parameters.put("download.fieldsEnclosedBy", new JobParameter("\""));
parameters.put("download.sort", new JobParameter("searchable.label_sort_asc"));
parameters.put("download.format", new JobParameter("hierarchicalChecklist"));
parameters.put("download.template.filepath", new JobParameter("org/emonocot/job/download/reports/name_report1.jrxml"));
JobParameters jobParameters = new JobParameters(parameters);
Job archiveCreatorJob = jobLocator.getJob("FlatFileCreation");
assertNotNull("flatFileCreator Job must exist", archiveCreatorJob);
JobExecution jobExecution = jobLauncher.run(archiveCreatorJob,
jobParameters);
assertEquals("The Job should be sucessful", ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
示例9: testNotModifiedResponse
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
/**
*
* @throws IOException
* if a temporary file cannot be created.
* @throws NoSuchJobException
* if SpeciesPageHarvestingJob cannot be located
* @throws JobParametersInvalidException
* if the job parameters are invalid
* @throws JobInstanceAlreadyCompleteException
* if the job has already completed
* @throws JobRestartException
* if the job cannot be restarted
* @throws JobExecutionAlreadyRunningException
* if the job is already running
*/
@Test
public final void testNotModifiedResponse() throws IOException,
NoSuchJobException, JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("query.string", new JobParameter("select i from Image i"));
JobParameters jobParameters = new JobParameters(parameters);
Job job = jobLocator.getJob("ImageProcessing");
assertNotNull("ImageProcessing must not be null", job);
JobExecution jobExecution = jobLauncher.run(job, jobParameters);
assertEquals("The job should complete successfully",jobExecution.getExitStatus().getExitCode(),"COMPLETED");
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
logger.info(stepExecution.getStepName() + " "
+ stepExecution.getReadCount() + " "
+ stepExecution.getFilterCount() + " "
+ stepExecution.getWriteCount());
}
}
示例10: testWriteJobInstance
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
/**
*
* @throws Exception
* if there is a problem serializing the object
*/
@Test
public void testWriteJobInstance() throws Exception {
Map<String, JobParameter> jobParameterMap
= new HashMap<String, JobParameter>();
jobParameterMap.put("authority.name", new JobParameter("test"));
JobInstance jobInstance = new JobInstance(1L, new JobParameters(
jobParameterMap), "testJob");
jobInstance.setVersion(1);
try {
objectMapper.writeValueAsString(jobInstance);
} catch (Exception e) {
fail("No exception expected here");
}
}
示例11: launch
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
@Override
public void launch(JobLaunchRequest request) {
Job job;
try {
job = jobLocator.getJob(request.getJob());
Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
for(String parameterName : request.getParameters().keySet()) {
jobParameterMap.put(parameterName, new JobParameter(request.getParameters().get(parameterName)));
}
JobParameters jobParameters = new JobParameters(jobParameterMap);
jobLauncher.run(job, jobParameters);
} catch (NoSuchJobException
| JobExecutionAlreadyRunningException
| JobRestartException
| JobInstanceAlreadyCompleteException
| JobParametersInvalidException exception) {
jobStatusNotifier.notify(new JobExecutionException(exception.getLocalizedMessage()), request.getParameters().get("job.configuration.id"));
}
}
示例12: testWriteTaxonFile
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
/**
* @throws Exception
*/
@Test
public void testWriteTaxonFile() throws Exception {
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("query", new JobParameter(""));
parameters.put("selected.facets", new JobParameter("taxon.family_ss=Araceae"));
parameters.put("download.taxon", new JobParameter(toParameter(DarwinCorePropertyMap.getConceptTerms(DwcTerm.Taxon))));
parameters.put("download.file", new JobParameter(UUID.randomUUID().toString() + ".txt"));
parameters.put("download.limit", new JobParameter(new Integer(Integer.MAX_VALUE).toString()));
parameters.put("download.fieldsTerminatedBy", new JobParameter("\t"));
parameters.put("download.fieldsEnclosedBy", new JobParameter("\""));
parameters.put("download.format", new JobParameter("taxon"));
JobParameters jobParameters = new JobParameters(parameters);
Job archiveCreatorJob = jobLocator.getJob("FlatFileCreation");
assertNotNull("flatFileCreatorJob must exist", archiveCreatorJob);
JobExecution jobExecution = jobLauncher.run(archiveCreatorJob,
jobParameters);
assertEquals("The Job should be sucessful", ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
示例13: convert
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
public static ParameterType convert(JobParameter.ParameterType type) {
if(JobParameter.ParameterType.DATE.equals(type)) {
return DATE;
}
else if(JobParameter.ParameterType.DOUBLE.equals(type)) {
return DOUBLE;
}
else if(JobParameter.ParameterType.LONG.equals(type)) {
return LONG;
}
else if(JobParameter.ParameterType.STRING.equals(type)) {
return STRING;
}
else {
throw new IllegalArgumentException("Unable to convert type");
}
}
示例14: JobParametersEvent
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
public JobParametersEvent(Map<String,JobParameter> jobParameters) {
this.parameters = new LinkedHashMap<>();
for(Map.Entry<String, JobParameter> entry: jobParameters.entrySet()){
if(entry.getValue().getValue() instanceof String){
parameters.put(entry.getKey(), new JobParameterEvent(entry.getValue()));
}
else if(entry.getValue().getValue() instanceof Long){
parameters.put(entry.getKey(), new JobParameterEvent(entry.getValue()));
}
else if(entry.getValue().getValue() instanceof Date){
parameters.put(entry.getKey(), new JobParameterEvent(entry.getValue()));
}
else if(entry.getValue().getValue() instanceof Double){
parameters.put(entry.getKey(), new JobParameterEvent(entry.getValue()));
}
}
}
示例15: testJobParameters
import org.springframework.batch.core.JobParameter; //导入依赖的package包/类
@Test
public void testJobParameters() {
String[] JOB_PARAM_KEYS = {"A", "B", "C", "D"};
Date testDate = new Date();
JobParameter[] PARAMETERS = {new JobParameter("FOO", true), new JobParameter(1L, true),
new JobParameter(1D, true), new JobParameter(testDate, false)};
Map jobParamMap = new LinkedHashMap<>();
for (int paramCount = 0; paramCount < JOB_PARAM_KEYS.length; paramCount++) {
jobParamMap.put(JOB_PARAM_KEYS[paramCount], PARAMETERS[paramCount]);
}
jobParameters = new JobParameters(jobParamMap);
JobExecution jobExecution = new JobExecution(jobInstance, JOB_EXECUTION_ID, jobParameters, JOB_CONFIGURATION_NAME);
JobExecutionEvent jobExecutionEvent = new JobExecutionEvent(jobExecution);
assertNotNull("Job Parameter A was expected", jobExecutionEvent.getJobParameters().getString("A"));
assertNotNull("Job Parameter B was expected", jobExecutionEvent.getJobParameters().getLong("B"));
assertNotNull("Job Parameter C was expected", jobExecutionEvent.getJobParameters().getDouble("C"));
assertNotNull("Job Parameter D was expected", jobExecutionEvent.getJobParameters().getDate("D"));
assertEquals("Job Parameter A value was not correct", "FOO", jobExecutionEvent.getJobParameters().getString("A"));
assertEquals("Job Parameter B value was not correct", new Long(1), jobExecutionEvent.getJobParameters().getLong("B"));
assertEquals("Job Parameter C value was not correct", new Double(1), jobExecutionEvent.getJobParameters().getDouble("C"));
assertEquals("Job Parameter D value was not correct", testDate, jobExecutionEvent.getJobParameters().getDate("D"));
}