Post by Sergey P
Excuse me for question that maybe has asked before, but I'm not found question described exactly like my case now.
I build adapter for IGI.
So, in short, I need to pass some Map object between two connectors that both defined in Feed on Iterator Mode. How can I do this?
I can also insert to one ScriptConnector some java code to writing data in file and then read from a file inside another ScriptConnector, but if I could to use more graceful way to implement this logic I'll glad to hear (read) :)
Thank you in advance!
Ok, Sergey, as with most things TDI, there are several ways to flay this feline (aka skin the cat :)
One way is to pass stuff around using Input/Output Maps. However, your Iterators only have Input Maps for returning data. No easy way to pass in anything but string values via the parameters.
So instead, you could use the Op Entry which is owned by the AL. The Op Entry is created when the AL starts and it contains any instructions to the AL itself: settings, Connector parameters, AL Operation, etc. However, it is a valid Entry object and is around as long as the AL is running, so we can use it to pass around data within the AL.
I have created an example AL here: https://github.ibm.com/eddie-hartman/_test
To easily use this TDI Project you should:
1. Create a new Project named '_test'
2. Pull down the _test repo - either with 'git clone' or downloading the zip
Put this folder somewhere outside your TDI workspace.
3. Now copy the contents of this _test folder to the _test Project folder
in your TDI workspace.
4. Right-click on your _test Project in the TDI CE Navigator pane and select Refresh
If you just want the 'scriptedIteratorsPassingJavaObject' AL itself, then grab the _test/AssemblyLines/scriptedIteratorsPassingJavaObject.assemblyline file and drag-drop it into your own Project in the TDI CE. You can drag-drop most of the files found in the TDI Project (*.script, *.parser, *.attributemap, and so forth).
Now you should see the scriptedIteratorsPassingJavaObject AL there. Running it you should have both Iterators returning the same four Entries.
If you look in the Connection > Script for the first one you'll see it creates a HashMap and populates it with JS Objects. It then grabs the Op Entry from the AL (task) and saves the map as its '$map' attribute. This is all done in selectEntries().
In the second Iterator the selectEntries grabs the '$map' attribute from the AL's Op Entry and uses it for its own iteration.
Hope this helps! Please let me know if anything is unclear.