Return-Path: Delivered-To: apmail-camel-dev-archive@www.apache.org Received: (qmail 77445 invoked from network); 26 Jan 2009 13:25:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jan 2009 13:25:20 -0000 Received: (qmail 32624 invoked by uid 500); 26 Jan 2009 13:25:20 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 32544 invoked by uid 500); 26 Jan 2009 13:25:20 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 32533 invoked by uid 500); 26 Jan 2009 13:25:20 -0000 Delivered-To: apmail-activemq-camel-dev@activemq.apache.org Received: (qmail 32530 invoked by uid 99); 26 Jan 2009 13:25:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jan 2009 05:25:20 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Jan 2009 13:25:19 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5B003234C48B for ; Mon, 26 Jan 2009 05:24:59 -0800 (PST) Message-ID: <135228995.1232976299367.JavaMail.jira@brutus> Date: Mon, 26 Jan 2009 05:24:59 -0800 (PST) From: "Claus Ibsen (JIRA)" To: camel-dev@activemq.apache.org Subject: [jira] Commented: (CAMEL-398) Map the content of a CSV file to a POJO using @annotation and .convertBodyTo() In-Reply-To: <1727324133.1206523532643.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/activemq/browse/CAMEL-398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=48952#action_48952 ] Claus Ibsen commented on CAMEL-398: ----------------------------------- v0.96 review ========== - Maybe a bit overkill with byte,char,short data formats as they are kinda newer used - CharacterFormat#format: Can you not just do: return object.toString(); to format it as a String? - PatternFormat needs type as well: public interface PatternFormat extends Format - Data pattern should use the Date as type public class DatePatternFormat implements PatternFormat - The same for all xxxFormat they should add the type they are, eg Double public class DoubleFormat implements Format - The PatternFormat: remember to test for pattern is not null ObjectHelper.notNull(pattern, "pattern") in the parse/format methods - NumberPatternFormat could be abstract - BigDecimal how do you set its scale and other parameters? - BindyFactory: The model object Map. Please document what the key is? (= the string). And the value is the POJO - BindyCsvFactory a) I still think you should not sort the keys in unbind. I think it should use the same order as the data is in the model map. You can use a LinkedHashMap for the model map then the data have the same order as its added b) In Unbind I dont see a newline anywhere. Should you not add a newline after each record? > 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 > Assignee: Claus Ibsen > Fix For: 2.0.0 > > Attachments: camel-bindy-v0.95.zip, camel-bindy-v0.96.zip, camel-bindy.zip > > > 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) 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) > 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 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.