#1 2009-02-25 11:15:33

arnaud.g
Member
Registered: 2008-10-22
Posts: 39

Load context from XML file

Hello,

I'd like to manage my context variables thanks to an XML file. In this file, I would like to manage all the needed variables PLUS different value for these variable according to the execution environment (production or development).

So I wrote an XML file like this:

Code:

<setup_information>
    <setup context="DEV">
        <hostname>servename_DEV</hostname>
        <port>1234_DEV</port>
        <username>user_DEV</username>
        <password>pass_DEV</password>
    </setup>
    <setup context="PROD">
        <hostname>servename_PROD</hostname>
        <port>1234_PROD</port>
        <username>user_PROD</username>
        <password>pass_PROD</password>
    </setup>
</setup_information>

Then, I setup my tFileInputXML like you can see on the screen shot, where context.context_type = "DEV" or "PROD" according to the context...

I can retrieve the expected value, according to the context, taht fine.

BUT, how can I transform this into context, the tContextLoad component having a shema key/value ???


Uploaded Images

Offline

#2 2009-02-26 06:43:15

shong
Talend team
Registered: 2007-08-29
Posts: 10289
Website

Re: Load context from XML file

Hello

BUT, how can I transform this into context,

After you extract the value from xml file, you can use a tJavaRow to set the values to context variables, see the screenshots.

the tContextLoad component having a shema key/value ???

Yes, tContextLoad component have a schema with key/value column. You can store your context variable and their values in a file like this:
hostname:hostnameDEV
port:portDEV
username:usernameDEV
password:passwordDEV

then, use a tContextLoad component to load the values to context variables in a job. About the basic usage of tContextload, please read the user documentation.

Best regards

         shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2009-02-26 10:44:09

arnaud.g
Member
Registered: 2008-10-22
Posts: 39

Re: Load context from XML file

Damned... My yesterday job does not work anymore...

Tahnks shong for your help !!!

Arnaud

Offline

#4 2010-07-20 04:17:58

buzzy
Member
Registered: 2009-08-11
Posts: 74

Re: Load context from XML file

hi guys,



i am using this approach to set global context in a project...

tmysqlinput(1)------>tjavarow(here multifull if conditions for assiging vales to different context's)
                              |
                              |
                              tmysqlinput(2)---------tmysqloutput

Note: Created context variables.


by using those components i am able to assign values to context and i am using those context in tmysqlinput(2), and finaly loaded data into target...

??????PROBLEM IS : i am facing one of the issue..like this..

i dont want to use " tmysqlinput(1)------>tjavarow(here multifull if conditions for assiging vales to different context's)" this part every time.

based on context variables i need to assign context values to other jobs..

when i retrive context by using context tab and trying to use.............but unable to retrive and dispaly  those  values.....

How we can use those context's in other jobs..?????


Pls let me know any one.....on this issue.???????



Regards

Offline

#5 2010-07-20 08:22:30

lovely
Member
Registered: 2010-05-28
Posts: 68

Re: Load context from XML file

Hi Buzzy,

How we can use those context's in other jobs..?????

Please see screeshots below. I am not good in explaining things that's why I just provided screenshots for you. But still, not sure if this is what you are looking for. smile


Uploaded Images


“The mediocre teacher tells. The good teacher explains. The superior teacher demonstrates. The great teacher inspires.” -William A. Ward

Offline

#6 2010-09-09 16:54:39

archenroot
Member
Company: CoeTech Unconnected
Registered: 2010-02-23
Posts: 161
Website

Re: Load context from XML file

Hey,

nice tutorial Shong. It works well. But because it is already some time ago, I want to ask if there is another more intuitive way how to read configuration from XML file directly into context variables?

Best regards,

Ladislav Jech


Emperor wants to control outer space Yoda wants to explore inner space that's the fundamental difference between good and bad sides of the Force

Offline

Board footer

Powered by FluxBB