我需要读取flatfile并创建一个TRADE java对象。现在处理器应该基于TRADE java对象创建3个不同的java对象。 我必须将这3个不同的java对象写入3个不同的xml文件。
根据读取的数据,我只想读取3个处理器和3个写入多个xml文件。
我已经尝试过compositeItemWriter,但它会使用相同的对象进行写入。但我有3个不同的对象使用者,信封,deliveryOrder
SampleInput:
11000000001F11000000062237 693553467588549
11000000001221000000030237 628525475867698
11000000031110000000562374 687598787668557
11000000001G21000000056237 687557575645346
11000000001F11000000062237 693553467588549
11000000001221000000030237 628525475867698
output 1.
<consumers>
<consumer>
<sequenceNum>1481</sequenceNum>
<sourceSystemBrandId>237</sourceSystemBrandId>
<sourceCid>999000367588</sourceCid>
<preferences>
<preference>
<contentType>Statement</contentType>
<value>E</value>
<distributionChannel>test@gmail.com</distributionChannel>
</preference>
</preferences>
<deliveryPoints>
<dpvDeliveryPoint>
<dpv>1171783651</dpv>
</dpvDeliveryPoint>
<emailDeliveryPoint>
<email>test@gmail.com</email>
</emailDeliveryPoint>
</deliveryPoints>
</consumer>
</consumers>
output 2:
<envelopes>
<envelope>
<sourceEnvId>xxxx</sourceEnvId>
<sourceSystemBrandId>xxx</sourceSystemBrandId>
<sourceCid>xxx</sourceCid>
<envelopeData>
<envelopeName>xxx</envelopeName>
<contentType>statement</contentType>
<statementData>
<accountNumber>xxx</accountNumber>
<accountName>xxx</accountName>
<statementAmount/>
<periodStartDate/>
<periodEndDate/>
<date>2017-09-04</date>
</statementData>
<details><detail><name>Class_Email</name><value>xxx</value><type>xxx</type>
</detail></details>
<envelopeDocuments>
<envelopeDocument><docRef>Benhe</docRef></envelopeDocument>
</envelopeDocuments>
<printSuppressed>YES</printSuppressed>
<historicalMail>NO</historicalMail>
<asOfDate>2017-09-04</asOfDate>
</envelopeData>
</envelope>
</envelopes>
output 3:
<deliveryOrder>
<consumer>
<preferences>
<!--1 or more repetitions:-->
<preference>
<contentType>string</contentType>
<value>string</value>
<!--Optional:-->
<effectiveDate>2006-08-19T19:27:14+02:00</effectiveDate>
</preference>
</preferences>
<!--Optional:-->
<details>
<detail>
<name>string</name>
<value>string</value>
</detail>
<detail>
<name>string</name>
<value>string</value>
</detail>
<detail>
<name>string</name>
<value>string</value>
</detail>
</details>
<deliveryPoints>
<unstructuredNameDeliveryPoint>
<name>string</name>
</unstructuredNameDeliveryPoint>
</deliveryPoints>
</consumer>
<envelopeDocuments>
<envelopeDocument>
<docRef>string</docRef>
<docFingerprint>string</docFingerprint>
</envelopeDocument>
</envelopeDocuments>
<printSuppressed>NO</printSuppressed>
<historicalMail>Yes</historicalMail>
<asOfDate>2005-09-12+02:00</asOfDate>
</envelopeData>undefined</deliveryOrder>
感谢您的任何帮助。 谢谢。
答案 0 :(得分:0)
您与url
关系密切。但是,根据您所描述的内容CompositeItemWriter
,有一个更好的选择。这个ClassifierCompositeItemWriter
实现允许您注入一个ItemWriter
,您可以选择该Classifier
来选择您的对象最终开始传递到哪个ItemWriter
。实际上,我们甚至提供了一个对您有用的Classifier
实现,SubclassClassifier
。这会将类的映射作为键,ItemWriter
是值。这将允许您将每个对象类型映射到适当的ItemWriter
。