Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobInstance


   */
  @Test
  public void testGetJobExecutionsForJobInstance() throws Exception {
    String jobName = "job";
    Long jobInstanceId = 12L;
    JobInstance jobInstance = MetaDataInstanceFactory.createJobInstance(jobName, jobInstanceId);
    EasyMock.expect(jobLocator.getJobNames()).andReturn(Collections.<String> emptyList());
    EasyMock.expect(jobInstanceDao.countJobInstances(jobName)).andReturn(1);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobInstanceId)).andReturn(jobInstance);
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    EasyMock.expect(jobExecutionDao.findJobExecutions(jobInstance)).andReturn(Arrays.asList(jobExecution));
    stepExecutionDao.addStepExecutions(jobExecution);
    EasyMock.expectLastCall();
    EasyMock.replay(jobLocator, jobInstanceDao, stepExecutionDao, jobExecutionDao);
    assertEquals(1, service.getJobExecutionsForJobInstance("job", jobInstance.getId()).size());
    EasyMock.verify(jobLocator, jobInstanceDao, stepExecutionDao, jobExecutionDao);
  }
View Full Code Here


    this.jobId = jobExecution.getJobId();
    this.stepExecutionCount = jobExecution.getStepExecutions().size();
    this.jobParameters = converter.getProperties(jobExecution.getJobParameters());
    this.jobParametersString = new JobParametersExtractor().fromJobParameters(jobExecution.getJobParameters());

    JobInstance jobInstance = jobExecution.getJobInstance();
    if (jobInstance != null) {
      this.jobName = jobInstance.getJobName();
      BatchStatus status = jobExecution.getStatus();
      this.restartable = status.isGreaterThan(BatchStatus.STOPPING) && status.isLessThan(BatchStatus.ABANDONED);
      this.abandonable = status.isGreaterThan(BatchStatus.STARTED) && status!=BatchStatus.ABANDONED;
      this.stoppable  = status.isLessThan(BatchStatus.STOPPING);
    }
View Full Code Here

  /* (non-Javadoc)
   * @see org.springframework.batch.core.repository.JobRepository#createJobExecution(org.springframework.batch.core.Job, org.springframework.batch.core.JobParameters)
   */
  public JobExecution createJobExecution(String jobName, JobParameters jobParameters)
      throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
    return new JobExecution(new JobInstance(0L, jobName), jobParameters);
  }
View Full Code Here

    AtomicLong jobId = new AtomicLong();

    public JobExecution run(Job job, JobParameters jobParameters){
      jobs.add(job);
      parameters.add(jobParameters);
      return new JobExecution(new JobInstance(jobId.getAndIncrement(), job.getName()), jobParameters);
    }
View Full Code Here

   * @param string
   * @return
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  private GenericMessage<ChunkRequest> getSimpleMessage(String string, Long jobId) {
    StepContribution stepContribution = new JobExecution(new JobInstance(0L, "job"), new JobParameters())
    .createStepExecution("step").createStepContribution();
    ChunkRequest chunk = new ChunkRequest(0, StringUtils.commaDelimitedListToSet(string), jobId, stepContribution);
    GenericMessage<ChunkRequest> message = new GenericMessage<ChunkRequest>(chunk);
    return message;
  }
View Full Code Here

   * @param string
   * @return
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  private GenericMessage<ChunkRequest> getSimpleMessage(String string, Long jobId) {
    StepContribution stepContribution = new JobExecution(new JobInstance(0L, "job"), new JobParameters())
    .createStepExecution("step").createStepContribution();
    ChunkRequest chunk = new ChunkRequest(0, StringUtils.commaDelimitedListToSet(string), jobId, stepContribution);
    GenericMessage<ChunkRequest> message = new GenericMessage<ChunkRequest>(chunk);
    return message;
  }
View Full Code Here

  @Override
  public JobInstance createJobInstance(String jobName, JobParameters jobParameters) {

    Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist");

    JobInstance jobInstance = new JobInstance(currentId.getAndIncrement(), jobName);
    jobInstance.incrementVersion();
    jobInstances.put(jobName + "|" + jobKeyGenerator.generateKey(jobParameters), jobInstance);

    return jobInstance;
  }
View Full Code Here

  }

  @Override
  public JobInstance getJobInstance(Long instanceId) {
    for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
      JobInstance instance = instanceEntry.getValue();
      if (instance.getId().equals(instanceId)) {
        return instance;
      }
    }
    return null;
  }
View Full Code Here

  @Override
  public List<JobInstance> getJobInstances(String jobName, int start, int count) {
    List<JobInstance> result = new ArrayList<JobInstance>();
    for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
      JobInstance instance = instanceEntry.getValue();
      if (instance.getJobName().equals(jobName)) {
        result.add(instance);
      }
    }

    sortDescending(result);
View Full Code Here

  public List<JobInstance> findJobInstancesByName(String jobName, int start, int count) {
    List<JobInstance> result = new ArrayList<JobInstance>();
    String convertedJobName = jobName.replaceAll(STAR_WILDCARD, STAR_WILDCARD_PATTERN);

    for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
      JobInstance instance = instanceEntry.getValue();

      if(instance.getJobName().matches(convertedJobName)) {
        result.add(instance);
      }
    }

    sortDescending(result);
View Full Code Here

TOP

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

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.