You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/03/25 08:43:00 UTC

[jira] [Resolved] (CAMEL-16402) Global variable in split

     [ https://issues.apache.org/jira/browse/CAMEL-16402?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-16402.
---------------------------------
    Resolution: Invalid

Ask for help on the user mailing list, or the chat room first.

> 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)