Make a SimpleJobIdentifierFactory for SimpleJobIdentifiers

OPEN - issue BATCH-58: Make JobStream and JobRun optional properties of Job (e.g. through join to optional table) 
http://opensource.atlassian.com/projects/spring/browse/BATCH-58
This commit is contained in:
dsyer
2007-08-23 19:46:38 +00:00
parent f19379e27b
commit 1ffd47a9b2
3 changed files with 82 additions and 43 deletions

View File

@@ -0,0 +1,40 @@
package org.springframework.batch.execution.repository.dao;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.runtime.JobIdentifier;
/**
* Shared utility class for {@link JobDao} implementations to allow a
* {@link JobInstance} to be identified from its {@link JobIdentifier}.
*
* @author Dave Syer
*
*/
class JobInstanceFilter {
/**
* Filter the list and pull out a {@link JobInstance} with the supplied
* identifier.
*
* @param instances
* a collection of {@link JobInstance}
* @param identifier
* the required {@link JobIdentifier}
* @return another collection of {@link JobInstance}, all matching the the
* given {@link JobIdentifier}
*/
public List filter(List instances, JobIdentifier identifier) {
List result = new ArrayList();
for (Iterator iterator = instances.iterator(); iterator.hasNext();) {
JobInstance job = (JobInstance) iterator.next();
if (job.getIdentifier().equals(identifier)) {
result.add(job);
}
}
return result;
}
}