talend open studio advanced training material. p2 v080424 copyright © 2008 talend. all rights...

108
TALEND OPEN STUDIO ADVANCED Training Material

Upload: lorraine-barker

Post on 21-Dec-2015

250 views

Category:

Documents


10 download

TRANSCRIPT

Page 1: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

TALEND OPEN STUDIO

ADVANCED

Training Material

Page 2: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p2V080424 Copyright © 2008 Talend. All rights reserved

Copyright

Any total or partial reproduction without the consent of the author or beneficiary, devisee or legatee is not allowed (law of 11 March 1957, par. 1 of article 40). Representation or reproduction, by any means, would be considered an infringement of copyright under articles 425 et.seq. of the Penal Code. The law of 11 March 1957, par. 2 and 3 of article 41, allows the creation of copies and reproductions exclusively for the private use of the copier and not for collective use on the one hand while on the other it allows analysts to use short quotes for purposes of illustration.

Page 3: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p3V080424 Copyright © 2008 Talend. All rights reserved

Summary

Reminders and best practices Context management Mastering complex components Error handling Performance monitoring Monitoring and automating management of log files Deployment and scheduling Exploiting the power of programming languages Routines Debugging Creating components

tCiviliteGenerator (no properties view/retrieval of an exercise) tPrintln (properties view) tDecryptRow or tChangeDevise or tAddColumnTotal tPrintOutput to redirect to printer Virtual component (combining tFileInput and tSortRow)

Page 4: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p4

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Reminders and best practices

Reminders Job designs Lookups

Best practices

Page 5: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p5V080424 Copyright © 2008 Talend. All rights reserved

Job Designer: reminders

A Job: components that are linked to one another

Sub-Job

Job

Page 6: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p6V080424 Copyright © 2008 Talend. All rights reserved

Job Designer: tMap and Lookup

Main and Lookup links set the order of processing

CUSTOMER WITH STATES

Page 7: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p7V080424 Copyright © 2008 Talend. All rights reserved

Job Designer: best practices

Page 8: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p8V080424 Copyright © 2008 Talend. All rights reserved

Job Designer: order of components

Order of execution of components

StartingStartingStartingEnd End End

StartingStarting

End End

Page 9: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p9

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Management of Contexts

Reminders The Context node in the Repository

Dedicated components

Page 10: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p10V080424 Copyright © 2008 Talend. All rights reserved

A context contains several types (dev/prod) The prompt functionality refers to different types of

variables (pathDir, pathFile)

Context management

Page 11: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p11V080424 Copyright © 2008 Talend. All rights reserved

Selecting the execution context

When Talend Open Studio starts:

During deployment:

Page 12: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p12V080424 Copyright © 2008 Talend. All rights reserved

Advice

F5: Declare a variable

The component tRunJob

Page 13: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p13V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 1 and 2

Page 14: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p14

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Mastering complex components

Using regular expressions: tFileRegex tIntervalMatch / tDenormalize XML input, validation & XSL Using Webservices

Page 15: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p15V080424 Copyright © 2008 Talend. All rights reserved

Metadata file regexp

An example of reading an Apache log file

Page 16: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p16V080424 Copyright © 2008 Talend. All rights reserved

tFileInputRegexp

Define a regexp, example of reading from Apache log Aug 18 06:31:29 cplemon02.d075.cp logger: 66.102.9.104 - - [18/Aug/2006:07:49:27 +0200] "GET /server-status/ HTTP/1.1" 200 12891 "-" "CactiScript/1.0" "-" localhost Aug 18 06:31:30 cplemon02.d075.cp logger: 66.102.9.104 - - [18/Aug/2006:07:49:28 +0200] "GET /portail/accueil.pl HTTP/1.1" 200 2907 "-" "CactiScript/1.0" "-" localhost Aug 18 06:31:32 cplemon01.d075.cp logger: 66.102.9.104 - - [18/Aug/2006:08:06:48 +0200] "GET /server-status/ HTTP/1.1" 200 56765 "-" "CactiScript/1.0" "-" localhost

Page 17: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p17V080424 Copyright © 2008 Talend. All rights reserved

tIntervalMatch

Page 18: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p18V080424 Copyright © 2008 Talend. All rights reserved

tNormalize

Page 19: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p19V080424 Copyright © 2008 Talend. All rights reserved

