Get a list of Objects coming from a tMap

Four Stars

Get a list of Objects coming from a tMap

I have a job with a lot of data coming from 6 different files, i have several rules applied to this files so I can build the final output list to my database;

 

The last step of this process is hard. I need to get set a new Field that depends on a list of other fields.

 

My data is coming from a tMap and i need something like:

 

List<Material> list = the rows on tMap that have this "Material" key. Like a distinct clause on SQL.

 

Then, after doing the logic to create this new Field, i need to return all the values as a tMap;

 

Here is an example of it in pseudo-code

 

Class Material {
string key;
string value;
string status;
}

List<Material> list = tMap;
for each (key : list.distinct(Keys)){
 value > 0 ? status = true : status = false;
}

return list.toTMap();
Moderator

Re: Get a list of Objects coming from a tMap

Hello,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: Get a list of Objects coming from a tMap

I have a tMap that maps my Material with several columns, we have a code, a price and a name, i.e.

Code = 1 ; Price = 10; Name = Plastic Fork;
Code = 1 ; Price = 15; Name = Steel Fork;
Code = 1 ; Price = 20; Name = Italian Fork;
Code = 2 ; Price = 7; Name = Steel Knife;

Code = 2 ; Price = 10; Name = Ceramic Knife;

 

I want to return a list, grouping this materials by code;

List<Material> list = (Code =1, [Plastic Fork, Steel Fork, Italian Fork] ; Code=2, [Steel Knife, Ceramic Knife])

 

And then i want to consume this list on another tMap;

 

I've managed to create the grouped list using tJavaFlex. First i've created a class containing the information a i needed, the created a list of this class, looped through the tMap using the loop code to set my new Object and to add it to my list;

 

Then on the finish code, i've used lambda expressions to group it in a map of <MaterialCode, List<Material>> and print it, just to test it.

 

I want to consume this final Map in a tMap, is there any way?

Four Stars

Re: Get a list of Objects coming from a tMap

In the picture, stuff is my List of Teste, output is my tMap output

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download