Contoh pemanggilan Transformation (dan Job) Pentaho Data Integration di Java

Posted: May 21, 2015 in IT and Programming Stuff
Tags: , , ,

Library versi terbaru di maven repo masih ada bug. Sebaiknya ambil dari versi sebelumnya langsung dari instalasi PDI. Saya sudah coba pakai versi 5.0.1

Library yang dibutuhkan:
kettle5-log4j-plugin-5.0.1-stable.jar
kettle-core-5.0.1-stable.jar
kettle-dbdialog-5.0.1-stable.jar
kettle-engine-5.0.1-stable.jar
kettle-jdbc-5.0.1-stable.jar
kettle-ui-swt-5.0.1-stable.jar

================================================
private void executeTransformation() throws KettleException{
/**
* Initialize the Kettle Enviornment
*/
KettleEnvironment.init();

/**
* Create a trans object to properly assign the ktr metadata.
*
* @filedb: The ktr file path to be executed.
*
*/
String file = “resources/fee.ktr”;
TransMeta metadata = new TransMeta(file);
Trans trans = new Trans(metadata);

// Execute the transformation
trans.execute(null);
trans.waitUntilFinished();

// checking for errors
if (trans.getErrors() > 0) {
System.out.println(“Error Executing Transformation”);
}
}

private void executeJob(){
String file=”resources/backup-excel.kjb”; //Job file path that needs to be executed
Repository repository=null; //Checking for repository

try {
KettleEnvironment.init();

JobMeta jobmeta=new JobMeta(file,repository);
Job job=new Job(repository, jobmeta);

job.start();
job.waitUntilFinished();

if(job.getErrors()>0){
System.out.println(“Error Executing Job”);
}

} catch (KettleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s