tDenormalize

2

3

Page 20: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p20V080424 Copyright © 2008 Talend. All rights reserved

tXSDValidator

Page 21: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p21V080424 Copyright © 2008 Talend. All rights reserved

tXSLT: generate documents

Page 22: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p22V080424 Copyright © 2008 Talend. All rights reserved

tFileOutputXML: 1 special case

Page 23: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p23V080424 Copyright © 2008 Talend. All rights reserved

tAdvancedFileOutputXML

Page 24: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p24V080424 Copyright © 2008 Talend. All rights reserved

tWebServiceInput

Page 25: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p25

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Error management

Trigger ifOk and ifError Components tLogCatcher / tWarn / tDie Create specific logs

Page 26: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p26V080424 Copyright © 2008 Talend. All rights reserved

Error handling

Each component has its own error handling routine (OnComponentError)

Page 27: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p27V080424 Copyright © 2008 Talend. All rights reserved

tLogCatcher schema

Default schema

Page 28: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p28V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 3: Handling errors

Page 29: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p29V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 4: Customizing error logs

Page 30: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p30

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Performance monitoring

tStatCatcher tFlowMeter

Page 31: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p31V080424 Copyright © 2008 Talend. All rights reserved

tStatCatcher

Monitoring the performance of each component

Page 32: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p32

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Monitoring and automation of log file management

Automating the management of logs Using log files

Page 33: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p33V080424 Copyright © 2008 Talend. All rights reserved

Log management

3 types of log

Manual log management and error management

(Java or Perl errors)

Management of component

execution start, end and duration

Management of metrics

Page 34: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p34V080424 Copyright © 2008 Talend. All rights reserved

Management of logs/preferences

In order to collate logs, configure preferences:

Page 35: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p35V080424 Copyright © 2008 Talend. All rights reserved

Management of logs/preferences

In the Properties and Job Designs view, preferences are entered automatically:

This is in Built-in mode, which is not great for maintaining preferences!

It is better to create metadata in the Repository and specify it in each job.

Page 36: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p36V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 5: Creating the tables that are needed

Page 37: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p37V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 6

Page 38: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p38V080424 Copyright © 2008 Talend. All rights reserved

Activity Monitoring Console /PE

Centralize the monitoring of Talend jobs Single user version Harvesting of all execution server reports

Functionalities Monitoring of:

Events triggered by the jobs Execution time Volumes of processed data

Harvest the local and remoteserver data simultaneously

User-definable interface Integrated in Talend Open Studio or independent

Benefits Single console for all integration jobs Custom indicators and thresholds Global view

Page 39: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p39

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Exploiting the power of programming languages

tGroovy, tJava* & tPerl* Create specific classes/subs Use jars/ external Perl modules

Page 40: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p40V080424 Copyright © 2008 Talend. All rights reserved

GroovyFile component

GroovyFile: a simplified syntax

The script is simply entered in a text file

def name='World';

println "Hello $name";

Page 41: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p41V080424 Copyright © 2008 Talend. All rights reserved

Component execution in 3 stages

tPerlFlex/tJavaFlex component

Starting

loop

End

Start

Main

End

Component tPerlFlex/tJavaFlex: a component in 3 parts

Page 42: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p42V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 7

Use tPerlFlex/tJavaFlex to generate the following flow:

key value

0 Miss

1 Mrs.

2 Mr.

Page 43: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p43V080424 Copyright © 2008 Talend. All rights reserved

Start

Main

End

tJava / tPerl = Start section of a tPerlFlex/tJavaFlex

tJava / tPerl components

Page 44: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p44V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 8:

Create a table and use it in tMap

Page 45: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p45V080424 Copyright © 2008 Talend. All rights reserved

Start

Main

End

tJava / tPerl = Main section of a tJavaFlex / tPerlFlex

tJavaRow / tPerlRow components

Page 46: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p46V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 9:

Use a tPerlRow/tJavaRow to modify a flow:

INPUT OUTPUT

0 Miss

1 Mrs.

2 Mr.

Page 47: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p47V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 10: Use tPerlRow/tJavaRow to modify the flow:

INPUT OUTPUT

NSS month yeardepartment

2700392000000 03 1970 92

1760991000000 09 1976 91

