Resolved some TODOs. Changed signature of StepDao to use entity instead of ID.

This commit is contained in:
dsyer
2008-01-28 13:17:56 +00:00
parent 2e84c5a900
commit d173f0c022
9 changed files with 21 additions and 23 deletions

View File

@@ -322,7 +322,7 @@ public class SimpleJobRepository implements JobRepository {
StepInstance step = stepDao.findStep(job, stepConfiguration.getName());
if (step != null) {
step.setStepExecutionCount(stepDao.getStepExecutionCount(step.getId()));
step.setStepExecutionCount(stepDao.getStepExecutionCount(step));
// Ensure valid restart data is being returned.
if (step.getRestartData() == null || step.getRestartData().getProperties() == null) {
step.setRestartData(new GenericRestartData(new Properties()));

View File

@@ -276,9 +276,9 @@ public class JdbcStepDao implements StepDao, InitializingBean {
return getQuery(SAVE_STEP_EXECUTION);
}
public int getStepExecutionCount(Long stepId) {
public int getStepExecutionCount(StepInstance step) {
Object[] parameters = new Object[] { stepId };
Object[] parameters = new Object[] { step.getId() };
return jdbcTemplate.queryForInt(getStepExecutionCountQuery(), parameters);
}

View File

@@ -84,8 +84,8 @@ public class MapStepDao implements StepDao {
return (RestartData) restartsById.get(stepId);
}
public int getStepExecutionCount(Long jobId) {
Set executions = (Set) executionsById.get(jobId);
public int getStepExecutionCount(StepInstance stepInstance) {
Set executions = (Set) executionsById.get(stepInstance.getId());
if (executions==null) return 0;
return executions.size(); }

View File

@@ -90,11 +90,10 @@ public interface StepDao {
/**
* Return the count of StepExecutions with the given StepId.
*
* @param stepId
* @return the number of step executions for this step TODO: change
* signature to search by {@link StepInstance}
* @param step
* @return the number of step executions for this step
*/
public int getStepExecutionCount(Long stepId);
public int getStepExecutionCount(StepInstance step);
/**
* Return all StepExecutions for the given step.

View File

@@ -50,7 +50,7 @@ public class MockStepDao implements StepDao {
return null;
}
public int getStepExecutionCount(Long stepId) {
public int getStepExecutionCount(StepInstance step) {
return 1;
}

View File

@@ -161,11 +161,11 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDaoControl.setReturnValue(jobs);
stepDao.findStep(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.getStepExecutionCount(databaseStep1.getId());
stepDao.getStepExecutionCount(databaseStep1);
stepDaoControl.setReturnValue(1);
stepDao.findStep(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
stepDao.getStepExecutionCount(databaseStep2.getId());
stepDao.getStepExecutionCount(databaseStep2);
stepDaoControl.setReturnValue(1);
stepDaoControl.replay();
jobDao.getJobExecutionCount(databaseJob.getId());
@@ -233,11 +233,11 @@ public class SimpleJobRepositoryTests extends TestCase {
jobDaoControl.setReturnValue(jobs);
stepDao.findStep(databaseJob, "TestStep1");
stepDaoControl.setReturnValue(databaseStep1);
stepDao.getStepExecutionCount(databaseStep1.getId());
stepDao.getStepExecutionCount(databaseStep1);
stepDaoControl.setReturnValue(1);
stepDao.findStep(databaseJob, "TestStep2");
stepDaoControl.setReturnValue(databaseStep2);
stepDao.getStepExecutionCount(databaseStep2.getId());
stepDao.getStepExecutionCount(databaseStep2);
stepDaoControl.setReturnValue(1);
stepDaoControl.replay();
jobDao.getJobExecutionCount(databaseJob.getId());
@@ -441,12 +441,12 @@ public class SimpleJobRepositoryTests extends TestCase {
stepDao.findStep(databaseJob, "TestStep1");
databaseStep1.setRestartData(null);
stepDaoControl.setReturnValue(databaseStep1);
stepDao.getStepExecutionCount(databaseStep1.getId());
stepDao.getStepExecutionCount(databaseStep1);
stepDaoControl.setReturnValue(1);
stepDao.findStep(databaseJob, "TestStep2");
databaseStep2.setRestartData(new GenericRestartData(null));
stepDaoControl.setReturnValue(databaseStep2);
stepDao.getStepExecutionCount(databaseStep2.getId());
stepDao.getStepExecutionCount(databaseStep2);
stepDaoControl.setReturnValue(1);
stepDaoControl.replay();
jobDao.getJobExecutionCount(databaseJob.getId());

View File

@@ -207,16 +207,16 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
public void testGetStepExecutionCountForNoExecutions(){
int executionCount = stepDao.getStepExecutionCount(step2.getId());
int executionCount = stepDao.getStepExecutionCount(step2);
assertEquals(executionCount, 0);
}
public void testIncrementStepExecutionCount(){
assertEquals(1, stepDao.getStepExecutionCount(step1.getId()));
assertEquals(1, stepDao.getStepExecutionCount(step1));
StepExecution execution = new StepExecution(step1, new JobExecution(step1.getJobInstance(), new Long(123)), null);
stepDao.save(execution);
assertEquals(2, stepDao.getStepExecutionCount(step1.getId()));
assertEquals(2, stepDao.getStepExecutionCount(step1));
}
public void testUpdateStepExecutionVersion() throws Exception {

View File

@@ -85,7 +85,7 @@ public class MapStepDaoTests extends TestCase {
}
public void testNoExecutionsForNew() throws Exception {
assertEquals(0, dao.getStepExecutionCount(step.getId()));
assertEquals(0, dao.getStepExecutionCount(step));
}
public void testSaveExecutionUpdatesId() throws Exception {
@@ -97,13 +97,13 @@ public class MapStepDaoTests extends TestCase {
public void testCorrectExecutionCountForExisting() throws Exception {
dao.save(new StepExecution(step, null, null));
assertEquals(1, dao.getStepExecutionCount(step.getId()));
assertEquals(1, dao.getStepExecutionCount(step));
}
public void testOnlyOneExecutionPerStep() throws Exception {
dao.save(new StepExecution(step, null, null));
dao.save(new StepExecution(step, null, null));
assertEquals(2, dao.getStepExecutionCount(step.getId()));
assertEquals(2, dao.getStepExecutionCount(step));
}
public void testSaveRestartData() throws Exception {

View File

@@ -160,7 +160,6 @@ public class TaskExecutorRepeatTemplate extends RepeatTemplate {
try {
value = future.getResult();
} catch (InterruptedException e) {
// TODO: cancel batch?
Thread.currentThread().interrupt();
value = e;
}