You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2009/01/15 08:58:59 UTC
[jira] Commented: (CAMEL-398) Map the content of a CSV file to a
POJO using @annotation and .convertBodyTo()
[ https://issues.apache.org/activemq/browse/CAMEL-398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48717#action_48717 ]
Claus Ibsen commented on CAMEL-398:
-----------------------------------
Hi Charles
Nice. I havent had the time to look much into it. This is just some thoughts. Some might already be fixed.
- But could you package it in a sub folder (camel-bindy) so it creates this folder name
- Fix pom.xml to be aligned with the other camel component pom.xml files
- pom.xml dependencies for unit test should have scope test so the runtime dependencies are minimal
- use commons logging for logging
- use a log4j.properties in src/test/resources that is like the other log4j.properties from the other components
- use Apache license header
- remove @author or fix it as @author your name (note: we normally dont have @author in camel code)
You can run unit testing with cobertura to check for gaps
I think the command is:
mvn cobertura:cobertura test
When I get done with my work on the Tracer then I have time to look some more.
And I am sure James would look as well.
> Map the content of a CSV file to a POJO using @annotation and .convertBodyTo()
> ------------------------------------------------------------------------------
>
> Key: CAMEL-398
> URL: https://issues.apache.org/activemq/browse/CAMEL-398
> Project: Apache Camel
> Issue Type: New Feature
> Components: camel-core
> Affects Versions: 1.4.0
> Reporter: Charles Moulliard
> Fix For: 2.0.0
>
> Attachments: Annotation.rar
>
>
> Hi,
> It should be nice if in a next relase of Camel, it will be possible to map the content of a CSV file to a POJO using @annotation.
> For the moment, I use an ArrayList + iterator (see code hereafter) to achieve the extraction of the content but I'm sure that we can simplify this code using @Annotation
> and the following action (.convertBodyTo(Order<List>) by example.
> Current situation
> Camel route
> from("file:///c:/temp/test?noop=true")
> .unmarshal().csv()
> .to("bean:converter?methodName=TransformMessage"); --> should be replaced by something like .convertBodyTo(Order<List>)
> 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
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.