Page 48: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p48

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Exploiting the power of programming languages

Master the complex components: tGroovy, tJava & tPerl Create specific classes/subs Use jars/ external Perl modules

Page 49: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p49V080424 Copyright © 2008 Talend. All rights reserved

Editor with embedded Java/Perl

Integrated Java / Perl editor Auto-complete Syntax-based colours Explanation of errors Javadoc / Perldoc

More information about the Java editor

http://jmdoudoux.developpez.com/java/eclipse/?page=Chap_006#L6.4

Page 50: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p50V080424 Copyright © 2008 Talend. All rights reserved

Managing shared code: routines

Structure your classes and subs Group together existing:

Business classes Connectors

Page 51: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p51V080424 Copyright © 2008 Talend. All rights reserved

Creating a class or a sub

Example: Java Class

The comments allow you to make the method available in

Expression Builder and tRowGenerator

Page 52: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p52V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 11: Create that allows the following to be extracted from an NSS:

Month Year Department

INPUT OUTPUT

NSS month year dept

2700392000000 03 1970 92

1760991000000 09 1976 91

Page 53: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p53

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Exploiting the power of programming languages

Mastering complex components: tGroovy, tJava & tPerl Create specific classes/subs Use jars/ external Perl modules

Page 54: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p54V080424 Copyright © 2008 Talend. All rights reserved

Use a jar file or an external module

The external jar files are declared in a routine

Page 55: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p55V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 12: Import the jakarta-oro-2.0.8.jar package Create a routine isValideEmail()

public static boolean isValideEmail(String email) { Perl5Matcher matcher = new Perl5Matcher(); Perl5Compiler compiler = new Perl5Compiler(); Pattern pattern; try { pattern = compiler.compile("^[\\w_.-]+@[\\w_.-]+\\.[\\w]+$"); if (!matcher.matches(email, pattern)) { return false; } } catch (MalformedPatternException e) { throw new RuntimeException(e); } return true; }

Page 56: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p56V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 13: Create a job and name it UseJar Use the function IsValideEmail()

Page 57: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p57

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Implementing jobs

Advanced debugging mode Define Breakpoints Learn step-by-step mode (step in, step into, step over) View variables in real time “Hot fix” variables in memory

Page 58: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p58V080424 Copyright © 2008 Talend. All rights reserved

Debug view

"Step-by-step" mode Hot fix variables

JasperETL

On-line resources

http://www.jmdoudoux.fr/java/dejae/chap008.htm

Page 59: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p59V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 14: Using the debugger

Page 60: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p60

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Implementing jobs

Deploy your jobs to a production system Export your jobs

Executable Web services

Launch your jobs from the command line Plan execution of your jobs via a scheduler

Page 61: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p61V080424 Copyright © 2008 Talend. All rights reserved

Deployment and optimisation

Deploy jobs Retrieve the generated code Conditions under which they function

Page 62: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p62V080424 Copyright © 2008 Talend. All rights reserved

Deploy a web service

Page 63: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p63V080424 Copyright © 2008 Talend. All rights reserved

Talend products and deployment

Talend Integration Suite

• Shares Repository• Job Conductor• Activity Monitoring Console / Dashboard• Distant Run• Grid Conductor• CPU Balancer

Talend on Demand

• Hosted Repository

Su

bs

criptio

n

GP

L

Op

en S

ou

rce

En

terprise

Ind

ividu

al

Activity Monitoring Console/Personal Edition

Talend Open Studio

• Business Modeler• Job Designer• Metadata Manager

Deploy your jobs remotelyDeploy your jobs remotely

Page 64: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p64

Let's carry on!

V080424 Copyright © 2008 Talend. All rights reserved

Implementing jobs

Create your own components: design and implementation Understand the concepts of code generation via a template Understand the 3 template files: start/main/end Understand the XML description of components Internationalize your components

Page 65: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p65V080424 Copyright © 2008 Talend. All rights reserved

Architecture of Talend Open Studio

Talend Open Studio

Business

Model

XML

Job

XML ...

Perl

Jet Template

Java

Jet Template

C

Jet Template

Perl Program

Java Program

C Program

Storage

CodeGenerator

GeneratedProgram

GUI

Pre

lim

inar

y sk

ills

: JA

VA

1.5

Pre

lim

inar

y sk

ills

