I need to be able to convert the below CSV into objects.
Is that possible with Bindy?
H,header1,01/01/2012
D,test11,1.00,10.00
D,test12,2.00,20.00
D,test13,3.00,30.00
H,header2,01/02/2012
D,test21,1.00,10.00
D,test22,2.00,20.00
D,test23,3.00,30.00
I have created two models Header and Detail and at the end I want to have a List of:
Header,Detail,Detail,Detail,Header,Detail,Detail,Detail objects.
When I put these models in the same package and run my test it seems like Bindy is not able to recognize which model is which and fails saying:
java.lang.AssertionError: mock://queue.csv Received message count. Expected: <1> but was: <0>
Is this even possible with Bindy?
I actually do not think this is possible out of the box? As you would need a way (discriminator) to determine if a row is a header or a detail. And that is not a function we got right now.
You could though split the data, so there is a single header + number of details. But that would entail having multiple messages in Camel.
However it seems that your structure is fairly simple. So just use some good old fashioned Java code often does the trick.
However the Apache Camel project love contributions, so feel free to open a JIRA ticket with this use-case, and then adding a discrimination functionality would be a nice addition. Then it’s also a bit easier to handle CSV records that vary from type to type.
http://camel.apache.org/contributing.html