当前位置: 首页>>代码示例>>Java>>正文


Java JobParametersBuilder.addString方法代码示例

本文整理汇总了Java中org.springframework.batch.core.JobParametersBuilder.addString方法的典型用法代码示例。如果您正苦于以下问题:Java JobParametersBuilder.addString方法的具体用法?Java JobParametersBuilder.addString怎么用?Java JobParametersBuilder.addString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.batch.core.JobParametersBuilder的用法示例。


在下文中一共展示了JobParametersBuilder.addString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareJobParameters

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
/**
 * Helper method converting the Camel message headers into the Spring Batch parameters map. Date, Long and Double
 * header values are converted to the appropriate types. All the other header values are converted to string
 * representation.
 *
 * @param headers Camel message header to be converted
 * @return Camel message headers converted into the Spring Batch parameters map
 */
protected JobParameters prepareJobParameters(Map<String, Object> headers) {
    JobParametersBuilder parametersBuilder = new JobParametersBuilder();
    for (Map.Entry<String, Object> headerEntry : headers.entrySet()) {
        String headerKey = headerEntry.getKey();
        Object headerValue = headerEntry.getValue();
        if (headerValue instanceof Date) {
            parametersBuilder.addDate(headerKey, (Date) headerValue);
        } else if (headerValue instanceof Long) {
            parametersBuilder.addLong(headerKey, (Long) headerValue);
        } else if (headerValue instanceof Double) {
            parametersBuilder.addDouble(headerKey, (Double) headerValue);
        } else if (headerValue != null) {
            parametersBuilder.addString(headerKey, headerValue.toString());
        } else {
            // if the value is null we just put String with null value here to avoid the NPE
            parametersBuilder.addString(headerKey, null);
        }
    }
    JobParameters jobParameters = parametersBuilder.toJobParameters();
    log.debug("Prepared parameters for Spring Batch job: {}", jobParameters);
    return jobParameters;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:SpringBatchProducer.java

示例2: unmarshal

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Override
public JobParameters unmarshal(AdaptedJobParameters params) throws Exception {
	JobParametersBuilder jobParametersBuilder  = new JobParametersBuilder();
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
	for (AdaptedJobParameters.AdaptedJobParameter param : params.getParameters()) {
   		switch (param.type) {
   			case "STRING":
   				jobParametersBuilder.addString(param.key, param.value, param.identifier);
   				break;
   			case "DATE":
   				jobParametersBuilder.addDate(param.key, df.parse(param.value), param.identifier);
   				break;
   			case "DOUBLE":
   				jobParametersBuilder.addDouble(param.key, Double.valueOf(param.value), param.identifier);
   				break;
   			case "LONG":
   				jobParametersBuilder.addLong(param.key, Long.valueOf(param.value), param.identifier);
   				break;
   		}
	}
	return jobParametersBuilder.toJobParameters();
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:23,代码来源:JobParametersAdapter.java

示例3: getJobParameters

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
public static JobParameters getJobParameters() {
	JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
	if (jobParameters.isEmpty()) {
		jobParametersBuilder.addLong("id", 1L, true);
		jobParametersBuilder.addString("stringTest", "Joe Cool", true);
		jobParametersBuilder.addDate("start", new Date(), false);
		jobParametersBuilder.addLong("longTest", 1239L, false);
		jobParametersBuilder.addDouble("doubleTest", 1.35D, false);
		jobParameters = jobParametersBuilder.toJobParameters();
	} else {
		JobParametersTestUtils utils = new JobParametersTestUtils();
		jobParameters = utils.getNext(jobParameters);
	}
	return jobParameters;
	
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:17,代码来源:JobParametersTestUtils.java

示例4: warmCache

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@GET
@Path("{sourceKey}/warmCache")
@Produces(MediaType.APPLICATION_JSON)
public JobExecutionResource warmCache(@PathParam("sourceKey") final String sourceKey) {
    ResultsCache resultsCache = new ResultsCache();
    CDMResultsCache cache = resultsCache.getCache(sourceKey);
    if (cache != null) {
        return new JobExecutionResource();
    }

    Source source = getSourceRepository().findBySourceKey(sourceKey);
    CDMResultsCacheTasklet tasklet = new CDMResultsCacheTasklet(this.getSourceJdbcTemplate(source), source);
    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("jobName", "warming " + sourceKey + " cache ");
    return this.jobTemplate.launchTasklet("warmCache", "warmCacheStep", tasklet, builder.toJobParameters());
}
 
开发者ID:OHDSI,项目名称:WebAPI,代码行数:17,代码来源:CDMResultsService.java

示例5: getJobParametersFromJobMap

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
/**
 * Copy parameters that are of the correct type over to
 * {@link org.springframework.batch.core.launch.JobLauncher JobParameters},
 * ignoring jobName.
 * 
 * @return a JobParameters instance
 */
private JobParameters getJobParametersFromJobMap(Map<String, Object> jobDataMap, JobParameters sPreviousJobParameters) {

    JobParametersBuilder builder = (sPreviousJobParameters != null) ? new JobParametersBuilder(sPreviousJobParameters) : new JobParametersBuilder();

    for (Entry<String, Object> entry : jobDataMap.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (value instanceof String && !key.equals(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 {
            LOGGER.debug("JobDataMap contains values which are not job parameters (ignoring).");
        }
    }

    return builder.toJobParameters();

}
 
开发者ID:acxio,项目名称:AGIA,代码行数:31,代码来源:JobLauncherDetails.java

示例6: requestJob3

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@RequestMapping("/job3/{input_file_name}")
@ResponseBody
String requestJob3(@PathVariable("input_file_name") String inputFileName) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException{
	JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
	jobParametersBuilder.addString("INPUT_FILE_PATH", inputFileName);
	jobParametersBuilder.addLong("TIMESTAMP",new Date().getTime());
	
	jobLauncher.run(job3, jobParametersBuilder.toJobParameters());
    return "Job3!";
}
 
开发者ID:pauldeng,项目名称:aws-elastic-beanstalk-worker-spring-boot-spring-batch-template,代码行数:11,代码来源:RESTController.java

示例7: test

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    JobParametersBuilder jpb = new JobParametersBuilder();
    jpb.addString("input_file_path", "src/test/resources/triple/test1.ttl");
    jpb.addString("graph_name", "myTestGraph");
    getJobLauncherTestUtils().launchJob(jpb.toJobParameters());

    String xml = getClient().newServerEval().xquery("collection('myTestGraph')").evalAs(String.class);
    Fragment f = parse(xml);
    f.assertElementExists("/sem:triples/sem:triple[sem:subject = 'http://example.org/kennedy/person1']");
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:12,代码来源:ImportRdfFromFileJobTest.java

示例8: runJobTest

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
public void runJobTest() throws Exception {
    JobParametersBuilder jpb = new JobParametersBuilder();
    jpb.addString("output_collections", "monster");
    JobExecution jobExecution = jobLauncherTestUtils.launchJob(jpb.toJobParameters());
    Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:8,代码来源:TwoStepJobTest.java

示例9: findOneMonsterInDatabaseTest

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
public void findOneMonsterInDatabaseTest() throws Exception {
    JobParametersBuilder jpb = new JobParametersBuilder();
    jpb.addString("output_collections", "monster");
    JobExecution jobExecution = getJobLauncherTestUtils().launchJob(jpb.toJobParameters());
    Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    getClientTestHelper().assertCollectionSize("Expecting 100 items in monster collection", "monster", 100);
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:9,代码来源:YourJobTest.java

示例10: runJobTwiceTest

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
public void runJobTwiceTest() throws Exception {
    JobParametersBuilder jpb = new JobParametersBuilder();
    jpb.addString("output_collections", "monster", false);
    jpb.addLong("run_id", 1L, true);
    JobExecution jobExecution = getJobLauncherTestUtils().launchJob(jpb.toJobParameters());
    jpb.addLong("run_id", 2L);
    JobExecution jobExecution2 = getJobLauncherTestUtils().launchJob(jpb.toJobParameters());
    Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    Assert.assertEquals(BatchStatus.COMPLETED, jobExecution2.getStatus());
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:12,代码来源:YourJobTest.java

示例11: testLaunchJob

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
public void testLaunchJob() throws Exception {
	JobParametersBuilder pb = new JobParametersBuilder();
	pb.addString("xml.input", "classpath:sample-exchange-schema.xml");
	pb.addString("tab.output", "file:out/sample.tab");
	
	jobLauncher.run(job, pb.toJobParameters());
}
 
开发者ID:MIABIS,项目名称:miabis-converter,代码行数:9,代码来源:JobXMLToCSVTest.java

示例12: testJob

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
  public void testJob() throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException, InterruptedException{
  	
  	// should be zero
  	Assert.assertEquals(0, getHits());
  	
  	JobParametersBuilder pb = new JobParametersBuilder();
pb.addString("contactInfo", DIRECTORY + "contactInfo.txt");
pb.addString("biobank", DIRECTORY + "biobank.txt");
pb.addString("sampleCollection", DIRECTORY + "sampleCollection.txt");
pb.addString("study", DIRECTORY + "study.txt");
pb.addString("sample", DIRECTORY + "sample.txt");

pb.addString("map","example.mapping.properties");

//Elasticsearch config
pb.addString("cluster.nodes", "localhost:9300");
pb.addString("cluster.name", "elasticsearch");
pb.addString("index.name", "sample");

JobExecution launch = jobLauncher.run(job, pb.toJobParameters());

while(launch.isRunning()){
	Thread.sleep(5000);
}
Thread.sleep(5000);

Assert.assertEquals(3, getHits());
  }
 
开发者ID:MIABIS,项目名称:miabis-converter,代码行数:30,代码来源:DBIndexJobTest.java

示例13: testLaunchJob

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Test
public void testLaunchJob() throws Exception {
	JobParametersBuilder pb = new JobParametersBuilder();
	pb.addString("contactInfo", DIRECTORY + "contactInfo.txt");
	pb.addString("biobank", DIRECTORY + "biobank.txt");
	pb.addString("sampleCollection", DIRECTORY + "sampleCollection.txt");
	pb.addString("study", DIRECTORY + "study.txt");
	pb.addString("sample", DIRECTORY + "sample.txt");
	
	pb.addString("map","example.mapping.properties");
	pb.addString("tab.output",DIRECTORY_OUT + "db.out.tab");
	jobLauncher.run(job, pb.toJobParameters());
}
 
开发者ID:MIABIS,项目名称:miabis-converter,代码行数:14,代码来源:JobFilesDBTabTest.java

示例14: generateFeatures

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@GET
@Path("/generate/{sourceKey}/{id}")
@Produces(MediaType.APPLICATION_JSON)
public JobExecutionResource generateFeatures(@PathParam("id") final int id, @PathParam("sourceKey") final String sourceKey) {
	Source source = getSourceRepository().findBySourceKey(sourceKey);
	String cdmTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.CDM);
	String resultsTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results);

	DefaultTransactionDefinition requresNewTx = new DefaultTransactionDefinition();
	requresNewTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
	TransactionStatus initStatus = this.getTransactionTemplate().getTransactionManager().getTransaction(requresNewTx);

	this.getTransactionTemplate().getTransactionManager().commit(initStatus);
	JobParametersBuilder builder = new JobParametersBuilder();
	builder.addString("jobName", "generating features for cohort " + id + " : " + source.getSourceName()
		+ " (" + source.getSourceKey() + ")");
	builder.addString("cdm_database_schema", cdmTableQualifier);
	builder.addString("results_database_schema", resultsTableQualifier);
	builder.addString("target_dialect", source.getSourceDialect());
	builder.addString("cohort_definition_id", ("" + id));
	builder.addString("source_id", ("" + source.getSourceId()));

	final JobParameters jobParameters = builder.toJobParameters();

	log.info(String.format("Beginning generate cohort features for cohort definition id: \n %s", "" + id));

	GenerateCohortFeaturesTasklet generateCohortFeaturesTasklet
		= new GenerateCohortFeaturesTasklet(getSourceJdbcTemplate(source), getTransactionTemplate());

	Step generateCohortFeaturesStep = stepBuilders.get("cohortFeatures.generateFeatures")
		.tasklet(generateCohortFeaturesTasklet)
		.build();

	Job generateCohortFeaturesJob = jobBuilders.get("generateFeatures")
		.start(generateCohortFeaturesStep)
		.build();

	JobExecutionResource jobExec = this.jobTemplate.launch(generateCohortFeaturesJob, jobParameters);
	return jobExec;
}
 
开发者ID:OHDSI,项目名称:WebAPI,代码行数:41,代码来源:FeatureExtractionService.java

示例15: convert

import org.springframework.batch.core.JobParametersBuilder; //导入方法依赖的package包/类
@Override
public JobParameters convert(final JsonNode root) {
	final JobParametersBuilder builder = new JobParametersBuilder();

	final Iterator<String> it = root.fieldNames();
	while (it.hasNext()) {
		final String paramName = it.next();
		final JsonNode param = root.get(paramName);
		final ParameterType type = ParameterType.valueOf(param.get("type").textValue());

		final JsonNode value = param.get("value");
		final boolean identifying = param.get("identifying").booleanValue();

		switch (type) {
		case STRING:
			builder.addString(paramName, value.textValue(), identifying);
			break;
		case DATE:
			builder.addDate(paramName, new Date(value.longValue()), identifying);
			break;
		case DOUBLE:
			builder.addDouble(paramName, value.doubleValue(), identifying);
			break;
		case LONG:
			builder.addLong(paramName, value.longValue(), identifying);
			break;
		default:
			throw new IllegalArgumentException("Unknown job parameter type: " + type);
		}
	}

	return builder.toJobParameters();
}
 
开发者ID:phjardas,项目名称:spring-batch-tools,代码行数:34,代码来源:BatchJacksonModule.java


注:本文中的org.springframework.batch.core.JobParametersBuilder.addString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。