Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Alter the fieldset value

  1. #1
    Join Date
    Apr 2008
    Posts
    28

    Question Alter the fieldset value

    Hi,

    I want to read from a file and checks some conditions on record and do some changes on few fields then after write to database.
    Do to this, first I thought read record and do the verification of conditions and alteration of field values on FieldSet then write to database. But the implemetation class for FieldSet is provided by frame work. So I cant do that.
    Please guide me to solve this issue.

    Thanks in advance,
    Shahul

  2. #2

    Default

    There is a related issue: http://jira.springframework.org/browse/BATCH-394

    Currently you'll need to create new modified FieldSet instance rather than change values in the original instance.

  3. #3
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Couldn't you change some of the fields when you put them into a domain object?

  4. #4
    Join Date
    Apr 2008
    Posts
    28

    Unhappy

    I am not using any specific VO classes, instead we are using map.

    I have two options.
    One is, alter the values just after creating tokens of fields but before creating fieldset. So we can instantiate fieldset with updated values.
    Second one is, extend our DefaultFieldSet class with options to updated the tokens. So we can alter the values just after tokenizing but before the fieldsetmapper.

    Please guide me to take a solution.

    ~Shahul

  5. #5
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    I'm still confused, can't you alter the values when moving them from the fieldset to the map?

  6. #6
    Join Date
    Apr 2008
    Posts
    28

    Default

    Yes Lucas, We can alter the values in map. But I want to segregate that functions with creation of map. Because the alteration is little bit trickier. More of that, according to some values, i need to skip entire record from writing to database. Thats why I am thinking for a better solution.

  7. #7
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    The skip part is easy, just throw an exception, and configure it as skippable. To be honest, I think modifying the values in the map is still your best option. A FieldSet is immutable for good reason, it is purely a transfer mechanism. If you absolutely don't want to do it in the map, put another abstraction between the fieldset and the map, but I would still leave the FieldSet alone.

  8. #8
    Join Date
    Apr 2008
    Posts
    28

    Default

    Thanks Lucas for your valuable suggestion. I will put a abstraction between fieldset and map such that create a new instance of fieldset using updated values in original instance of fieldset.
    I didnt understand to skip record using exception, please guide me.

  9. #9
    Join Date
    Apr 2008
    Posts
    28

    Default

    Lucas,

    I think above method also change the fieldset indirectly by creating new fieldset using updated values. Is it ok? I took the suggestion of Robert. Please guide me.

  10. #10
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Here's the section in the documentation about configuring skip:

    http://static.springframework.org/sp...n.html#d0e3747

    You could use another FieldSet as your abstraction if you like, although it might be a bit overkill depending upon how many fields you need to alter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •