Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Matthew,
What is the datatype of context.map in child?
You need not use tBuffer component for this task in child. You can simply assign value in child to context variable and in parent call that value again... during this you will have to enable checkbox, transmit all context. One more thing is you will have to have this context in both the jobs with same datatype.
You can also think of using getter-setter routines for this purpose.
Thanks
Vaibhav
I am able to pass a Map object down from a parent to a child via context variables without any problems. However, when I attempt to pass a Map object back up to the parent via a tBufferOutput, I am unable to cast it to a Map in the parent without getting a java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map error.
For example, I have two jobs, ParentMap and ChildMap, to illustrate this. Both jobs have a context variable "map" of type "Object".
The parent Object consists of tJava --onComponentOk-->tRunJob(ChildMap--row1(main)-->tJavaRow.
172438/mini_blob_20140907-0315.png
In the tJava, I create a HashMap, put two entries in it, and set context.map to the HashMap.
In the ChildMap, I set the context parameter map to the ParentMap's context.map:
172438/mini_blob_20140907-0317.png
The ChildMap job consists of tJava--row1(main)-->tBufferOutput.
172438/mini_blob_20140907-0320.png
As you can see, I am able to cast the context.map object (that was passed from the parent via context variables) into a HashMap. I also set row1.map to this context.map and pass it to the tBufferOutput, which has a variable "map" of type "Object".
Now, back to the parent, I have the following code in the tJavaRow that attempts to cast the map object into a hashmap and iterate over it.
172438/mini_blob_20140907-0322.png
However, the job fails in the parent when I run it:
172438/mini_blob_20140907-0324.png
I have an identical ParentList/ChildList jobs which show the same behavior for Lists:
172438/mini_blob_20140907-0332.png
So it appears that Talend is calling the toString() method on any "Object" in the tBufferOutput, thus rendering it a String and not a polymorphic Object. Is this behavior intentional and I am misunderstanding how I should be passing complex Objects from a child job back to a parent job, or is this a bug?
How should I go about passing a List or Map or other complex Object back up to the parent job from a child job?
Regards,
Matthew