I think using tJavaFlex, tMap and tFlowToIterate components you can easily split the data. You can start off by arranging the components as shown below:
Open the Map Editor and map the data as shown:
In the Map Editor output table add a new row called “iterations” of “long” type to hold the difference between the dates.
tFlowToIterate components need no configurations to be done. It will by default pass on the values to the tJavaFlex.
Add the below code to the tJavaFlex component:
Start Code:
// start part of your Java code
int currentId = (Integer)globalMap.get("res.id");
String currentName = (String)globalMap.get("res.name");
Long iterations = (Long)globalMap.get("res.iterations");
Date dateFrom = (java.util.Date)globalMap.get("res.dateFrom");
Date dateTo = (java.util.Date)globalMap.get("res.dateTo");
for(int i=0; i<((Long)globalMap.get("res.iterations")); i++) {
Main Code:
row2.new_id = i+1;
row2.id = currentId;
row2.name = currentName;
row2.dateFrom = TalendDate.addDate(dateFrom, i, "dd");
row2.dateTo = TalendDate.addDate(dateFrom, i+1, "dd");
End Code:
}
Like the tFlowToIterate component tLogRow also do not need any configurations to be done. You can just go ahead and execute the job which will give you the below output.
Hope this was what you were looking for.
Get your Talend certification today to become certified professional.
Thanks.