#1 2012-07-17 16:47:29

splithorizon852
Guest

Context Values

Hi, I've just started using TalenD and still learning the basics. I am trying to design a process in which I extract values from a configuration file (xml) for use in the rest of the process, stuff like connection information. These values are extracted fine through tFileInputXML, however I have no idea how to assign those values to a context. Can anyone help?

Thanks in advance

#2 2012-07-18 01:30:55

alevy
Member
Registered: 2009-11-20
Posts: 1558

Re: Context Values

Pass the flow to tJavaRow and then use statements like

Code:

context.myFirstContext = row1.myFirstValue;

Offline

#3 2012-07-18 15:03:33

splithorizon852
Guest

Re: Context Values

Thanks for the help, I will give it a shot.

So there is no component where you can manage this? I'd love to see contexts be included in tmap.

#4 2012-07-19 02:15:24

alevy
Member
Registered: 2009-11-20
Posts: 1558

Re: Context Values

How do you see it working in tMap or another component?  If your flow contains two columns "key" (being the context variable name) and "value" you can pass it to tContextLoad to set the context values.

Offline

#5 2012-07-19 15:09:24

splithorizon852
Guest

Re: Context Values

I worked with Adobe Livecycle before and I would just create a loop, each time it executed the value was changed to the next and assigned to that variable, then I used the variable anywhere I needed in that loop.

I really like what talenD can do, but I do miss that functionality, I am still having a hard time grasping the concepts of how data actually moves. I am sure I'll get it one of these days.

As for how I envision it, well if we are talking about a repeating field then it wouldn't work without a similar loop. However, it would be great for reading values out of a config file, or something similar.

Also, for some reason when I put tLogRow after my tJavaRow, the log does not output context values, so I have to use another component to actually test variable assignment.

#6 2012-07-20 09:33:49

alevy
Member
Registered: 2009-11-20
Posts: 1558

Re: Context Values

It sounds like what you're looking for is tFlowToIterate, which will loop the following components for each incoming row from tFileInputXML.  Note, though that it places the values in the globalMap rather than the context but using them is no different (apart from syntax).

tLogRow will show the values in the flow.  A statement like my suggestion changes the context, which is not part of the flow.  You can assign the context value to an output column from tJavaRow if you want to send it on to tLogRow e.g. output_row.newColumn = context.myFirstContext;

You can also use tContextDump to create a flow of context values that you can pass to tLogRow.  But tContextDump should be linked with OnSubjobOK from tFileInputXML so it only runs after tFileInputXML is complete i.e. has all context values populated and outputs them only once.

Offline

Board footer

Powered by FluxBB