Deprecate redundant methods in JobExplorer/JobInstanceDao APIs
Resolves #4821
This commit is contained in:
@@ -76,7 +76,10 @@ public interface JobExplorer {
|
||||
* @param start The start index of the instances to return.
|
||||
* @param count The maximum number of instances to return.
|
||||
* @return a list of {@link JobInstance} for the requested job name.
|
||||
* @deprecated Since v6.0 and scheduled for removal in v6.2. Use
|
||||
* {@link #getJobInstances(String, int, int)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
List<JobInstance> findJobInstancesByJobName(String jobName, int start, int count);
|
||||
|
||||
/**
|
||||
|
||||
@@ -230,9 +230,14 @@ public class SimpleJobExplorer implements JobExplorer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since v6.0 and scheduled for removal in v6.2. Use
|
||||
* {@link #getJobInstances(String, int, int)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
public List<JobInstance> findJobInstancesByJobName(String jobName, int start, int count) {
|
||||
return jobInstanceDao.findJobInstancesByName(jobName, start, count);
|
||||
return getJobInstances(jobName, start, count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -332,33 +332,14 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since v6.0 and scheduled for removal in v6.2. Use
|
||||
* {@link #getJobInstances(String, int, int)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public List<JobInstance> findJobInstancesByName(String jobName, final int start, final int count) {
|
||||
ResultSetExtractor extractor = new ResultSetExtractor() {
|
||||
private final List<JobInstance> list = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
|
||||
int rowNum = 0;
|
||||
while (rowNum < start && rs.next()) {
|
||||
rowNum++;
|
||||
}
|
||||
while (rowNum < start + count && rs.next()) {
|
||||
RowMapper<JobInstance> rowMapper = new JobInstanceRowMapper();
|
||||
list.add(rowMapper.mapRow(rs, rowNum));
|
||||
rowNum++;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
if (jobName.contains(STAR_WILDCARD)) {
|
||||
jobName = jobName.replaceAll("\\" + STAR_WILDCARD, SQL_WILDCARD);
|
||||
}
|
||||
|
||||
return (List<JobInstance>) getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_LIKE_NAME), extractor, jobName);
|
||||
|
||||
return getJobInstances(jobName, start, count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
* Copyright 2006-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -117,7 +117,10 @@ public interface JobInstanceDao {
|
||||
* should begin.
|
||||
* @param count int containing the number of job instances to return.
|
||||
* @return a list of {@link JobInstance} for the job name requested.
|
||||
* @deprecated Since v6.0 and scheduled for removal in v6.2. Use
|
||||
* {@link #getJobInstances(String, int, int)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
List<JobInstance> findJobInstancesByName(String jobName, int start, int count);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2024 the original author or authors.
|
||||
* Copyright 2024-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -143,20 +143,14 @@ public class MongoJobInstanceDao implements JobInstanceDao {
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since v6.0 and scheduled for removal in v6.2. Use
|
||||
* {@link #getJobInstances(String, int, int)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
public List<JobInstance> findJobInstancesByName(String jobName, int start, int count) {
|
||||
Query query = query(where("jobName").alike(Example.of(jobName)));
|
||||
Sort.Order sortOrder = Sort.Order.desc("jobInstanceId");
|
||||
List<org.springframework.batch.core.repository.persistence.JobInstance> jobInstances = this.mongoOperations
|
||||
.find(query.with(Sort.by(sortOrder)),
|
||||
org.springframework.batch.core.repository.persistence.JobInstance.class, COLLECTION_NAME)
|
||||
.stream()
|
||||
.toList();
|
||||
return jobInstances.subList(start, jobInstances.size())
|
||||
.stream()
|
||||
.map(this.jobInstanceConverter::toJobInstance)
|
||||
.limit(count)
|
||||
.toList();
|
||||
return getJobInstances(jobName, start, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user