Be careful to open all nodes specified in the directions to connect the correct items. The completed business appears as follows in the Java Collaboration Definition Editor's Business Rules Designer.
From the Project Explorer tree, double-click jcdBatch_Record.
The Java Collaboration Editor opens to the jcdBatch_Record Collaboration.
To create commentsfor the Business Rules, from the Business Rules toolbar, click the comment icon.
The Enter a Comment dialog box appears. The comment is placed on the Business Rules tree under the last selected item.
Enter the comment and click OK.
Once the Comment is created, it can be moved by clicking the comment and dragging it up or down the Business Rules tree to a new location.
Create the Create uninitialized variable loopCount (of type int) variable:
The Create uninitialized variable loopCount (of type int) rule defines a loop count integer variable
Create the Create uninitialized variable recordStr (of type String) variable:
The Create uninitialized variable recordStr (of type String) rule defines String called recordStr .
From the Business Rules toolbar, click the Local Variable icon.
The Create Variable dialog box appears.
Enter recordStr as the name of the variable.
From the Create Variable dialog box Type field, select Class and click the ellipsis (...) button.
The Class Browser dialog box appears.
From the Class Browser dialog box, select String in the All Classes field, and select String in the String field.
Click Select to close the Class Browser dialog box and click OK to close the Create Variable dialog box.
The new variable is added to the Business Rules tree.
Create the For Loop:
The For Loop and its Business Rules create ten records, each incremented by 1 (as a String). It does a put for each incremented record until the payload contains ten records.
From the Business Rules toolbar, click the For Loop icon.
A For Loop is added to the Business Rules tree.
From the Business Rules tree, select counter initialization under the For Loop.
From the Business Rules Designer’s Math menu, select Literal Number.
The Number literal box appears.
Double-click the value field of the Number literal box and enter 1 as the Literal Number value.
Map the 1 output node of the Number literal box to the loopCount variable in the right pane of the Business Rules Designer.
Under the For Loop, create the condition, loopCount is less than 11:
From the Business Rules tree, select the condition under the For Loop.
From the Business Rules Designer’s Comparison menu, select Less Than.
The Less Than method box appears.
Double-click the number2 value field of the Less Than method box and enter 11 as the value.
Map the loopCount variable in the left pane of the Business Rules Designer, to the number1 input node of the Less Than method box.
Map the result(boolean) output node of the Less Than method box, to condition variable in the right pane of the Business Rules Designer.
Under For Loop steps, create the increment loopCount rule:
Under For Loop rules, create the Copy "Record" + intToString(loopCount) to recordStr rule:
From the Business Rules tree, select rules under the For Loop.
Map the loopCount variable in the left pane of the Business Rules Designer, to the recordStr variable in the right pane of the Business Rules Designer.
The Number to String Conversion dialog box appears.
Click OK to accept the default values.
The intToString method box appears.
From the Business Rules Designer canvas, click the link between the result(String) output node of the intToString method box and the recordStr variable in the right pane of the Business Rules Designer.
With the link selected, press the Delete key to break the link.
From the Business Rules Designer’s String menu, select Add.
The Add method box appears.
Double-click the value1 value field of the Add method box and enter Record as the value.
Map the result(String) output node of the intToString method box, to the value2 input node of the Add method box.
Map the result output node of the Add method box, to the recordStr variable in the right pane of the Business Rules Designer.
Create the Copy recordStr.Bytes to BatchRecord_Create.Record rule under For loop rules:
Right-click the recordStr variable in the left pane of the Business Rules Designer and select Browse this type from the context menu.
The Class Browser dialog box appears.
From the Class Browser dialog box, select String in the All Classes field and getBytes() in the String field.
Click Select.
The getBytes method box appears.
Map the result(byte[]) output node of the getBytes method box, to Record under BatchRecord_Create in the right pane of the Business Rules Designer.
Create the BatchRecord_Create.put rule under FOR Loop rules:
Create the BatchRecord_Create.finish rule:
From the Business Rules tree, select the For Loop, and from the Business Rules toolbar click the rule icon to create a new rule.
Right-click BatchRecord_Create in the left pane of the Business Rules Designer, and choose Select method to call from the context menu.
The method selection window appears.
Select finish() from the method selection window.
The finish method box appears in the Business Rules Designer canvas.
Create the Copy BatchRecord_Create.Payload to FileClient_1.ByteArray rule:
The Copy BatchRecord_Create.Payload to FileClient_1.ByteArray sets the ByteArray of the File Adapter to the payload.
Create the FileClient_1.writeBytes rule:
Click rule on the Business Rules toolbar to add a new rule in the Business Rules pane.
Right-click FileClient_1 in the left pane of the Business Rules Designer, and click Select method to call from the context menu.
The method selection window appears.
Select writeBytes() from the method selection window.
The writeBytes method box appears.
Create the Copy BatchRecord_Create.Payload to BatchRecord_Parse.Payload rule:
The Copy BatchRecord_Create.Payload to BatchRecord_Parse.Payload rule copies the payload to the BatchRecord_Parse Adapter.
Create the While statement:
The While statement and its Business Rules parse the ten records and publishes each record to the File Adapter.
From the Business Rules toolbar, click the While icon.
A While statement is added to the Business Rules tree.
From the Business Rules tree, select condition under the While statement.
Right-click BatchRecord_Parse in the left pane of the Business Rules Designer, and click Select method to call from the context menu.
The method selection window appears.
Select get() from the method selection window.
The get method box appears.
Map the result(boolean) output node of the get method box to condition in the right pane of the Business Rules Designer.
Create the Copy BatchRecord_Parse.Record to FileClient_1.ByteArray rule under the While statement rules:
Create the FileClient_1.writeBytes rule under the While statement rules:
Click rule on the Business Rules toolbar to add a new rule in the Business Rules pane.
Right-click FileClient_1 in the left pane of the Business Rules Designer, and click Select method to call from the context menu.
The method selection window appears.
Select writeBytes() from the method selection window.
The writeBytes method box appears.
Create the BatchRecord_Parse.finish rule
From the Business Rules tree, select the While statement, and from the Business Rules toolbar click the rule icon to create a new rule.
Right-click BatchRecord_Parse in the left pane of the Business Rules Designer, and choose Select method to call from the context menu.
The method selection window appears.
Select finish() from the method selection window.
The finish method box appears.
From the editor’s toolbar, click Validate to check the Collaboration for errors.
Save the Project.