Charles,

I don't think this feature is currently supported by Camel, but it would sure make a nice addition. Could you open a JIRA for it?

Gert

cmoulliard wrote:
Hi,

I would like to know if someone has an example showing how to map the
content of a CSV file to a POJO using inside this POJO class @annotation ?
For the moment, I use ArrayList + iterator (see code hereafter) to achieve
the extraction of the content but I'm sure that I can simplify my code using
@Annotation E.g. :
Camel route

from("file:///c:/temp/test?noop=true")
.unmarshal().csv()
.to("bean:converter?methodName=TransformMessage");

Converter class

        public void TransformMessage(Exchange in) {
                process(in.getIn().getBody(List.class));
        }

        @SuppressWarnings("unchecked")
        private void process(List messages) {
                
                // Iterate through the list of messages
                for (Iterator<ArrayList> it = messages.iterator(); 
it.hasNext();) {

                        // Split the content of the message into field
                        message = it.next();
                        field = (String[]) message.toArray();

                        order = new Order();
                        order.setId(Integer.valueOf(field[0]).intValue());
                        order.setBank(field[1]);
                        order.setAmountFrom(Double.parseDouble(field[2]));
                        order.setAmountTo(Double.parseDouble(field[3]));
                        order.setOrderInstruction(field[4].trim());
                        this.orderService.createOrder(order);

                }
        }

Regards,

Charles

Reply via email to