IN PROGRESS - issue BATCH-340: Refactor JobRepository for greater clarity and consistency.

http://jira.springframework.org/browse/BATCH-340

more StepInstance heritage cleaned up - StepExecution refers to Step rather than stepName string
This commit is contained in:
robokaso
2008-02-25 17:21:46 +00:00
parent 59f884b832
commit 7368aa3541
25 changed files with 162 additions and 139 deletions

View File

@@ -143,8 +143,8 @@ public class JobExecution extends Entity {
*
* @param stepExecution
*/
public StepExecution createStepExecution(String stepName) {
StepExecution stepExecution = new StepExecution(stepName, this, null);
public StepExecution createStepExecution(Step step) {
StepExecution stepExecution = new StepExecution(step, this, null);
this.stepExecutions.add(stepExecution);
return stepExecution;
}

View File

@@ -20,6 +20,7 @@ import java.util.Date;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.util.Assert;
/**
* Batch domain object representation the execution of a step. Unlike
@@ -37,7 +38,7 @@ public class StepExecution extends Entity {
private JobExecution jobExecution;
private String stepName;
private Step step;
private BatchStatus status = BatchStatus.STARTING;
@@ -75,9 +76,10 @@ public class StepExecution extends Entity {
* @param jobExecution the current job execution
* @param id the id of this execution
*/
public StepExecution(String stepName, JobExecution jobExecution, Long id) {
public StepExecution(Step step, JobExecution jobExecution, Long id) {
super(id);
this.stepName = stepName;
Assert.notNull(step);
this.step = step;
this.jobExecution = jobExecution;
}
@@ -87,8 +89,8 @@ public class StepExecution extends Entity {
* @param step the step to which this execution belongs
* @param jobExecution the current job execution
*/
public StepExecution(String stepName, JobExecution jobExecution) {
this(stepName, jobExecution, null);
public StepExecution(Step step, JobExecution jobExecution) {
this(step, jobExecution, null);
}
/**
@@ -235,7 +237,7 @@ public class StepExecution extends Entity {
* @return the name of the step
*/
public String getStepName() {
return stepName;
return step.getName();
}
/**
@@ -258,14 +260,14 @@ public class StepExecution extends Entity {
public boolean equals(Object obj) {
//TODO make sure the equality makes sense
Object jobExecutionId = getJobExecutionId();
if (stepName == null && jobExecutionId == null || !(obj instanceof StepExecution) || getId() == null) {
if (step == null && jobExecutionId == null || !(obj instanceof StepExecution) || getId() == null) {
return super.equals(obj);
}
StepExecution other = (StepExecution) obj;
if (stepName == null) {
if (step == null) {
return jobExecutionId.equals(other.getJobExecutionId());
}
return stepName.equals(other.getStepName())
return step.getName().equals(other.getStepName())
&& (jobExecutionId == null || jobExecutionId.equals(other.getJobExecutionId()));
}
@@ -276,12 +278,12 @@ public class StepExecution extends Entity {
*/
public int hashCode() {
Object jobExecutionId = getJobExecutionId();
return super.hashCode() + 31 * (stepName != null ? stepName.hashCode() : 0) + 91
return super.hashCode() + 31 * (step.getName() != null ? step.getName().hashCode() : 0) + 91
* (jobExecutionId != null ? jobExecutionId.hashCode() : 0);
}
public String toString() {
return super.toString() + ", name=" + stepName + ", taskCount=" + taskCount + ", commitCount=" + commitCount
return super.toString() + ", name=" + step.getName() + ", taskCount=" + taskCount + ", commitCount=" + commitCount
+ ", rollbackCount=" + rollbackCount;
}