[ 
https://issues.apache.org/jira/browse/CAMEL-16402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17308541#comment-17308541
 ] 

Evgeny commented on CAMEL-16402:
--------------------------------

OK.

> Global variable in split
> ------------------------
>
>                 Key: CAMEL-16402
>                 URL: https://issues.apache.org/jira/browse/CAMEL-16402
>             Project: Camel
>          Issue Type: Task
>          Components: came-core
>            Reporter: Evgeny
>            Priority: Major
>
> When I reading csv files in split,  I need to get get field names and 
> calculate index for each name. It's OK via groovy.
> I try to store indexes in some heades. I need it because csv file coud 
> contain fields in arbitrary order. 
> In one file: name, ID, address...
> In other file: ID, address, name...
> <when>
> <simple>${headers[CamelSplitIndex]} == 0</simple>
> <transform>
> <groovy>
> <![CDATA[
> String[] AllData = exchange.getIn().getBody().split(';');
> //some processing
> //and store to headers for next using
> //for case name, ID, address...
> exchange.getIn().getHeaders().put("Name", NameValue); //0
> exchange.getIn().getHeaders().put("ID", IDValue); //1
> exchange.getIn().getHeaders().put("Address", AddressValue); //2
> ]]>
> </groovy>
> </transform>
> I use index for each field, to get correct value when I going to insert in 
> database.
> But each time split (new step) read new line from csv file, headers a lost 
> their value.
> While ${headers[CamelSplitIndex]} == 0 headers contain fields index.
> But when  ${headers[CamelSplitIndex]} > 0 all headers loose the info.
> How to create real global variables, which will be avialable in any <when> 
> cases and slplit steps?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to