Wednesday, 19 November 2014

Example 4 Efficient For Loop in Talend

String Col="abcd,efg";
String[] filters = col.split(",");
String CFILTER = "WHERE ( ";

for(String filter : filters ) {
  CFILTER += " OR (\"STATUS\" LIKE '%"+filter+"%')";
}

The above split function will split the passed string into multiple rows.
for loop will be iterating till the last row.
we don't have to mention any start/end in the for loop.

Config file not picking up in TAC

This occurs mainly when the PROJECT  is RENAMED.

So,prepare a pre-requiste list of items that are needed to be added when project is renamed.

1)Any custom components needs to be added.
2)Custom components specifically used in context parameter file JOBLET/JOB used.

Summary :
--------------
-->Add and apply Custom components to the project.

Monday, 17 November 2014

Solution for ZIP file Deployment of Talend job in TAC

After configuring the normal properties that Talend Documentation says, deployment fails because of some default settings in Internet Explorer.

The solution for it is as follows.

Solution 1 :  It works well if you create a TASK in CHROME browser instead of INTERNET EXPLORER.

Note :  1 thing to remember is the TAC webpage consists of multiple pages for the TASKS. check for the last page for your task    created.


Solution 2 :  In INTERNET EXPLORER,  you got to do some settings configured as below.
                   Tools --> Internet Options --> Security --> Custom Level --> DISABLE  "Include Local Directory Path when Uploading files to Server".

tPrejob & tPostjob Components

we can perform different type of activities by using the tPrejob & tPostjob Components.

tPrejob :   This will be first component to be run in the Talend job.

                  1)  Run the Child jobs.
                  2) Drop the Database Indexes
                  3)Truncate the Database Tables.
                  4)Disable the Indexes of TABLES.

tPostjob :   This will be last component to be run in the Talend job
         
                1)Re-create the Indexes which are dropped in tPrejob
                2)Enable the Indexes which are disabled in tPrejob

Note : Pre & Post jobs will work even if the job fails.

creating a request in tXMLMAP

1) Add a column
2)Make the datatype as document
3)Import the schema which is already created by checking the checkbox in ESB component.

No: of Child Threads Property of tPartitioner

No : of child Threads  is nothing but the no: of CPU's of the particular machine on which TALEND APPLICATION is running.

we can get the no: of child threads in the below way.

Runtime.getRuntime().availableProcessors()

Note :   If we give more than the no: of CPU's that our machine has, will give in-appropriate results while using tPartioner & tCollector components.

Built-in functions used frequently

CONTAINS & EQUALS :

row1.contains("ram")
row2.equals("Name")

LASTINDEXOF :
("tFileList_1_CURRENT_FILE")).lastIndexOf("."))

SUBSTRING:
m-- starts from 0 .. refers to the position.
n -- starts from 1 -- refers to the position itself (not the no: of the characters)

Input  :  "ABCD".substring(0,2)
Result :   ABC
substring(m,n)


GETTING CURRENT FILEPATH  IN tFILELIST :
((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))

GETTING CURRENT FILENAME FROM  tFILELIST :
((String)globalMap.get("tFileList_1_CURRENT_FILE")).substring(0,((String)globalMap.get
("tFileList_1_CURRENT_FILE")).lastIndexOf("."))

replace() Example :
-------------------------
we can use this for replacing special characters in a string
String input_row="abcd:[],kdkkxyzkll:[],";

String abc="{\"NOTIFICATION_RESPONSE\":{"+input_row.replace(":[],",":\"\"")+"}}";
System.out.println(abc);
Output : 
-----------
{"NOTIFICATION_RESPONSE":{abcd:""kdkkxyzkll:""}}

Note :  Go for replace() if  replaceAll() is not working.
replaceAll() will not work for dollar ($),doublequotes("),comma(,) etc special characters, in such cases you can go for replace().


split() Example :
-----------------------
package com.myjava.string;
public class MyStrSplit {
    public static void main(String a[]){
     
        String str = "This program splits a string based on space";
        String[] tokens = str.split(" ");
        for(String s:tokens){
            System.out.println(s);
        }
        str = "This     program  splits a string based on space";
        tokens = str.split("\\s+");
    }
}

Sharing tPostgresql Connection


Basic Settings Checkbox Property : Use or register a shared DB Connection

1) Can give the static name or a value thru Context variable.
     Static name should be in double quotes.

2)In the first tPostgresql Connection,  give a static name after providing all connection details in the corresponding properties.

3)From the second tPostgresql connection, you don't have to mention any connection details, except the Use or register a shared DB connection, by giving the same static name which you have given in the first tPostgresql Connection.

Important Property of tParallelize

Basic Settings in tparallelize:

Die when one of parallelize subjobs fail

There is a checkbox for the above in Basic settings.

If we use that, even if  one of the parallelize  subjob fails, then the job will die at that point.

Delimeter you can rely on

In order to put a delimeter for a flat file, which should not be a part of string in the flat file.

Then you can rely on VERTICAL TAB.

Number 11  is for VERTICAL TAB.

The following VALUE should be given in column delimeter property of output file.

String.valueOf((char)11)