Four Stars

tHMap SimpleLoop Filter by Java function - need to pass entire loop (of Json array) as parameter

In Talend tHMap, we are trying to do custom filtering on a loop of JSON array using a Java function.

 

This Java function needs to have as input as the iteration of the loop being passed in as well as the entire loop itself.

This is to determine if a certain iteration of the loop should be filtered out based on other sibling instances within the same loop (which may come before or after the current instance)

 

How do we do that?

 

2 REPLIES
Six Stars

Re: tHMap SimpleLoop Filter by Java function - need to pass entire loop (of Json array) as parameter

Look at the mapper functions: I think there is one called LoopIndex that can be used to filter based on a given loop iteration. You can read more about it here:

 

http://doc.talend.com/enterprise/talend_data_mapper/3.3/map_iter.php#map_iter_cookbook

 

(look for the section titled "Mapping Looping to Non-Looping": it's not quite what you're trying to do, but it describes the component).

 

Good luck!

 

David

Eight Stars

Re: tHMap SimpleLoop Filter by Java function - need to pass entire loop (of Json array) as parameter

Hi,

 

I don't think you can do it like that.

 

But what is the algorithm of this java function ? 

 

Eric