Setting up the parent Job
Procedure
-
Create a new Job named ParentJob and add a
tFileInputDelimited component, a
tFlowToIterate component, a
tRunJob, and two tJava
components to it.
- Connect the tFileInputDelimited component to the tFlowToIterate component using a Row > Main connection; the tFlowToIterate component to the second tJava component using a Row > Iterate connection; the second tJava component to the first tJava component using a Trigger > Run if connection; and the second tJava component to the tRunJob component using a Trigger > Run if connection.
-
Double-click the tFileInputDelimited component to open
its Basic settings view.
- Click the [...] button next to Edit schema and in the pop-up dialog box, define the schema of the input data by adding two columns: Job_Name of String type and Execute of Boolean type. When done, click OK to close the dialog box.
- Click the [...] button next to File name/Stream frame; navigate to the folder where the file File_For_Execute.txt resides; and select the file.
- Type the character used to separate fields in the the file File_For_Execute.txt in Field Separator ("," in this example).
- Set the Header field to 1.
-
Select the connection between the two tJava components. Enter the following in the
Condition field in the Component view to catch the rejected Jobs:
!((Boolean)globalMap.get("row1.Execute"))
-
Select the connection between the tJava_2 component and the tRunJob_1 components. Enter the following in the Condition field in the Component view to trigger the execution of the
Jobs with the Execute field being true:
((Boolean)globalMap.get("row1.Execute"))
-
Double-click the tRunJob component to open its
Basic settings view.
- Select the Use dynamic job check box and in the Context job field displayed, press Ctrl+Space and from the list of variables select the iterative global variable created by the tFlowToIterate component, tFlowToIterate_1.Job_Name in this example. The Context job field is then filled with ((String)globalMap.get("row1.Job_Name")). Upon each iteration, this variable will be resolved as the name of the Job to be called.
- Click the [...] button next to the Job field and in the [Select Job] dialog box, select all the Jobs you want to run and click OK to close the dialog box. In this example, they are ChildJob1 through ChildJob5.
-
Double-click the tJava_1 component to open its Basic
settings view. Enter the following in the Code field to log the rejected child
Jobs.
System.out.println("----------------------------------"); System.out.println("MESSAGE : " + ((String)globalMap.get("row1.Job_Name")) + " JOB hasn't been selected for execution ... "); System.out.println("----------------------------------");
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!