Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobParametersBuilder


    @Test
    public void testCreateAndFind() throws Exception {

        job.setRestartable(true);

        JobParametersBuilder builder = new JobParametersBuilder();
        builder.addString("stringKey", "stringValue").addLong("longKey", 1L).addDouble("doubleKey", 1.1).addDate(
                "dateKey", new Date(1L));
        JobParameters jobParams = builder.toJobParameters();

        JobExecution firstExecution = jobRepository.createJobExecution(job.getName(), jobParams);
        firstExecution.setStartTime(new Date());
        assertNotNull(firstExecution.getLastUpdated());
View Full Code Here


  @Test
  public void basicExecution() throws Exception {
    runner.executeJob(job, new JobParameters());
    assertEquals(1, jobExplorer.getJobInstances("job", 0, 100).size());
    runner.executeJob(job, new JobParametersBuilder().addLong("id", 1L).toJobParameters());
    assertEquals(2, jobExplorer.getJobInstances("job", 0, 100).size());
  }
View Full Code Here

      @Override
      public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        throw new RuntimeException("Planned");
      }
    }).build()).incrementer(new RunIdIncrementer()).build();
    JobParameters jobParameters = new JobParametersBuilder().addLong("id", 1L, false).toJobParameters();
    runner.executeJob(job, jobParameters);
    runner.executeJob(job, jobParameters);
    assertEquals(1, jobExplorer.getJobInstances("job", 0, 100).size());
  }
View Full Code Here

        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
        exchange.getOut().setBody(jobExecution);
    }

    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);
            }
        }
        return parametersBuilder.toJobParameters();
    }
View Full Code Here

  @Autowired
  private JobLocator jobLocator;

  @Transformer
  public Message<JobLaunchRequest> transform(Message<String> pidMessage) {
    JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
    jobParametersBuilder.addString(JOB_PARAM_PID_KEY,
        pidMessage.getPayload());
    JobParameters jobParameters = jobParametersBuilder.toJobParameters();

    Job job = null;
    try {
      job = jobLocator.getJob("generateDerivatives");
    } catch (NoSuchJobException e) {
View Full Code Here

  @Override
  public void write(List<? extends String> pids) throws Exception {
    Job derivativeGenerationJob = jobLocator.getJob("generateDerivatives");

    for (String pid : pids) {
      JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
      jobParametersBuilder.addString(JOB_PARAM_PID_KEY, pid);
      JobParameters jobParameters = jobParametersBuilder
          .toJobParameters();
      jobLauncher.run(derivativeGenerationJob, jobParameters);
    }
  }
View Full Code Here

    if (uri == null || uri.equals("")) {
      throw new IllegalArgumentException("Message must contain URI");
    }

    JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
    jobParametersBuilder.addString("GUID", guid);
    jobParametersBuilder.addString("URI", uri);
    JobParameters jobParameters = jobParametersBuilder.toJobParameters();
   
    Job job = null;
    try {
      job = jobLocator.getJob("batchIngestJob");
    } catch (NoSuchJobException e) {
View Full Code Here

  @Autowired
  private JobLocator jobLocator;

  @Transformer
  public Message<JobLaunchRequest> transform(Message<Sip> sipMessage) {
    JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
    jobParametersBuilder.addString(Sip.JOB_PARAM_GUID_KEY, sipMessage
        .getPayload().getGuid());
    jobParametersBuilder.addString(Sip.JOB_PARAM_URI_KEY, sipMessage
        .getPayload().getURI().toString());
    JobParameters jobParameters = jobParametersBuilder.toJobParameters();
   
    logger.info("Transforming job launch request {} / {}",
        sipMessage.getPayload().getGuid(),
        sipMessage.getPayload().getURI().toString()
        );
View Full Code Here

    if (uri == null || uri.equals("")) {
      throw new IllegalArgumentException("Message must contain URI");
    }

    JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
    jobParametersBuilder.addString("GUID", guid);
    jobParametersBuilder.addString("URI", uri);
    JobParameters jobParameters = jobParametersBuilder.toJobParameters();
   
    Job job = null;
    try {
      job = jobLocator.getJob("batchIngestJob");
    } catch (NoSuchJobException e) {
View Full Code Here

  public void testWithinJob() throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/org/springframework/data/hadoop/fs/HdfsItemWriterTest-context.xml");
    JobLauncher launcher = context.getBean(JobLauncher.class);
    Job job = context.getBean(Job.class);

    JobParameters jobParameters = new JobParametersBuilder().toJobParameters();

    JobExecution execution = launcher.run(job, jobParameters);
    assertTrue("status was: " + execution.getStatus(), execution.getStatus() == BatchStatus.COMPLETED);
    context.close();
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.JobParametersBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.