#1 2009-07-07 21:56:51

alanc007
Member
Registered: 2009-04-14
Posts: 30

Context Loading

Tags: [context, xml]

I have the Following XML Document:
<?xml version="1.0" encoding="utf-8"?>
<CONTEXT>
  <PLANT>
    <ID>
      <UID>UID1</UID>
      <NAME>NAME1</NAME>
    </ID>
    <SAP>
      <CLIENT>CLIENT1</CLIENT>
      <USERID>USERID1</USERID>
      <PASSWORD>PASSWORD1</PASSWORD>
      <LANGUAGE>LANGUAGE1</LANGUAGE>
      <HOSTNAME>HOSTNAME1</HOSTNAME>
      <SYSTEM>SYSTEM1</SYSTEM>
    </SAP>
    <FOLDERS>
      <DNS>DNS1</DNS>
      <SHARENAME_INPUT>SHARENAME_INPUT1</SHARENAME_INPUT>
    </FOLDERS>
  </PLANT>
</CONTEXT>
I created a Context Item under the contexts heading with the same Structure. Also Created this Structure under metadata to try that way as well. i can use the tcontextLoad tExtractXML Field,tFileXML with tJavaCode and Nothing im doing will populate the context.field values.. What can i be Doing wrong?

For tJavaCode i use
context.CLIENT = row1.CLIENT;
also tried
context.CLIENT = ((String)globalMap.get("row1.CLIENT"))
or
((String)globalMap.put("context.Client"),row1.CLIENT))
the Structure for the tContextLoad completes, but no loading
Starting job CONTEXT_LOAD at 21:50 07/07/2009.

[trace] connecting to socket on port 5046
[trace] connected
DUN_INDU|404|RFC_TALEND|initiale|EN|ScoopC22.corp.ponet|00|SDUN030|\\10.210.10.30\GENERAL_OUTPUT
[trace] disconnected
Job CONTEXT_LOAD ended at 21:50 07/07/2009. [exit code=0]
Thanks in Advance

Offline

#2 2009-07-08 04:18:27

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

Re: Context Loading

Hello
tContextLoad is used to load the context value from a delimited file. In your case, you store the data in a xml file, so a tFileInputXML component is enough.
tFileInputXML-->tJavaRow
   |
onSubJobOK
   |
do other transaction
On tJavaRow: context.CLIENT = input_row.CLIENT;

Best regards

          shong


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-07-08 15:11:21

alanc007
Member
Registered: 2009-04-14
Posts: 30

Re: Context Loading

Thnak you for the Information
With This Syntax the following at the Bottom Is the System.Outprint, but the Context Values are not changed..
currentComponent = "tJavaRow_1";

                // Code generate accord to input schema and output schmea

                context.NAME = row1.NAME;
                context.CLIENT = Integer.toString(row1.CLIENT);
                context.USERID = row1.USERID;
                context.PASSWORD = row1.PASSWORD;
                context.LANGUAGE = row1.LANGUAGE;
                context.HOSTNAME = row1.HOSTNAME;
                context.SYSTEM = row1.SYSTEM;
                context.DNS = row1.DNS;
                context.SHARENAME_INPUT = row1.SHARENAME_INPUT;

                nb_line_tJavaRow_1++;

                if (row2 != null) {
                    globalMap.put("ENABLE_TRACES_CONNECTION_tFileInputXML_2",
                            Boolean.TRUE);
                    runTrace.isPause();
                    if (runTrace.isPause()) {
                        while (runTrace.isPause()) {
                            Thread.sleep(100);
                        }
                    } else {

                        // here we dump the line content for trace purpose
                        runTrace.sendTrace("row2", " NAME=" + row2.NAME
                                + "| CLIENT=" + row2.CLIENT + "| USERID="
                                + row2.USERID + "| PASSWORD=" + row2.PASSWORD
                                + "| LANGUAGE=" + row2.LANGUAGE + "| HOSTNAME="
                                + row2.HOSTNAME + "| SYSTEM=" + row2.SYSTEM
                                + "| DNS=" + row2.DNS + "| SHARENAME_INPUT="
                                + row2.SHARENAME_INPUT + "|");
                    }
                } else {
                    globalMap.put("ENABLE_TRACES_CONNECTION_tFileInputXML_2",
                            Boolean.FALSE);
                }

                tos_count_tJavaRow_1++;

                /**
                 * [tJavaRow_1 main ] stop
                 */

                /**
                 * [tLogRow_1 main ] start
                 */

                currentComponent = "tLogRow_1";

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Starting job CONTEXT_LOAD at 15:09 08/07/2009.

[trace] connecting to socket on port 4512
[trace] connected
.--------+------+----------+--------+--------+-------------------+------+-------+-----------------------------.
|                                                  tLogRow_1                                                  |
|=-------+------+----------+--------+--------+-------------------+------+-------+----------------------------neutral
|NAME    |CLIENT|USERID    |PASSWORD|LANGUAGE|HOSTNAME           |SYSTEM|DNS    |SHARENAME_INPUT              |
|=-------+------+----------+--------+--------+-------------------+------+-------+----------------------------neutral
|DUN_INDU|402   |RFC_TALEND|initiale|EN      |ScoopC22.corp.ponet|00    |SDUN030|\\10.210.10.30\GENERAL_OUTPUT|
'--------+------+----------+--------+--------+-------------------+------+-------+-----------------------------'
[trace] disconnected
Job CONTEXT_LOAD ended at 15:09 08/07/2009. [exit code=0]

Offline

#4 2009-07-08 15:32:34

alanc007
Member
Registered: 2009-04-14
Posts: 30

Re: Context Loading

if i use the following on each line i can see the Loaded from XML values.
String NAME = String.valueof(row2.NAME);
System.out.println(NAME)
Starting job CONTEXT_LOAD at 15:28 08/07/2009.

[trace] connecting to socket on port 5305
[trace] connected
DUN_INDU

Which still leads me to be confused as to why i can see the valuse, but not load them into the context. Im sure im just Java Dumb. Thanks in advance again. Ohh And just so you know FEB 09 foundation class is when i first started using JAVA, so Im a NEWBIE :-)

Offline

#5 2009-07-08 15:56:46

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

Re: Context Loading

Hello

but the Context Values are not changed..

Why do you say the context values don't change?  If you type in the code as below on tJavaRow, you will see the context value changes.
context.CLIENT = input_row.CLIENT;
system.out.println(context.CLIENT);



Best regards

          shong


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

#6 2009-07-08 17:15:00

alanc007
Member
Registered: 2009-04-14
Posts: 30

Re: Context Loading

im not seeing the values on the Context output window to the left of the std output window change valuse nor can i use the values of the context.object in other jobs.


Uploaded Images

Offline

#7 2009-07-09 07:45:49

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

Re: Context Loading

Hello

im not seeing the values on the Context output window to the left of the std output window change valuse nor can i use the values of the context.object in other jobs.

First, the default value of vars  will not be changed forever. In fact, the context var changes dynamically. For exampe, if you type in the following code on tJavaRow:
system.out.println(context.CLIENT);
context.CLIENT = input_row.CLIENT;
system.out.println(context.CLIENT);
the result will be:
null
402
As you see, before you set value to context.CLIENT, the value of context.CLIENT is the default value:null, after you set value to context.CLIENT, the value is 402.
Second, the context var can't be used on separate jobs. If you want to share the context var on another job, you need to use a tRunJob component to run the other job and pass the context var via tRunJob.

Best regards

         shong


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

Board footer

Powered by FluxBB