KETTLE+JAVA+API+开发实战记录

发布时间 : 星期一 文章KETTLE+JAVA+API+开发实战记录更新完毕开始阅读

else selectSQL+=\ \

selectSQL+=sourceFields[i]+Const.CR;

}

selectSQL+=\

tii.setSQL(selectSQL);

StepLoader steploader = StepLoader.getInstance();

String fromstepid = steploader.getStepPluginID(tii);

StepMeta fromstep = new StepMeta(log, fromstepid, fromstepname, (StepMetaInterface) tii);

fromstep.setLocation(150, 100);

fromstep.setDraw(true);

fromstep.setDescription(\

+ \

transMeta.addStep(fromstep);

//

// add logic to rename fields

// Use metadata logic in SelectValues, use SelectValueInfo...

//

/* 不必改名或映射 add by chq(www.chq.name) on 2006.07.20

SelectValuesMeta svi = new SelectValuesMeta();

svi.allocate(0, 0, sourceFields.length);

for (int i = 0; i < sourceFields.length; i++)

{

svi.getMetaName()[i] = sourceFields[i];

svi.getMetaRename()[i] = targetFields[i];

}

String selstepname = \

String selstepid = steploader.getStepPluginID(svi);

StepMeta selstep = new StepMeta(log, selstepid, selstepname, (StepMetaInterface) svi);

selstep.setLocation(350, 100);

selstep.setDraw(true);

selstep.setDescription(\

transMeta.addStep(selstep);

TransHopMeta shi = new TransHopMeta(fromstep, selstep);

transMeta.addTransHop(shi);

fromstep = selstep; //设定了新的起点 by chq([link=http://www.chq.name]www.chq.name[/link]) on 2006.07.20

*/

//

// Create the target step...

//

//

// Add the TableOutputMeta step...

//

String tostepname = \

TableOutputMeta toi = new TableOutputMeta();

toi.setDatabase(targetDBInfo);

toi.setTablename(targetTableName);

toi.setCommitSize(200);

toi.setTruncateTable(true);

String tostepid = steploader.getStepPluginID(toi);

StepMeta tostep = new StepMeta(log, tostepid, tostepname, (StepMetaInterface) toi);

tostep.setLocation(550, 100);

tostep.setDraw(true);

tostep.setDescription(\information to table [\+ targetTableName + \on database [\

transMeta.addStep(tostep);

//

// Add a hop between the two steps...

//

TransHopMeta hi = new TransHopMeta(fromstep, tostep);

transMeta.addTransHop(hi);

// OK, if we're still here: overwrite the current transformation...

return transMeta;

}

catch (Exception e)

{

throw new KettleException(%unexpected error occurred creating the new transformation\

}

}

/**

* 1) create a new transformation

* 2) save the transformation as XML file

* 3) generate the SQL for the target table

* 4) Execute the transformation

* 5) drop the target table to make this program repeatable

*

* @param args

*/

联系合同范文客服:xxxxx#qq.com(#替换为@)