Search code examples
talend

is there a way to get all match from tmap to a list


I'm using Talend to do a joint operation between two tables in order to get all match records.

enter image description here

Here is my tables:

  1. table of Careers
  2. table Careers's Interruptions

So the logic is like this one. A person can have a carrer number X10 witch start form 01-01-2000 to 31-12-2000. In the other side, i have multiple interruptions related to this carrer X10

  • Interruption X10 from 01-02-2000 to 05-02-2000
  • Interruption X10 from 05-06-2000 to 05-07-2000
  • Interruption X10 from 30-10-2000 to 01-11-2000

I have a function that accept two parameter ( carrer car, interruption inter ) I use this function to split the carrer interval with the interruption interval to get only a carrer without interruption

enter image description here

for example

  • carrer start date 01-01-2000 to 31-12-2000

with

  • interruption start date 05-02-2000 to 07-02-2000

As output function i get this one:

  • carrer one : start date 01-01-2000 to 04-02-2000
  • interruption: start date 05-02-2000 to 07-02-2000
  • carrer two : start date 08-02-2000 to 31-12-2000

    My program work fine, when i have only one interruption related to a carrer.

when i have Multiple interruptions, the function will get all records ( all match rows row by row ) like this

carrer X  Interruption I1     ->  to my function ()
carrer X  Interruption I2     ->  to my function ()
carrer X  Interruption I3     ->  to my function ()

In this case all the logic will be incorrect as the carrer is not updated after the first split with the first interruption as always we pass the same carrer X 3 time to my function.

My question is is there a way to pass all matches in one shoot to my function Like this

carrer X ,  List<interruption>  -> to my function 

Solution

  • I found out a way to get a list of rows that ( all the interrupt lines that correspond to the main line). This is done with the tAggregateRow component.

    here is the new schema :

    enter image description here

    I used two list to group all start DATE and end DATE that much the same carrer.

    enter image description here

    and there is my final tmap shcema.

    enter image description here