: P

erl

5.8

Page 66: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p66V080424 Copyright © 2008 Talend. All rights reserved

Execution of components

Order in which components are executed

StartingStartingStartingEnd End End

StartingStarting

End End

Page 67: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p67V080424 Copyright © 2008 Talend. All rights reserved

Design a specific component

tJavaFlex / tPerlFlex : Start: action triggered by calling the component Main: action triggered with each line of data End: action triggered at the end of processing

Page 68: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p68V080424 Copyright © 2008 Talend. All rights reserved

Module containing components

The module org.talend.designer.components.localprovider

Do not modify this file by hand!

Page 69: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p69V080424 Copyright © 2008 Talend. All rights reserved

User components

Store your components in a specific file

Page 70: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p70V080424 Copyright © 2008 Talend. All rights reserved

Component’s Designer

Your components currently in development

Page 71: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p71V080424 Copyright © 2008 Talend. All rights reserved

Best practices

Differentiate between your development and production environments!

Install an instance of TOS to develop your components

Install an instance of TOS or of TIS Client to manage your Talend projects

Simply separating the storage folders for production and development components is not sufficient.

Page 72: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p72V080424 Copyright © 2008 Talend. All rights reserved

Component files

<component>_<language>.xml Description of a component

<component>_icon32.png The Palette icon

<component>_messages.properties The contents of the properties view

<component>_begin.<language>jet The Start part of the code

<component>_main.<language>jet The Main part of the code (the loop)

<component>_end.<language>jet The End part of the code

Page 73: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p73V080424 Copyright © 2008 Talend. All rights reserved

Working with files

The Component Designer view

Page 74: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p74V080424 Copyright © 2008 Talend. All rights reserved

<component>_<language>.xml

<component>_<language>.xml, description of component The Header tag presents the attributes

AUTHOR, VERSION, COMPATIBILITY STARTABLE SCHEMA_AUTO_PROPAGATE DATA_AUTO_PROPAGATE

The CONNECTORS tag contains: <CONNECTOR CTYPE="FLOW" MAX_INPUT="0"/> <CONNECTOR CTYPE="ITERATE"

MAX_OUTPUT="1" MAX_INPUT="1"/> <CONNECTOR CTYPE="THEN_RUN" MAX_INPUT="1"/> <CONNECTOR CTYPE="RUN_OK"/> <CONNECTOR CTYPE="RUN_ERROR"/> <CONNECTOR CTYPE="RUN_IF"/> <CONNECTOR NAME="UNIQUE" CTYPE="FLOW"

COLOR="086438" BASE_SCHEMA="FLOW" /> <CONNECTOR NAME="DUPLICATE" CTYPE="FLOW"

LINE_STYLE="2" COLOR="f36300" BASE_SCHEMA="FLOW" /> PARAMETERS...following page ;)

http://www.talendforge.org/wiki/doku.php?id=component_creation#xml_description

Page 75: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p75V080424 Copyright © 2008 Talend. All rights reserved

<component>_<language>.xml

<component>_<language>.xml, description of component: parameters

<PARAMETER NAME="FILENAME" FIELD="FILE" NUM_ROW="2" REQUIRED="true" >

<DEFAULT>'C:\talend_files\in.csv'</DEFAULT> </PARAMETER>

http://www.talendforge.org/wiki/doku.php?id=component_creation#xml_description

•CHECK•CLOSED_LIST•DIRECTORY•FILE•MEMO•MEMO_PERL

•MEMO_JAVA•MEMO_SQL•PROCESS_TYPE•PROPERTY_TYPE•SCHEMA_TYPE•TABLE•TEXT

The different forms of FIELD

Page 76: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p76V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 15: First component! Objective is to understand the description xml file

Page 77: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p77V080424 Copyright © 2008 Talend. All rights reserved

Internationalize these components

CompoName_messages_zh.properties

Page 78: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p78V080424 Copyright © 2008 Talend. All rights reserved

JET Templates

Eclipse Modeling Framework (EMF) contains a very powerful tool for generating source code: JET (Java Emitter Templates)

Page 79: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p79V080424 Copyright © 2008 Talend. All rights reserved

JET Templates: general information

JET Template is made up of several parts: The code to be generated The functional code allowing you to determine the

parameters of the code to be generated

<%

