Issue Details (XML | Word | Printable)

Key: BATCH-278
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Robert Kasanicky
Reporter: Fabian Krämer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Batch

Allow FixedLengthLineAggregator to be configured with different padding/alignment for specific columns

Created: 11/Jan/08 05:21 AM   Updated: 23/Sep/08 02:37 PM
Component/s: Infrastructure
Affects Version/s: 1.0-m3
Fix Version/s: 2.0.0.M1

Time Tracking:
Original Estimate: 1d
Original Estimate - 1d
Remaining Estimate: 0d
Time Spent - 0.75d
Time Spent: 0.75d
Time Spent - 0.75d Time Not Required

File Attachments: 1. Text File batch-278-unittest-v2.patch (6 kB)
2. Text File batch-278-unittest.patch (6 kB)
3. Text File batch-278-unittest.patch (6 kB)
4. Text File batch-278-v2.patch (9 kB)
5. Text File batch-278.patch (9 kB)
6. Text File batch-278.patch (8 kB)



 Description  « Hide
I'm currently evaluating if Spring Batch needs our requirements and what I do have to write on my own. We have a customer who needs to have an output format similar with the following example. I simplified the format to present the two important columns, first is a lastName and second is a memberId. The lastName should be aligned left with padding space, the memberId should be aligned right with padding zero.

E.g. (range is 1-13,13-23):
Wood 000123456789
Cinque 123456789012

Do you have any plans to upgrade the FixedLengthLineAggregator or a subclass with such functionality, column specific padding/alignment?




 All   Comments   Work Log   Change History   FishEye   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Dave Syer added a comment - 11/Jan/08 12:27 PM
It wouldn't be a big change, but it wasn't planned. We use JIRA for planning, so this ticket can now be folded into a plan (it probably won't be in 1.0, but maybe a point release 1.0.1, unless someone contributes some code).

Douglas C. Kaminsky added a comment - 14/Mar/08 02:08 PM
Been sitting on this one for awhile...

Attached a modification that preserves the original behavior (with slight rename of setters to "setDefaultXXX" instead of "setXXX") and adds the ability to inject maps from FieldSet name to align / padding -- or, in the case where your field set does not have a name, allows you to address your ranges by index (e.g. 0 = first range, 1 = second range, etc.). The added logic does not seem to have a noticable performance impact. Hope this solves the issue adequately.

Douglas C. Kaminsky added a comment - 14/Mar/08 06:05 PM
Updated attachments to allow for values in padding map to be non-character - new behavior converts to string and asserts that length is 1, then converts to character - added a regression condition test to one of the test cases

Douglas C. Kaminsky added a comment - 14/Mar/08 06:07 PM
Sorry, last upload named the files the same so they're indistinguishable by name alone - use the attached "v2" versions. I don't have rights so please delete the duplicates.

Ben Hale added a comment - 20/Mar/08 04:29 AM
We should follow a system like the logback formatting scheme:

http://logback.qos.ch/manual/layouts.html

See format modifiers

Lucas Ward added a comment - 03/Jun/08 05:33 PM
I raised the priority on this, as I think it absolutely needs to be done for 1.1

Dave Syer added a comment - 06/Jun/08 06:54 AM
I'm not sure what we can do in 1.1. The FieldSet is created by the application, not the framework, so all the conversion and formatting has already been done before we get any data to write out in the aggregator. So the FieldSetCreator should handle zero padding of numbers (the aggregator can't tell the difference between field types). It's sort of uncomfortable because it seems like the file output concerns should be more separate from the object mapping concerns, but they aren't. This is basically because of our design of the LineAggregator using FieldSet and FieldSetCreator. I can't see a good way to fix this without redesigning the aggregation and conversion, so I would prefer to leave it for now.

The workaround shouldn't be too painful in 1.x - you (the application programmer) just have to know the width of the numeric columns so you can add the zero padding in the FieldSetCreator.

Dave Syer added a comment - 07/Aug/08 07:45 AM
The original requested feature is now available through the FormatterLineAggregator (a replacement for FixedLengthLineAggregator).

Dave Syer added a comment - 07/Aug/08 08:56 AM
Assigned for review