You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Babak Vahdat (Created) (JIRA)" <ji...@apache.org> on 2012/03/17 21:40:37 UTC

[jira] [Created] (CAMEL-5105) Add the options configRef and strategyRef to csv data format in XML DSL

Add the options configRef and strategyRef to csv data format in XML DSL
-----------------------------------------------------------------------

                 Key: CAMEL-5105
                 URL: https://issues.apache.org/jira/browse/CAMEL-5105
             Project: Camel
          Issue Type: Improvement
          Components: camel-spring
    Affects Versions: 2.9.0
            Reporter: Babak Vahdat
            Assignee: Babak Vahdat
            Priority: Minor
             Fix For: 2.10.0, 2.9.2


CAMEL-5100 provided the autogenColumns option which doesn't bring much on it's own (default is true), which with an *explicit* value set to false nothing will be appended into the output other than "\n"'s.

So using the configRef and strategyRef options we could then bring the same power of expression inside XML DSL like inside Java. Following a sample where the user can customize the used CSVConfig and/or CSVStrategy being used:

{code}
  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">

    <route>
      <from uri="direct:start" />
      <marshal>
        <csv autogenColumns="false" delimiter="|" configRef="csvConfig1" />
      </marshal>
      <convertBodyTo type="java.lang.String" />
      <to uri="mock:result" />
    </route>

    <route>
      <from uri="direct:start2" />
      <marshal>
        <!-- make use of a strategy other than the default one which is 'org.apache.commons.csv.CSVStrategy.DEFAULT_STRATEGY' -->
        <csv autogenColumns="false" delimiter="|" configRef="csvConfig2" strategyRef="excelStrategy" />
      </marshal>
      <convertBodyTo type="java.lang.String" />
      <to uri="mock:result2" />
    </route>

  </camelContext>

  <bean id="csvConfig1" class="org.apache.commons.csv.writer.CSVConfig">
    <property name="fields">
      <list>
        <!-- here we're only interested in 'item' but not in 'orderId' or 'amount' -->
        <bean class="org.apache.commons.csv.writer.CSVField">
          <property name="name" value="item" />
        </bean>
      </list>
    </property>
  </bean>

  <bean id="csvConfig2" class="org.apache.commons.csv.writer.CSVConfig">
    <property name="fields">
      <list>
        <!-- here we're interested in both 'orderId' and 'amount' but not in 'item' -->
        <bean class="org.apache.commons.csv.writer.CSVField">
          <property name="name" value="orderId" />
        </bean>
        <bean class="org.apache.commons.csv.writer.CSVField">
          <property name="name" value="amount" />
        </bean>
      </list>
    </property>
  </bean>

  <bean id="excelStrategy" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
    <property name="staticField" value="org.apache.commons.csv.CSVStrategy.EXCEL_STRATEGY" />
  </bean>
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CAMEL-5105) Add the options configRef and strategyRef to csv data format in XML DSL

Posted by "Babak Vahdat (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5105?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Babak Vahdat resolved CAMEL-5105.
---------------------------------

    Resolution: Fixed

Did update the 2.10.0 release notes as well.
                
> Add the options configRef and strategyRef to csv data format in XML DSL
> -----------------------------------------------------------------------
>
>                 Key: CAMEL-5105
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5105
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring
>    Affects Versions: 2.9.0
>            Reporter: Babak Vahdat
>            Assignee: Babak Vahdat
>            Priority: Minor
>             Fix For: 2.10.0, 2.9.2
>
>
> CAMEL-5100 provided the autogenColumns option which doesn't bring much on it's own (default is true), which with an *explicit* value set to false nothing will be appended into the output other than "\n"'s.
> So using the configRef and strategyRef options we could then bring the same power of expression inside XML DSL like inside Java. Following a sample where the user can customize the used CSVConfig and/or CSVStrategy being used:
> {code}
>   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>     <route>
>       <from uri="direct:start" />
>       <marshal>
>         <csv autogenColumns="false" delimiter="|" configRef="csvConfig1" />
>       </marshal>
>       <convertBodyTo type="java.lang.String" />
>       <to uri="mock:result" />
>     </route>
>     <route>
>       <from uri="direct:start2" />
>       <marshal>
>         <!-- make use of a strategy other than the default one which is 'org.apache.commons.csv.CSVStrategy.DEFAULT_STRATEGY' -->
>         <csv autogenColumns="false" delimiter="|" configRef="csvConfig2" strategyRef="excelStrategy" />
>       </marshal>
>       <convertBodyTo type="java.lang.String" />
>       <to uri="mock:result2" />
>     </route>
>   </camelContext>
>   <bean id="csvConfig1" class="org.apache.commons.csv.writer.CSVConfig">
>     <property name="fields">
>       <list>
>         <!-- here we're only interested in 'item' but not in 'orderId' or 'amount' -->
>         <bean class="org.apache.commons.csv.writer.CSVField">
>           <property name="name" value="item" />
>         </bean>
>       </list>
>     </property>
>   </bean>
>   <bean id="csvConfig2" class="org.apache.commons.csv.writer.CSVConfig">
>     <property name="fields">
>       <list>
>         <!-- here we're interested in both 'orderId' and 'amount' but not in 'item' -->
>         <bean class="org.apache.commons.csv.writer.CSVField">
>           <property name="name" value="orderId" />
>         </bean>
>         <bean class="org.apache.commons.csv.writer.CSVField">
>           <property name="name" value="amount" />
>         </bean>
>       </list>
>     </property>
>   </bean>
>   <bean id="excelStrategy" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
>     <property name="staticField" value="org.apache.commons.csv.CSVStrategy.EXCEL_STRATEGY" />
>   </bean>
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira