Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to Pass Arguments to org.pentaho.di.trans.Trans.execute()

  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Default Question on How to Pass Arguments to org.pentaho.di.trans.Trans.execute()

    Hi,I'm a Java developer and I'm new to Kettle and this forum, so please move this topic to the right place in case I'm in the wrong forum (with apologies).I'm trying to call a Kettle transformation and pass some parameters and their values from a Java application. I've successfully managed to call the transformation with a call to org.pentaho.di.trans.Trans.execute(), but I'm still not sure how to pass the arguments. The API describes this method as execute(String[] arguments); the examples I found pass null to the method (trans.execute(null)). For the sake of this question, say I have two parameters to pass to the transformation: A=1, B=2.Could anyone please show me an example of how I should pass these parameters in the method call?Thanks in advance for your help.Joe
    Last edited by Joe.Nader; 04-04-2012 at 01:09 PM.

  2. #2

    Default

    Joe,The best place to start is with the PDI article @ http://wiki.pentaho.com/display/EAI/...a+API+Examples

    For your reference here is the code fragment

    Code:
           
    System.setProperty("KETTLE_HOME", "/tmp/"); 
    
    KettleEnvironment.init(false); 
    EnvUtil.environmentInit(); 
                   
    TransMeta transMeta = new TransMeta("/tmp/test.ktr"); 
    transMeta.setName("test"); 
    Trans  transformation = new Trans(transMeta); 
    
    // set variavle. same can be retrieved using "Get Variables" step 
    transformation.setVariable("TEST_VARIABLE_FROM_JAVA", "This value is passsed from java"); 
                   
    // set parameter. same can be used inside steps in transformation 
    transformation.setParameterValue("JAVA_PARAM", "java param value");
    
    transformation.execute(null);                
    transformation.waitUntilFinished(); 
                   
    // Cleanup the parameters used by the job. 
    transMeta.eraseParameters(); 
    transformation.eraseParameters();
    - Rakesh
    Last edited by rakcheru; 04-08-2012 at 06:15 AM.

  3. #3
    Join Date
    Apr 2012
    Posts
    2

    Default

    Thank you very much Rakesh; this works for me. I appreciate your help.

    Joe

  4. #4

    Default

    hey can you post the ktr file please ?
    Regards,
    Atul Darne.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.