Generation of differently formatted CSV files based on centrally stored values.

0
I am looking for advice. In my application I register information (oh really). Regularly I need to export the information to several other parties each of which requires a differently formatted csv file as input. As an example: In the application I store numberplate as AA11BB. One party requires a numberplate as AA-11-BB. Another as aa11bb. One party requires gender as 'Man', 'Vrouw' another as 'm', 'v'. I want to prevent separate storage of all different formats. And I want to be able to generate all csv's for all parties with one click. And preferably I want to maintain the different formatdefinitions. How best to approach this?
asked
1 answers
2

Are we talking about the standard CSV button on a datagrid here or your own custom CSV exporter? For the latter it doesn't seem too hard, just implement a formatter based on the party you are sending the information. For the former I think you can't really escape having to save the data in separate helper entities. And then you can add some formatting microflows that fill the data based on the party's specifications.

Add: I'd write the formatter itself in Java to avoid needing to create various helper entities for holding the data, but you could certainly keep the party specifications in an entity. For a quick solution you could just create an entity 'Formatter' with a description field that says which party this is about and with fields such as 'MaleFormat' with value 'm' or a field 'LicensePlateFormat' filled with 'xx-XX-00'. This is of course not the best generic solution and you could go further, entirely defining your own format but if these cases don't get too complex I don't think I would put so much time in it and just handle the definitions in Java (such as 'smaller case x means I should lowercase these characters')

answered