One Star

[resolved] tNormalize behavior to split java.util.List

Scenario:
Aggregate rows using tAggregateRow, count rows in groups
Delete rows by ID from original table where count(*) > 1 using tJDBCOutput
tAggregateRow can output row IDs for future use either as java.util.List or as comma separated string. Note that we have multiple objects of type List, one for each aggregated row.
tNormalize can split that comma separated string to rows and pass them to tJDBCOutput
Same can be done with java.util.List, but it will involve 3 components: treplicate, tjavaflex and tjavarow.
We need to create a loop that iterates the List and outputs some rows further in flow. The loop should be started in Main part, not start/end part of components. Other components should insert their code inside the loop.
For that we add treplicate and tjavaflex in our flow. Most columns are auto propagated, but the current list item is assigned manually.
tjavaflex main code:
for (String s : (List<String>)row8.list) {
row10.s = s;

Now add tjavarow as second ouput to treplicate. It closes the loop. Output order is important.
tjavarow code:
}
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] tNormalize behavior to split java.util.List

For anyone else reading this, the above statements/quoted-code are literal.
You don't close your for loop in your main section of your tJavaFlex (as indicated in original post), and then you close it with "}" in your tJavaRow component.
Works just as advertised!

PS: Sorry, just saw your post... hopefully my additional comments help any other readers. Feel free to delete, or incorporate into your solution, if not.
3 REPLIES
One Star

Re: [resolved] tNormalize behavior to split java.util.List

Old (but useful) thread... a quick clarification, did you intend to leave the code block for the tJavaRow component blank? Could someone further explain the statement "It closes the loop"?
It appears that this solution (with some additions) is precisely what I am looking for. I am trying to marshal a MongoDB subdocument list into JSON objects using json-simple to pull out the subdocument properties from each list item, and then write them out to a new row.
One Star

Re: [resolved] tNormalize behavior to split java.util.List

Hi bigteejay.
The code block is not empty, it contains the right brace, that "closes the loop".
Download the attached fullsize image, rename it to .zip, extract the sample and import with Studio.
One Star

Re: [resolved] tNormalize behavior to split java.util.List

For anyone else reading this, the above statements/quoted-code are literal.
You don't close your for loop in your main section of your tJavaFlex (as indicated in original post), and then you close it with "}" in your tJavaRow component.
Works just as advertised!

PS: Sorry, just saw your post... hopefully my additional comments help any other readers. Feel free to delete, or incorporate into your solution, if not.