Create a job using Java

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.