bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

Creating Basic Task Flows

Receiving arguments and parameters in a job:

Jobs, as well as transformations, are more flexible when receiving parameters from outside.

Get the Pentaho training online for taking your career to the next level.

Customizing the hello world file with arguments and parameters:

  1. Create a new transformation.
  2. Press Ctrl+T to bring up the Transformation properties window.
  3. Select the Parameters tab.
  4. Add a named parameter HELLOFOLDER. Insert Name as the default value.
  5. Click on OK.
  6. Drag a Get System Info step to the canvas .
  7. Double-click the step.
  8. Add a field named your name. Select command line argument 1 as the Type.
  9. Click on OK.
  10. Now add a Formula step located in the Scripting category of steps.
  11. Use the step to add a String field named message. As Formula, type “Hello, ” & [yourname] & “!”.
  12. Finally, add a Text file output step.
  13. Use the step to send the message data to a file. Enter ${LABSOUTPUT}/${HELLOFOLDER}/hello as the name of the file.
  14. Save the transformation in the transformations folder you created in the previous tutorial, under the name hello_world_param.ktr.
  15. Open the hello_world.kjb job you created in the previous tutorial and save it under a new job named hello_world_param.kjb.
  16. Press Ctrl+J to open the Job properties window.
  17. Select the Parameters tab.
  18. Add the same named parameter you added in the transformation.

 

1

 

 

  1. Click on OK.
  2. Double-click the Create a folder entry.
  3. Change the Folder name textbox content to ${LABSOUTPUT}/${HELLOFOLDER}.
  4. Double-click the Transformation entry.
  5. Change the transformation filename textbox to point to the new transformation: ${Internal.Job.Filename.Directory}/transformations/hello_world_ param.ktr.
  6. Click on OK.
  7. Save the job and run it.
  8. Fill the dialog window with a value for the named parameter and a value for the command-line argument.

 

1

 

 

  1. Click on Launch.
  2. When the execution finishes, check the output folder. The folder named my_folder, which you initially specified as a named parameter, should be created.
  3. Inside that folder there should be a file named hello.txt. This time the content of the file has been customized with the name you provided:

Hello, pdi student!

 

Running jobs from a terminal window:

The transformation also required a command-line argument. When you executed the job from Spoon, you provided both the parameter and the argument in the job dialog window. You will now learn to launch the job and provide that information from a terminal window.

 

Executing the hello world job from a terminal window:

  1. Open a terminal window.
  2. Go to the directory where Kettle is installed.

 

On Windows systems type:

C:\pdi-ce>kitchen /file:c:/pdi_labs/hello_world_param.kjb Maria -param:"HELLOFOLDER=my_work" /norep

On Unix, Linux, and other Unix-like systems type:

/home/yourself/pdi-ce/kitchen.sh /file:/home/yourself/ pdi_labs/hello_world_param.kjb Maria -param:"HELLOFOLDER= my_work" /norep
  1. If your job is in another folder, modify the command accordingly. You may also replace the name Maria with your name, of course. If your name has spaces, enclose the whole argument within “”.
  2. You will see how the job runs, following the log in the terminal:

 

1

 

 

  1. Go to the output folder—the folder pointed by your LABS_OUTPUT variable.
  2. A folder named my_work should have been created.
  3. Check the content of the folder. A file named hello.txt should be there. Edit the file. You should see the following:

Hello,Maria!

 

Using named parameters and command-line arguments in transformations:

As you know, transformations accept both arguments from the command line and named parameters. When you run a transformation from Spoon, you supply the values for arguments and named parameters in the transformation dialog window that shows up when you launch the execution. From a terminal window, you provide those values in the Pan command line.

 

Calling the hello world transformation with fixed arguments and parameters:

  1. Open the hello_world.kjb job you created in the first section and save it as hello_world_fixedvalues.kjb.
  2. Double-click the Create a folder job entry.
  3. Replace the chapter10 string by the string fixedfolder.
  4. Double-click the transformation job entry.
  5. Change the Transformation filename as ${Internal.Job.Filename. Directory}/transformations/hello_world_param.ktr.
  6. Fill the Argument tab as follows.

 

1

 

 

  1. Click the Parameters tab and fill it as follows:

 

1

 

 

  1. Click on OK.
  2. Save the job.
  3. Open a terminal window and go to the directory where Kettle is installed.

On Windows systems type:

C:\pdi-ce>kitchen /file:c:/pdi_labs/ hello_world_param.kjb /norep

On Unix, Linux, and other Unix-like systems type:

/home/yourself/pdi-ce/kitchen.sh /file:/home/yourself/ pdi_labs/hello_world_param.kjb /norep
  1. When the execution finishes, check the output folder. A folder named fixedfolder has been created.
  2. In that folder, you can see a hello.txt with the following content:

Hello, reader!

 

Running job entries under conditions:

A job may contain any number of entries. Not all of them execute always. Some of them execute depending on the result of previous entries in the flow.

 

Sending a sales report and warning the administrator if something is wrong:

  1. As the report will be based on the Jigsaw database you created in Chapter 8, you will need the MySQL server running.
  2. In order to send e-mails, you will need at least one valid Gmail account. Sign up for an account. Alternatively, if you are familiar with you own SMTP configuration, you could use it instead.

"0 Responses on Creating Basic Task Flows"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 04th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free Creating Basic Task Flows.