OPEN - issue BATCH-371: FlatFileItemWriter no longer uses LineAggregator
http://jira.springframework.org/browse/BATCH-371 Introduce FieldSetUnmapper for symmetry with input
This commit is contained in:
@@ -27,10 +27,7 @@
|
||||
<bean class="org.springframework.batch.sample.item.writer.TradeWriter">
|
||||
<property name="dao" ref="tradeDao" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.batch.item.writer.DelegatingItemWriter">
|
||||
<property name="delegate" ref="flatFileOutputSource" />
|
||||
</bean>
|
||||
<ref bean="flatFileOutputSource" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
@@ -80,6 +77,10 @@
|
||||
|
||||
<bean class="org.springframework.batch.io.file.FlatFileItemWriter" id="flatFileOutputSource">
|
||||
<property name="resource" ref="customerFileLocator" />
|
||||
<property name="fieldSetUnmapper">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="customerFileLocator" class="org.springframework.core.io.FileSystemResource">
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource"
|
||||
value="file:target/test-outputs/20070122.testStream.multilineStep.txt" />
|
||||
<property name="fieldSetUnmapper">
|
||||
<bean class="org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper"/>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
@@ -1,31 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
|
||||
|
||||
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.FlatFileItemReader"
|
||||
scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource" ref="fileInputLocator" />
|
||||
<property name="lineTokenizer" ref="orderFileDescriptor" />
|
||||
<property name="fieldSetMapper">
|
||||
<bean class="org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="flatFileOutputSource" class="org.springframework.batch.io.file.FlatFileItemWriter"
|
||||
scope="step" >
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource" ref="fileOutputLocator" />
|
||||
</bean>
|
||||
|
||||
<bean id="delimitedLineAggregator" class="org.springframework.batch.io.file.transform.DelimitedLineTokenizer" />
|
||||
|
||||
<bean id="fixedLineAggregator" class="org.springframework.batch.io.file.transform.FixedLengthLineAggregator" />
|
||||
|
||||
<bean id="fileInputTemplate"
|
||||
class="org.springframework.batch.io.file.FlatFileItemReader"
|
||||
scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource" ref="fileInputLocator" />
|
||||
<property name="lineTokenizer" ref="orderFileDescriptor" />
|
||||
<property name="fieldSetMapper">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="flatFileOutputSource"
|
||||
class="org.springframework.batch.item.writer.ItemTransformerItemWriter">
|
||||
<property name="delegate">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.FlatFileItemWriter"
|
||||
scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource" ref="fileOutputLocator" />
|
||||
<property name="fieldSetUnmapper">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="itemTransformer">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.transform.RecursiveCollectionItemTransformer" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="delimitedLineAggregator"
|
||||
class="org.springframework.batch.io.file.transform.DelimitedLineTokenizer" />
|
||||
|
||||
<bean id="fixedLineAggregator"
|
||||
class="org.springframework.batch.io.file.transform.FixedLengthLineAggregator" />
|
||||
|
||||
</beans>
|
||||
@@ -143,7 +143,4 @@
|
||||
|
||||
<bean parent="customEditorConfigurer"/>
|
||||
|
||||
<!-- register the step scope with the application context -->
|
||||
<bean class="org.springframework.batch.execution.scope.StepScope" />
|
||||
|
||||
</beans>
|
||||
@@ -1,64 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
|
||||
|
||||
|
||||
<bean class="org.springframework.batch.sample.dao.JdbcTradeDao"
|
||||
id="tradeDao" p:jdbcTemplate-ref="jdbcTemplate">
|
||||
<property name="incrementer">
|
||||
<bean parent="incrementerParent">
|
||||
<property name="incrementerName" value="TRADE_SEQ" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.JdbcCustomerDebitWriter"
|
||||
id="customerDao" p:jdbcTemplate-ref="jdbcTemplate" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.FlatFileCustomerCreditWriter"
|
||||
id="customerReportOutputSource" scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="outputSource">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.FlatFileItemWriter"
|
||||
id="customerFlatFileOutputSource">
|
||||
<property name="resource" ref="customerFileLocator" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.FlatFileItemReader"
|
||||
id="fileInputTemplate" scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource" ref="fileLocator" />
|
||||
<property name="lineTokenizer" ref="tradeFileDescriptor" />
|
||||
<property name="fieldSetMapper">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="tradeFileDescriptor"
|
||||
class="org.springframework.batch.io.file.transform.DelimitedLineTokenizer">
|
||||
<property name="names" value="ISIN, Quantity, Price, Customer" />
|
||||
</bean>
|
||||
|
||||
<bean id="tradeValidator"
|
||||
class="org.springframework.batch.item.validator.SpringValidator">
|
||||
<property name="validator">
|
||||
<bean
|
||||
class="org.springmodules.validation.valang.ValangValidator">
|
||||
<property name="valang">
|
||||
<value>
|
||||
<bean class="org.springframework.batch.sample.dao.JdbcTradeDao"
|
||||
id="tradeDao" p:jdbcTemplate-ref="jdbcTemplate">
|
||||
<property name="incrementer">
|
||||
<bean parent="incrementerParent">
|
||||
<property name="incrementerName" value="TRADE_SEQ" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.JdbcCustomerDebitWriter"
|
||||
id="customerDao" p:jdbcTemplate-ref="jdbcTemplate" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.batch.sample.dao.FlatFileCustomerCreditWriter"
|
||||
id="customerReportOutputSource" scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="outputSource">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.FlatFileItemWriter"
|
||||
id="customerFlatFileOutputSource">
|
||||
<property name="resource" ref="customerFileLocator" />
|
||||
<property name="fieldSetUnmapper">
|
||||
<bean
|
||||
class="org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.batch.io.file.FlatFileItemReader"
|
||||
id="fileInputTemplate" scope="step">
|
||||
<aop:scoped-proxy />
|
||||
<property name="resource" ref="fileLocator" />
|
||||
<property name="lineTokenizer" ref="tradeFileDescriptor" />
|
||||
<property name="fieldSetMapper">
|
||||
<bean
|
||||
class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="tradeFileDescriptor"
|
||||
class="org.springframework.batch.io.file.transform.DelimitedLineTokenizer">
|
||||
<property name="names" value="ISIN, Quantity, Price, Customer" />
|
||||
</bean>
|
||||
|
||||
<bean id="tradeValidator"
|
||||
class="org.springframework.batch.item.validator.SpringValidator">
|
||||
<property name="validator">
|
||||
<bean
|
||||
class="org.springmodules.validation.valang.ValangValidator">
|
||||
<property name="valang">
|
||||
<value>
|
||||
<![CDATA[
|
||||
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
|
||||
]]>
|
||||
|
||||
@@ -23,11 +23,10 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
public class MultilineJobFunctionalTests extends AbstractValidatingBatchLauncherTests {
|
||||
|
||||
// TODO: make the output group together in two lines, instead of all the
|
||||
// trades coming out on a single line (it's the recursive transform call in
|
||||
// FlatFileItemWriter).
|
||||
private static final String EXPECTED_RESULT = "Trade: [isin=UK21341EAH45,quantity=978,price=98.34,customer=customer1]Trade: [isin=UK21341EAH46,quantity=112,price=18.12,customer=customer2]"
|
||||
+ "Trade: [isin=UK21341EAH47,quantity=245,price=12.78,customer=customer2]Trade: [isin=UK21341EAH48,quantity=108,price=9.25,customer=customer3]Trade: [isin=UK21341EAH49,quantity=854,price=23.39,customer=customer4]";
|
||||
// The output is grouped together in two lines, instead of all the
|
||||
// trades coming out on a single line.
|
||||
private static final String EXPECTED_RESULT = "[Trade: [isin=UK21341EAH45,quantity=978,price=98.34,customer=customer1], Trade: [isin=UK21341EAH46,quantity=112,price=18.12,customer=customer2]]"
|
||||
+ "[Trade: [isin=UK21341EAH47,quantity=245,price=12.78,customer=customer2], Trade: [isin=UK21341EAH48,quantity=108,price=9.25,customer=customer3], Trade: [isin=UK21341EAH49,quantity=854,price=23.39,customer=customer4]]";
|
||||
|
||||
private Resource output = new FileSystemResource("target/test-outputs/20070122.testStream.multilineStep.txt");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user