/*Java code which will not be included in the generated code

otherwise called the functional code

*/

%>

/* Jave Code constituting the generated code*/

Page 80: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p80V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 16: First JET Templates!

Page 81: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p81V080424 Copyright © 2008 Talend. All rights reserved

JET Templates / Start :: imports

JET Templates header

Then provides information according to the functionality of components

<%@ jet imports="   

org.talend.core.model.process.INode org.talend.core.model.process.ElementParameterParser org.talend.core.model.metadata.IMetadataTable org.talend.core.model.metadata.IMetadataColumn org.talend.designer.codegen.config.CodeGeneratorArgument java.util.List

"

%>

Page 82: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p82V080424 Copyright © 2008 Talend. All rights reserved

JET Templates / tPrint

The tPrint component:

<%@ jet imports="

org.talend.core.model.process.INode org.talend.core.model.process.ElementParameterParserorg.talend.designer.codegen.config.CodeGeneratorArgument

"%><% CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument; INode node = (INode)codeGenArgument.getArgument(); String msg = ElementParameterParser.getValue(node, "__COMMENTAIRE__");%> String msg = <%=msg %>; if(msg.equals("")) { System.out.println("Message is empty"); } else { System.out.println(msg); }

Page 83: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p83V080424 Copyright © 2008 Talend. All rights reserved

JET Templates/tPrint/generated code

Generated code

String msg = "nbrLignes: " + ((Integer)globalMap.get("tLogRow_1_NB_LINE")) ;

if(msg.equals("")) { System.out.println("Message is empty"); } else { System.out.println(msg); }

Page 84: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p84V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 17: Create the component tPrint A single parameter: Comments

Use it in a job!

Page 85: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p85V080424 Copyright © 2008 Talend. All rights reserved

JET Templates/error management

Native handling: when a Java exception occurs The OnError link is triggered instead of the OnOk link The variable compoName_ERROR_MESSAGE is instantiated The error message is sent to tLogCatcher

Manual handling: compoName_ERROR_MESSAGE must be instantiated throw new Exception("myErrorMessage"); System.err.println("myErrorMessage");

Page 86: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p86V080424 Copyright © 2008 Talend. All rights reserved

JET Templates / tPrint

Handling an error in the tPrint component:

<%@ jet imports="

org.talend.core.model.process.INode org.talend.core.model.process.ElementParameterParserorg.talend.designer.codegen.config.CodeGeneratorArgument

"%><% CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument; INode node = (INode)codeGenArgument.getArgument(); String msg = ElementParameterParser.getValue(node, "__MSG2PRINT__");

String cid = node.getUniqueName(); %>String msg = <%=msg %>; if(msg.equals("")) { String errMsg = "<%=cid %>: message is empty"; globalMap.put("<%=cid %>_ERROR_MESSAGE", errMsg); System.err.println(errMsg); throw new Exception(errMsg); } else { System.out.println(msg); }

Page 87: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p87V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 18: Manage errors from within a component Create the component tPrint Display an alert in the case of an empty message Trigger the OnError link

Page 88: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p88V080424 Copyright © 2008 Talend. All rights reserved

JET Templates

Eclipse Modeling Framework (EMF) contains a very powerful tool for generating source code: JET (Java Emitter Templates)

In Talend, the JET Templates are split into 3 parts:

Start

Main

End

Page 89: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p89V080424 Copyright © 2008 Talend. All rights reserved

tInputCivilite

Page 90: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p90V080424 Copyright © 2008 Talend. All rights reserved

Define a schema by default

<PARAMETERS> <PARAMETER NAME="SCHEMA" FIELD="SCHEMA_TYPE"  REQUIRED="true" NUM_ROW="1" READONLY="true"> <TABLE> <COLUMN NAME="id" TYPE="id_Integer" LENGTH="1"/> <COLUMN NAME="value" TYPE="id_String" LENGTH="30"/> </TABLE> </PARAMETER> </PARAMETERS>

<PARAMETERS> <PARAMETER NAME="SCHEMA" FIELD="SCHEMA_TYPE"  REQUIRED="true" NUM_ROW="1" READONLY="true"> <TABLE> <COLUMN NAME="id" TYPE="id_Integer" LENGTH="1"/> <COLUMN NAME="value" TYPE="id_String" LENGTH="30"/> </TABLE> </PARAMETER> </PARAMETERS>

