Handling of the original address
/*** This method generates a job definition from scratch. * * It demonstrates the following:* *-Creating a new job*-C reating and connecting Job Entries* *@returnThe generated job definition*/ PublicJobmeta generatejob () {Try{System.out.println ("Generating a job definition");//Create empty transformation definitionJobmeta Jobmeta =NewJobmeta (); Jobmeta.setname ("Generated Demo Job");// ------------------------------------------------------------------------------------ //Create start entry and put it into the job// ------------------------------------------------------------------------------------System.out.println ("-Adding Start Entry");//Create and configure start entryJobentryspecial start =Newjobentryspecial (); Start.setname ("START"); Start.setstart (true);//wrap into Jobentrycopy object, which holds generic job entry informationJobentrycopy Startentry =Newjobentrycopy (start);//Place it on Spoon canvas properlyStartentry.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 entryJobentrywritetolog WriteToLog =NewJobentrywritetolog (); 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 informationJobentrycopy Writetologentry =Newjobentrycopy (writetolog);//Place it on Spoon canvas properlyWritetologentry.setdrawn (true); Writetologentry.setlocation (200, 100); Jobmeta.addjobentry (writetologentry); //Connect Start entry to logging entry using simple hopJobmeta.addjobhop (NewJobhopmeta (Startentry, Writetologentry));// ------------------------------------------------------------------------------------ //Create "Success" entry and put it into the job// ------------------------------------------------------------------------------------System.out.println ("-Adding Success Entry");//Crate and configure entryJobentrysuccess success =Newjobentrysuccess (); Success.setname ("Success");//wrap into Jobentrycopy object, which holds generic job entry informationJobentrycopy Successentry =Newjobentrycopy (success);//Place it on Spoon canvas properlySuccessentry.setdrawn (true); Successentry.setlocation (400, 100); Jobmeta.addjobentry (successentry); //Connect logging entry to Success entry on TRUE evaluationJobhopmeta Greenhop =NewJobhopmeta (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 entryJobentryabort abort =NewJobentryabort (); Abort.setname ("Abort Job");//wrap into Jobentrycopy object, which holds generic job entry informationJobentrycopy Abortentry =Newjobentrycopy (abort);//Place it on Spoon canvas properlyAbortentry.setdrawn (true); Abortentry.setlocation (400, 300); Jobmeta.addjobentry (abortentry); //Connect logging entry to abort entry on TRUE evaluationJobhopmeta Redhop =NewJobhopmeta (Writetologentry, abortentry); Redhop.setevaluation (true); Jobmeta.addjobhop (redhop);returnJobmeta;} Catch(Exception e) {//something went wrong, just log and returne.printstacktrace ();return NULL;}}
Create a job using Java