Thursday, November 3, 2011

jQuery Plugn for Refreshable DIV


I have created a jQuery plugin which can be used in an Ajax enabled websites to refresh the div content. The plugin can be found here.

Where to Use:
         If you have AJAX enabled website and you want to refresh some div contents based on some event on the web page in that case this plugin can be used.
        
How to use:
         In an html page add the script tag for jQuery and refresher plugin script.
        

          <script type="text/javascript" src="jquery.js"></script>
          <script type="text/javascript" src="jquery.refresh.js"></script>

         
          For demo purpose will take a simple example where I have say three DIV's whose contents need to be refresehd with the current date and time when "Refresh Div" link is clicked.
         
          So in body we will write
         
          <body>
             <a id="refreshDiv" href="#">Refresh Div</a>
             <div id="first" >First Div: Content to replace</div>
             <div id="second">Second Div: Content to replace</div>
             <div id="third" style="display:none">Third Div: Content to replace</div>
           </body>

         
          We will add a click event handler on the link using jQuery.
          Line $("div").refresh(); will select all the div's in the page and will call the refresh method on it.
         
          $(document).ready(function() {
                $("#refreshDiv").click(function() {
                   $("div").refresh();
                });
           });
   
          Now we will define three Javascript functions which will actually refresh the content of the DIV.
         
          first_refresh = function(){
                var time = new Date();
                $("#first").html("First Div: "+time); //your code will go here
            }
            second_refresh = function(){
                    var time = new Date();
                    $("#second").html("Second Div: "+time); //your code will go here
            }
            third_refresh = function(){
                    var time = new Date();
                    $("#third").html("Third Div: "+time); //your code will go here
              }
           
 Then initialize the div's which can be refrehsed on an event. Below is the code snippet where I have defined three method which refreshes the content of three div's
          And then register these functions with the respective div.

          <script type="text/javascript">
             
              first_refresh = function(){
                  var time = new Date();
                  $("#first").html("First Div: "+time); //your code will go here
              }
              second_refresh = function(){
                      var time = new Date();
                      $("#second").html("Second Div: "+time); //your code will go here
              }
              third_refresh = function(){
                      var time = new Date();
                      $("#third").html("Third Div: "+time); //your code will go here
              }
        
             $(document).ready(function() {
                $("#first").refresh('callback_method',first_refresh);
                $("#second").refresh('callback_method',second_refresh);
                $("#third").refresh('callback_method',third_refresh);
               
                $("#refreshDiv").click(function() {
                                   $("div").refresh();
                });
              });
        </script>
 The output should look like something below

Before refresh click:

After refresh click:

Wednesday, September 14, 2011

Restful webservice (Jersey+ Spring 3.0.X + TestNG+ Jetty)

This is simple hello world example for a restful webservice. This example demonstrates the use of the Jersey as an implementation for restful webservice integrated with the Spring. Jersey has a good support for unit testing with JUnit but there are very few examples of how to test Jersey based application using the TestNG. This example will also explain the use of TestNG with Jersey. For a simplicity we will be using the maven Jetty plugin to run our web application.

Maven Configuration:

Create a simple maven webapp project.

