Merge pull request #137 from spring-projects/spring-batch-excel-to-batch-51
Upgrade to Spring Batch 5.1
This commit is contained in:
@@ -42,16 +42,16 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<java.version>1.8</java.version>
|
<java.version>17</java.version>
|
||||||
|
|
||||||
<spring.batch.version>4.3.9</spring.batch.version>
|
<spring.batch.version>5.1.2</spring.batch.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>5.3.0</poi.version>
|
||||||
|
|
||||||
<!-- Test Dependencies -->
|
<!-- Test Dependencies -->
|
||||||
<assertj.version>3.18.1</assertj.version>
|
<assertj.version>3.26.3</assertj.version>
|
||||||
<junit.jupiter.version>5.8.2</junit.jupiter.version>
|
<junit.jupiter.version>5.10.2</junit.jupiter.version>
|
||||||
<slf4j.version>1.7.36</slf4j.version>
|
<slf4j.version>1.7.36</slf4j.version>
|
||||||
<mockito.version>3.12.4</mockito.version>
|
<mockito.version>5.12.0</mockito.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public abstract class AbstractExcelItemReader<T> extends AbstractItemCountingIte
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void jumpToItem(final int itemIndex) {
|
protected void jumpToItem(final int itemIndex) {
|
||||||
RowMapper<T> current = this.rowMapper;
|
var current = this.rowMapper;
|
||||||
this.rowMapper = (rs) -> null;
|
this.rowMapper = (rs) -> null;
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < itemIndex; i++) {
|
for (int i = 0; i < itemIndex; i++) {
|
||||||
@@ -145,8 +145,8 @@ public abstract class AbstractExcelItemReader<T> extends AbstractItemCountingIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInvalidValidRow(RowSet rs) {
|
private boolean isInvalidValidRow(RowSet rs) {
|
||||||
for (String str : rs.getCurrentRow()) {
|
for (var str : rs.getCurrentRow()) {
|
||||||
if (str.length() > 0) {
|
if (!str.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ public abstract class AbstractExcelItemReader<T> extends AbstractItemCountingIte
|
|||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() {
|
||||||
Assert.notNull(this.rowMapper, "RowMapper must be set");
|
Assert.notNull(this.rowMapper, "RowMapper must be set");
|
||||||
if (this.datesAsIso) {
|
if (this.datesAsIso) {
|
||||||
this.dataFormatter = (this.userLocale != null) ? new IsoFormattingDateDataFormatter(this.userLocale) : new IsoFormattingDateDataFormatter();
|
this.dataFormatter = (this.userLocale != null) ? new IsoFormattingDateDataFormatter(this.userLocale) : new IsoFormattingDateDataFormatter();
|
||||||
|
|||||||
@@ -140,11 +140,10 @@ public class BeanWrapperRowMapper<T> extends DefaultPropertyEditorRegistrar
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that precisely one of type or prototype bean name is specified.
|
* Check that precisely one of type or prototype bean name is specified.
|
||||||
* @throws IllegalStateException if neither is set or both properties are set.
|
|
||||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() {
|
||||||
Assert.state(this.name != null || this.type != null, "Either name or type must be provided.");
|
Assert.state(this.name != null || this.type != null, "Either name or type must be provided.");
|
||||||
Assert.state(this.name == null || this.type == null, "Both name and type cannot be specified together.");
|
Assert.state(this.name == null || this.type == null, "Both name and type cannot be specified together.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import org.springframework.batch.extensions.excel.support.rowset.RowSet;
|
|||||||
public class PassThroughRowMapper implements RowMapper<String[]> {
|
public class PassThroughRowMapper implements RowMapper<String[]> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] mapRow(final RowSet rs) throws Exception {
|
public String[] mapRow(final RowSet rs) {
|
||||||
return rs.getCurrentRow();
|
return rs.getCurrentRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,10 +100,10 @@ final class PropertyMatches {
|
|||||||
* @return the distance value
|
* @return the distance value
|
||||||
*/
|
*/
|
||||||
private int calculateStringDistance(String s1, String s2) {
|
private int calculateStringDistance(String s1, String s2) {
|
||||||
if (s1.length() == 0) {
|
if (s1.isEmpty()) {
|
||||||
return s2.length();
|
return s2.length();
|
||||||
}
|
}
|
||||||
if (s2.length() == 0) {
|
if (s2.isEmpty()) {
|
||||||
return s1.length();
|
return s1.length();
|
||||||
}
|
}
|
||||||
int[][] d = new int[s1.length() + 1][s2.length() + 1];
|
int[][] d = new int[s1.length() + 1][s2.length() + 1];
|
||||||
|
|||||||
@@ -50,12 +50,12 @@ public class MockExcelItemReader<T> extends AbstractExcelItemReader<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void openExcelFile(Resource resource, String password) throws Exception {
|
protected void openExcelFile(Resource resource, String password) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doClose() throws Exception {
|
protected void doClose() {
|
||||||
this.sheets.clear();
|
this.sheets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user