码迷,mamicode.com
首页 > 编程语言 > 详细

使用java创建job

时间:2017-11-07 16:18:43      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:mes   follow   try   nsf   public   star   return   target   generate   

搬运原地址

/**
* This method generates a job definition from scratch. 
* 
* It demonstrates the following:
* 
* - Creating a new job
* - Creating and connecting job entries
* 
* @return the generated job definition
*/
public JobMeta generateJob() {

try {
System.out.println("Generating a job definition");


// create empty transformation definition
JobMeta jobMeta = new JobMeta();
jobMeta.setName("Generated Demo Job");


// ------------------------------------------------------------------------------------ 
// Create start entry and put it into the job
// ------------------------------------------------------------------------------------
System.out.println("- Adding Start Entry");

// Create and configure start entry
JobEntrySpecial start = new JobEntrySpecial();
start.setName("START");
start.setStart(true);

// wrap into JobEntryCopy object, which holds generic job entry information
JobEntryCopy startEntry = new JobEntryCopy(start);

// place it on Spoon canvas properly
startEntry.setDrawn(true);
startEntry.setLocation(100, 100);

jobMeta.addJobEntry(startEntry);

// ------------------------------------------------------------------------------------ 
// Create "write to log" entry and put it into the job
// ------------------------------------------------------------------------------------
System.out.println("- Adding Write To Log Entry");

// Create and configure entry
JobEntryWriteToLog writeToLog = new JobEntryWriteToLog();
writeToLog.setName("Output PDI Stats");
writeToLog.setLogLevel(LogLevel.MINIMAL);
writeToLog.setLogSubject("Logging PDI Build Information:");
writeToLog.setLogMessage("Version: ${Internal.Kettle.Version}\n" +
"Build Date: ${Internal.Kettle.Build.Date}");

// wrap into JobEntryCopy object, which holds generic job entry information
JobEntryCopy writeToLogEntry = new JobEntryCopy(writeToLog);

// place it on Spoon canvas properly
writeToLogEntry.setDrawn(true);
writeToLogEntry.setLocation(200, 100);

jobMeta.addJobEntry(writeToLogEntry); 

// connect start entry to logging entry using simple hop
jobMeta.addJobHop(new JobHopMeta(startEntry, writeToLogEntry));

// ------------------------------------------------------------------------------------ 
// Create "success" entry and put it into the job
// ------------------------------------------------------------------------------------
System.out.println("- Adding Success Entry");

// crate and configure entry
JobEntrySuccess success = new JobEntrySuccess();
success.setName("Success");

// wrap into JobEntryCopy object, which holds generic job entry information
JobEntryCopy successEntry = new JobEntryCopy(success);

// place it on Spoon canvas properly
successEntry.setDrawn(true);
successEntry.setLocation(400, 100);

jobMeta.addJobEntry(successEntry); 

// connect logging entry to success entry on TRUE evaluation 
JobHopMeta greenHop = new JobHopMeta(writeToLogEntry, successEntry);
greenHop.setEvaluation(true);
jobMeta.addJobHop(greenHop);

// ------------------------------------------------------------------------------------ 
// Create "abort" entry and put it into the job
// ------------------------------------------------------------------------------------
System.out.println("- Adding Abort Entry");

// crate and configure entry
JobEntryAbort abort = new JobEntryAbort();
abort.setName("Abort Job");

// wrap into JobEntryCopy object, which holds generic job entry information
JobEntryCopy abortEntry = new JobEntryCopy(abort);

// place it on Spoon canvas properly
abortEntry.setDrawn(true);
abortEntry.setLocation(400, 300);

jobMeta.addJobEntry(abortEntry); 

// connect logging entry to abort entry on TRUE evaluation 
JobHopMeta redHop = new JobHopMeta(writeToLogEntry, abortEntry);
redHop.setEvaluation(true);
jobMeta.addJobHop(redHop);


return jobMeta;


} catch (Exception e) {


// something went wrong, just log and return
e.printStackTrace();
return null;
}


}

 

使用java创建job

标签:mes   follow   try   nsf   public   star   return   target   generate   

原文地址:http://www.cnblogs.com/xiaopan-cp9/p/7656624.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!