Edit the pom.xml file to include the below content.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ameeth.jersey</groupId>
    <artifactId>JerseySpring</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>Jersey Spring Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <jersey.version>1.5</jersey.version>           <org.springframework.version>3.0.3.RELEASE</org.springframework.version>
        <testng.version>5.12.1</testng.version>

    </properties>
    <dependencies>
        <!-- Jersey dependency -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey.jersey-test-framework</groupId>
            <artifactId>jersey-test-framework-grizzly</artifactId>
            <version>${jersey.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>JerseySpring</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <target>1.5</target>
                    <source>1.5</source>
                </configuration>
            </plugin>
            <!-- This plugin is for running a web application directly from Maven. -->
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.10</version>
                <configuration>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>9090</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Spring based Service:

Now we will create a simple service class. This service class will be configured using the Spring 3.0.X
First we will create a interface named "GreetingService" Which will have a single method declaration
 public String sayHello();


package com.ameeth.jersey.service;


/**
 * <p>
 * GreetingService
 * </p>
 * @version 1.0
 * @author Ameeth Paatil
 * @since Sep 14, 2011
 */
public interface GreetingService {
    public String sayHello();
}

Now we will implement the above interface. We will use spring annotation @Service to mark the "GreetingServiceImpl" as service class. The implementation of sayHello method will return a simple String "Hello World!"

package com.ameeth.jersey.service;

import org.springframework.stereotype.Service;

/**
 * <p>
 * GreetingService
 * </p>
 * @version 1.0
 * @author Ameeth Paatil
 * @since Sep 13, 2011
 */
@Service
public class GreetingServiceImpl
    implements GreetingService {

    /**
     * @see com.ameeth.jersey.service.GreetingService#sayHello()
     */
    @Override
    public String sayHello() {
        return "Hello World!";
    }
}


Jersey based Restfulwebservice

Now we will create a simple Root resource which will consume our service to say Hello. The GreetingsResource class is a very simple Web resource. The URI path of the resource is "/greeting" , it supports the HTTP GET and produces text content.


package com.ameeth.jersey.web;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.ameeth.jersey.service.GreetingService;

/**
 * <p>
 * GreetingsResource
 * </p>
 * @version 1.0
 * @author Ameeth Paatil
 * @since Sep 13, 2011
 */
@Path("/greeting")
@Component
@Scope("request")
public class GreetingsResource {

    @Autowired
    private GreetingService service;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String sayHello() {
        return service.sayHello();
    }
}


Webapp configuration:

So we have created a root resource, we have created a service class. We have configured the pom file. Now we will create the basic spring ApplicationContext.xml file. create this file under resources directory.


<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <context:component-scan base-package="com.ameeth.jersey" />
</beans>

The configuration tells the spring container to scan for the components under "com.ameeth.jersey" package.


Now we have added ApplicationContext.xml now its time to configure web.xml

The web.xml should look like something below where first we will configure the spring contextConfigLocation. Then we will add ContextLoaderListener and RequestContextListener
Then define the SpringServle. with the url pattern. This servlet will be responsible to identify all the spring managed rest resource. Configuration parameter can be set to include the jersey managed resources as well.

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Jersey+Spring+TestNG Demo Web Application</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:ApplicationContext.xml
        </param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>jerseyspring</servlet-name>
        <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jerseyspring</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>


Wednesday, August 31, 2011

Hello World With Java & Pentaho

This is a simple java program which takes a transformation "first_transformation.ktr" and executes the transformation



Create a simple Test.java file and execute
 
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;

/**
 * Hello world!
 *
 */
public class Test
{
    public static void main( String[] args )
    {
        try {
            KettleEnvironment.init();
            TransMeta metaData = new TransMeta("first_transformation.ktr");
            Trans trans = new Trans( metaData );
            trans.execute( null );
            trans.waitUntilFinished();
            if ( trans.getErrors() > 0 ) {
                System.out.print( "Error Executing transformation" );
            }
        } catch( KettleException e ) {
            e.printStackTrace();
        }
    }
}


This is the simple transformation created using spoon tool
filename: first_transformation.ktr

<?xml version="1.0" encoding="UTF-8"?>
<transformation>
  <info>
    <name>first_transformation</name>
    <description/>
    <extended_description/>
    <trans_version/>
    <trans_type>Normal</trans_type>
    <directory>&#47;</directory>
    <parameters>
    </parameters>
    <log>
<trans-log-table><connection/>
<schema/>
<table/>
<size_limit_lines/>
<interval/>
<timeout_days/>
<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STATUS</id><enabled>Y</enabled><name>STATUS</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name><subject/></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name><subject/></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name><subject/></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name><subject/></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name><subject/></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name><subject/></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>STARTDATE</id><enabled>Y</enabled><name>STARTDATE</name></field><field><id>ENDDATE</id><enabled>Y</enabled><name>ENDDATE</name></field><field><id>LOGDATE</id><enabled>Y</enabled><name>LOGDATE</name></field><field><id>DEPDATE</id><enabled>Y</enabled><name>DEPDATE</name></field><field><id>REPLAYDATE</id><enabled>Y</enabled><name>REPLAYDATE</name></field><field><id>LOG_FIELD</id><enabled>Y</enabled><name>LOG_FIELD</name></field></trans-log-table>
<perf-log-table><connection/>
<schema/>
<table/>
<interval/>
<timeout_days/>
<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>SEQ_NR</id><enabled>Y</enabled><name>SEQ_NR</name></field><field><id>LOGDATE</id><enabled>Y</enabled><name>LOGDATE</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STEPNAME</id><enabled>Y</enabled><name>STEPNAME</name></field><field><id>STEP_COPY</id><enabled>Y</enabled><name>STEP_COPY</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>INPUT_BUFFER_ROWS</id><enabled>Y</enabled><name>INPUT_BUFFER_ROWS</name></field><field><id>OUTPUT_BUFFER_ROWS</id><enabled>Y</enabled><name>OUTPUT_BUFFER_ROWS</name></field></perf-log-table>
<channel-log-table><connection/>
<schema/>
<table/>
<timeout_days/>
<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>LOGGING_OBJECT_TYPE</id><enabled>Y</enabled><name>LOGGING_OBJECT_TYPE</name></field><field><id>OBJECT_NAME</id><enabled>Y</enabled><name>OBJECT_NAME</name></field><field><id>OBJECT_COPY</id><enabled>Y</enabled><name>OBJECT_COPY</name></field><field><id>REPOSITORY_DIRECTORY</id><enabled>Y</enabled><name>REPOSITORY_DIRECTORY</name></field><field><id>FILENAME</id><enabled>Y</enabled><name>FILENAME</name></field><field><id>OBJECT_ID</id><enabled>Y</enabled><name>OBJECT_ID</name></field><field><id>OBJECT_REVISION</id><enabled>Y</enabled><name>OBJECT_REVISION</name></field><field><id>PARENT_CHANNEL_ID</id><enabled>Y</enabled><name>PARENT_CHANNEL_ID</name></field><field><id>ROOT_CHANNEL_ID</id><enabled>Y</enabled><name>ROOT_CHANNEL_ID</name></field></channel-log-table>
<step-log-table><connection/>
<schema/>
<table/>
<timeout_days/>
<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STEPNAME</id><enabled>Y</enabled><name>STEPNAME</name></field><field><id>STEP_COPY</id><enabled>Y</enabled><name>STEP_COPY</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>LOG_FIELD</id><enabled>N</enabled><name>LOG_FIELD</name></field></step-log-table>
    </log>
    <maxdate>
      <connection/>
      <table/>
      <field/>
      <offset>0.0</offset>
      <maxdiff>0.0</maxdiff>
    </maxdate>
    <size_rowset>10000</size_rowset>
    <sleep_time_empty>50</sleep_time_empty>
    <sleep_time_full>50</sleep_time_full>
    <unique_connections>N</unique_connections>
    <feedback_shown>Y</feedback_shown>
    <feedback_size>50000</feedback_size>
    <using_thread_priorities>Y</using_thread_priorities>
    <shared_objects_file/>
    <capture_step_performance>N</capture_step_performance>
    <step_performance_capturing_delay>1000</step_performance_capturing_delay>
    <step_performance_capturing_size_limit>100</step_performance_capturing_size_limit>
    <dependencies>
    </dependencies>
    <partitionschemas>
    </partitionschemas>
    <slaveservers>
    </slaveservers>
    <clusterschemas>
    </clusterschemas>
  <modified_user>-</modified_user>
  <modified_date>2011&#47;08&#47;31 19:03:08.937</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
  <hop> <from>Generate Rows</from><to>Write to log</to><enabled>Y</enabled> </hop>  </order>
  <step>
    <name>Generate Rows</name>
    <type>RowGenerator</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
         <partitioning>
           <method>none</method>
           <schema_name/>
           </partitioning>
    <fields>
      <field>
        <name>Test</name>
        <type>String</type>
        <format/>
        <currency/>
        <decimal/>
        <group/>
        <nullif>Hello World!</nullif>
        <length>-1</length>
        <precision>-1</precision>
      </field>
    </fields>
    <limit>10</limit>
     <cluster_schema/>
 <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
      <xloc>123</xloc>
      <yloc>213</yloc>
      <draw>Y</draw>
      </GUI>
    </step>

  <step>
    <name>Write to log</name>
    <type>WriteToLog</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
         <partitioning>
           <method>none</method>
           <schema_name/>
           </partitioning>
      <loglevel>log_level_basic</loglevel>
      <displayHeader>Y</displayHeader>
    <fields>
      <field>
        <name>Test</name>
        </field>
      </fields>
     <cluster_schema/>
 <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
      <xloc>331</xloc>
      <yloc>212</yloc>
      <draw>Y</draw>
      </GUI>
    </step>

  <step_error_handling>
  </step_error_handling>
   <slave-step-copy-partition-distribution>
</slave-step-copy-partition-distribution>
   <slave_transformation>N</slave_transformation>
</transformation>

-------




Assuming all the dependent jars are included in class path the above program should result in the following output.

INFO  31-08 19:14:46,992 - first_transformation - Dispatching started for transformation [first_transformation]
INFO  31-08 19:14:47,024 - first_transformation - This transformation can be replayed with replay date: 2011/08/31 19:14:47
INFO  31-08 19:14:47,039 - Generate Rows - Finished processing (I=0, O=0, R=0, W=10, U=0, E=0)
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 1------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 2------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 3------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 4------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 5------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 6------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 7------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 8------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 9------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log -
------------> Linenr 10------------------------------
Test = Hello World!

====================
INFO  31-08 19:14:47,039 - Write to log - Finished processing (I=0, O=0, R=10, W=10, U=0, E=0)


Friday, November 19, 2010

Running pentaho transformation stored in DB reposiotry from Java

Maven Configuration required for kettle

<properties>
        <pentaho.kettle.version>4.0.1-GA</pentaho.kettle.version>
</properties>


<dependency>
            <groupId>pentaho.kettle</groupId>
            <artifactId>kettle-core</artifactId>
            <version>${pentaho.kettle.version}</version>
        </dependency>
        <dependency>
            <groupId>pentaho.kettle</groupId>
            <artifactId>kettle-db</artifactId>
            <version>${pentaho.kettle.version}</version>
        </dependency>
        <dependency>
            <groupId>pentaho.kettle</groupId>
            <artifactId>kettle-engine</artifactId>
            <version>${pentaho.kettle.version}</version>
        </dependency>
        <dependency>
            <groupId>pentaho.kettle</groupId>
            <artifactId>kettle-ui-swt</artifactId>
            <version>${pentaho.kettle.version}</version>
        </dependency>
        <dependency>
            <groupId>pentaho-library</groupId>
            <artifactId>libformula</artifactId>
            <version>1.1.7</version>
            </dependency>
        <dependency>
            <groupId>org.codehaus.janino</groupId>
            <artifactId>janino</artifactId>
            <version>2.5.16</version>
        </dependency>
        <dependency>
            <groupId>rhino</groupId>
            <artifactId>js</artifactId>
            <version>1.7R2</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.1</version>
        </dependency>
  <!-- Assuming the tranformation is stored in MySql database-->
      <dependency>
            <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <version>5.1.17</version>
      </dependency>


Steps for running the Kettle transformation from Java code

Assumption the transformation are stored in the database repository

  • Initialize the kettle environment

                     KettleEnvironment.init();

  • Create a instance of kettle database repository
                     KettleDatabaseRepository repository = new KettleDatabaseRepository();
  • Create a instance of database meta

                    DatabaseMeta databaseMeta = new DatabaseMeta(
      type, type, "", host, databaseName, port, userName, password );
                 
                      type --> Data base type like "MySql"  
                      host --> database server name
                      databaseName --> Schema name
                      port --> Database port e.g 3306 for MySql
                      userName, Password --> To connect to the given database 

  • Create a instance of kettle repository  meta
                      KettleDatabaseRepositoryMeta kettleDatabaseMeta = new KettleDatabaseRepositoryMeta(
      repositoryId, repositoryName, "Transformation description", databaseMeta );

                     repositoryId --> Repository Id
                     repositoryName --> Repository name
                     databaseMeta --> DatabaseMeta defined above
  • Initialize the repository

                     repository.init( kettleDatabaseMeta );
  • Connect to the repository default user name password is "admin", "admin" 

                     repository.connect( repUserName, repPassword );
  • Load the root directory

                     RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree();
  • Read the saved transformation  meta data using the directory and the transformation name
                     TransMeta transformationMeta = repository.loadTransformation(
        transformationName, directory, null, true, null ) ;
  • Create a new transformation object using the transformation meta

                     Trans trans = new Trans( transformationMeta );

  • Set any transformation parameters 

                      trans.setParameterValue( parameterName, parameterValue);

  • Execute the transformation

                     trans.execute( null ); // You can pass arguments instead of null.
  • Wait till the transformation finish

                     trans.waitUntilFinished();
  • Check for any errors during the execution                    
                     if ( trans.getErrors() > 0 ) {                    
                               //Errors running transformation.
                     }else{
                               //Transformation run successfully.
                     }