Page 91: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p91V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 19: Create the tInputCivilite (or tInputtitle) component Configure the xml file and properties Create the 3 JET Templates

Page 92: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p92V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 20: Manipulate multiple flows Modify the xml file in order to allow multiple outputs Modify the main Jet Template

Page 93: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p93V080424 Copyright © 2008 Talend. All rights reserved

Mode Row: Propagation of the schema

Let's pass to the Row components

Page 94: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p94V080424 Copyright © 2008 Talend. All rights reserved

Propagation of the schema/ the code

Page 95: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p95V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 21: Create a tDemoRow component

Page 96: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p96V080424 Copyright © 2008 Talend. All rights reserved

tInt2StringCiviliteRow

Page 97: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p97V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 22: Produce the tInt2StringCivilite component Begin: initialize the String [] valueArray table Main: loop on the columns and determine the content of the

column __CIVILITEOUT__

Page 98: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p98V080424 Copyright © 2008 Talend. All rights reserved

tReplaceCiviliteRow

<PARAMETERS> <PARAMETER NAME="CIVILITEOUT"  FIELD="TEXT" REQUIRED="true"  NUM_ROW="1" NB_LINES="1"> <DEFAULT>"newColumn"</DEFAULT> </PARAMETER> </PARAMETERS>

<PARAMETERS> <PARAMETER NAME="CIVILITEOUT"  FIELD="TEXT" REQUIRED="true"  NUM_ROW="1" NB_LINES="1"> <DEFAULT>"newColumn"</DEFAULT> </PARAMETER> </PARAMETERS>

Page 99: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p99V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 23: Produce the tRowCivility component

Page 100: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p100V080424 Copyright © 2008 Talend. All rights reserved

Reject

Case where the key is superior to 2

Page 101: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p101V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 24: Manage a reject flow

Page 102: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p102V080424 Copyright © 2008 Talend. All rights reserved

Load a jar into a component

Page 103: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p103V080424 Copyright © 2008 Talend. All rights reserved

Practice area

Exercise 25: Import a Jar into a component

Page 104: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p104V080424 Copyright © 2008 Talend. All rights reserved

Improve the created components

The Java editor allows you to identify unused imports

Page 105: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p105V080424 Copyright © 2008 Talend. All rights reserved

Virtual component

Certain components can use other components in a transparent manner

<CODEGENERATION> <TEMPLATES INPUT="AGGOUT" OUTPUT="AI"> <TEMPLATE NAME="AGGOUT" COMPONENT="tAggregateOut"> <LINK_TO NAME="AI" CTYPE="THEN_RUN"/> </TEMPLATE> <TEMPLATE NAME="AI" COMPONENT="tArrayIn"/> <TEMPLATE_PARAM SOURCE="self.OPERATIONS"

<TEMPLATE_PARAM SOURCE="self.OPERATIONS" <TEMPLATE_PARAM SOURCE="self.GROUPBYS" 

TARGET="AGGOUT.GROUPBYS"/> <TEMPLATE_PARAM SOURCE="self.SCHEMA"

TARGET="AGGOUT.SCHEMA"/> <TEMPLATE_PARAM SOURCE="self.SCHEMA "

TARGET="AI.SCHEMA"/> <TEMPLATE_PARAM SOURCE="self.UNIQUE_NAME"

TARGET="AGGOUT.DESTINATION"/> <TEMPLATE_PARAM SOURCE="self.UNIQUE_NAME "  

TARGET="AI.ORIGIN" /> </TEMPLATES> </CODEGENERATION>

Page 106: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p106V080424 Copyright © 2008 Talend. All rights reserved

Component and graphic interface

The use of the graphic user interface by a component requires the creation of a dedicated plugin

Page 107: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p107V080424 Copyright © 2008 Talend. All rights reserved

Rely on the Talend community

Your tools: Wiki BugTracker

Exchange with the community: Forum Ecosystem

Page 108: TALEND OPEN STUDIO ADVANCED Training Material. p2 V080424 Copyright © 2008 Talend. All rights reserved Copyright Any total or partial reproduction without

p108

Congratulations!

V080424 Copyright © 2008 Talend. All rights reserved

Contact : [email protected]

Your turn to play!