Sun Adapter for Batch Tutorial

ProcedureTo Create the jcdBatch_Streaming Collaboration Business Rules

  1. From the Project Explorer tree, double-click jcdBatch_Streaming.

    The Java Collaboration Editor opens to the jcdBatch_Streaming Collaboration.

  2. To create comments for the Business Rules, from the Business Rules toolbar, click the comment icon.

    The Enter a Comment dialog box appears.

  3. Enter the comment and click OK.

    The comment is placed on the Business Rules tree under the last selected item. Click the comment to drag it up or down the Business Rules tree to a new location.

  4. Create the CopyBatchLocalFile_1.Client.OutputStreamAdapter to BatchFTP_1.Client.OutputStreamAdapter rule:

    The CopyBatchLocalFile_1.Client.OutputStreamAdapter to BatchFTP_1.Client.OutputStreamAdapter rule configures the BatchFTP and BatchLocalFile stream adapters so that the BatchFTP Adapter does a stream get, and the BatchLocalFile Adapter receives the stream.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Map OutputStreamAdapter under BatchLocalFile_1 ⇒ Client in the left pane of the Business Rules Designer, under to OutputStreamAdapter under BatchFTP_1 ⇒ Client in the right pane of the Business Rules Designer. To do this, Click on OutputStreamAdapter under BatchLocalFile_1 ⇒ Client in the left pane of the Business Rules Designer, and drag your cursor to OutputStreamAdapter under BatchFTP_1 ⇒ Client in the right pane of the Business Rules Designer. A link now connects the two nodes.

  5. Create the BatchFTP_1.Client.get rule:

    The BatchFTP_1.Client.get rule gets the file.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Under BatchFTP_1 in the left pane of the Business Rules Designer, right-click Client, and click Select method to call from the context menu.

      The method selection window appears.

    3. Select get() from the method selection window.

      The get method box appears in the Business Rules Designer canvas.

  6. Create the Copy BatchLocalFile_1.Configuration.PostDirectoryName to BatchLocalFile_1.Configuration.TargetDirectoryName rule:

    The Copy BatchLocalFile_1.Configuration.PostDirectoryName to BatchLocalFile_1.Configuration.TargetDirectoryName rule dynamically configures the name of the target directory to the post directory name.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Map PostDirectoryName under BatchLocalFile_1 ⇒ Configuration in the left pane of the Business Rules Designer, to TargetDirectoryName under BatchLocalFile_1 ⇒ Configuration in the right pane.

  7. Create the Copy BatchLocalFile_1.Configuration.PostFileName to BatchLocalFile_1.Configuration.TargetFileName rule:

    The Copy BatchLocalFile_1.Configuration.PostFileName to BatchLocalFile_1.Configuration.TargetFileName rule dynamically configures the name of the target file to the post file name.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Under BatchLocalFile_1⇒Configuration in the left pane of the Business Rules Designer, map PostFileName to TargetFileName under BatchLocalFile_1 ⇒ Configuration in the right pane of the Business Rules Designer.

  8. Create the Copy "None" to BatchLocalFile_1.Configuration.PostTransferCommand rule:

    The Copy "None" to BatchLocalFile_1.Configuration.PostTransferCommand rule dynamically configures the post transfer command to None so that no post transfer will take place.

    1. From the Business Rules Designer’s String menu, select Literal String.

      The String literal box appears.

    2. Double-click the value field of the String literal box and enter None as the value.

    3. Map the None output node of the String literal box to PostTransferCommand under BatchLocalFile_1⇒Configuration in the right pane of the Business Rules Designer

  9. Create the Copy BatchLocalFile_1.Client.InputStreamAdapter to BatchRecord_1.InputStreamAdapter rule:

    The Copy BatchLocalFile_1.Client.InputStreamAdapter to BatchRecord_1.InputStreamAdapter rule configures the BatchLocalFile and BatchRecord stream adapters so that the BatchLocalFile Adapter does a stream get, and the BatchRecord Adapter receives the stream.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Under BatchLocalFile_1 > Client in the left pane of the Business Rules Designer, map InputStreamAdapter to InputStreamAdapter under BatchRecord_1 in the right pane of the Business Rules Designer.

  10. Create the While statement:

    The While statement’s rules get the record, publish it to the outbound File Adapter, and the File Adapter writes the file to a local directory.

    1. Click While on the Business Rules toolbar to add a new while statement in the Business Rules pane.

    2. From the Business Rules tree, expand the While statement and select the condition.

    3. From the Business Rules Designer, right-click BatchRecord_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.

    4. Select get() from the method selection window.

      The get method box appears in the Business Rules Designer canvas.

    5. Map the output node of the get method box to result (boolean) condition in the right pane of the Business Rules Designer.

      Image shows the While statement in the Business Rules
Designer
  11. Create the Copy BatchRecord_1.Record to FileClient_1.ByteArray rule under the while statement:

    1. From the Business Rules tree, select rules under the While statement.

    2. Map Record, under BatchRecord_1 in the left pane of the Business Rules Designer, to ByteArray under FileClient_1 in the right pane of the Business Rules Designer.

  12. To create the FileClient_1.write rule under the while statement do the following:

    1. Click rule on the Business Rules toolbar to add a new rule under the While statement.

    2. Right-click FileClient_1 in the left pane of the Business Rules Designer, and click Select method to callfrom the context menu.

      The method selection window appears.

    3. Select write() from the method selection window.

      The write method box appears in the Business Rules Designer canvas.

  13. Create the BatchRecord_1.finish rule:

    1. Select the while statement on the Business Rules tree and click rule on the Business Rules toolbar.

      A new rule is added to the Business Rules tree.

    2. Right-click BatchRecord_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.

    3. Select finish() from the method selection window.

      The finish method box appears.

  14. From the editor’s toolbar, click Validate to check the Collaboration for errors.

    Image shows the completed business rules for the prjBatch_Streaming
Collaboration Definition
  15. Save the Project.