Sun Adapter for SQL Server Tutorials

ProcedureCreate the jcdUpdate Collaboration Business Rules

You can create the jcdTableSelect Java Collaboration business rules by following the steps below, or by copying the jcdUpdate Collaboration Java Code into the Collaboration Editor's Java Source Editor as described in Using the Collaboration Editor's Java Source Editor.

  1. From the Project window, double-click the jcdUpdate Collaboration under your project's jcdALL node.

    The Java Collaboration Editor opens to the jcdUpdate Collaboration.

  2. Create the Copy "Updating the Rate and Last_update fields .. " to FileClient_1.Text rule.

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

    2. From the Business Rules Designer toolbar's String menu, select Literal String.

      A String method box is added to the Business Rules Designer canvas.

    3. Double-click the value field of the String method box and enter Updating the Rate and Last_update fields .. as the value.

    4. Map the output node of the String method box, to Text, under FileClient_1 in the right pane of the Business Rules Designer.

  3. Create the FileClient_1.write rule.

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

    2. Right-click the FileClient_1 node in the left pane of the Business Rules Designer, and choose Select method to call from the popup menu.

      The method selection window appears.

    3. Select and double-click write() from the method selection window.

      The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.

  4. Create the otdSQLServer_1.db_employee.update(input.Text) rule.

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

    2. Right-click db_employee under otdSQLServer_1 in the left pane of the Business Rules Designer, and choose Select method to call from the popup menu.

      The method selection window appears.

    3. Select update(String sWhere) from the method selection window.

      The update method box appears in the Business Rules Designer canvas, and a link connects the db_employee node in the left pane of the Business Rules Designer to the db_employee input node of the update method box.

    4. Map Text under the input node in the left pane of the Business Rules Designer, to the sWhere (String) input node of the update method box.

  5. Add a While statement and create the condition: otdSQLServer_1.db_employee.next rule.

    1. Click the While icon on the Business Rules toolbar to add a While statement to the Business Rules tree.

    2. Right-click db_employee under otdSQLServer_1 in the left pane of the Business Rules Designer, and choose Select method to call from the popup menu.

      The method selection window appears.

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

      The next method box appears in the Business Rules Designer canvas, and a link connects the db_employee node in the left pane of the Business Rules Designer to the db_employee input node of the next method box.

    4. Map the result (boolean) output node of the next method box, to the While condition in the right pane of the Business Rules Designer.

  6. Create the Copy new Double.parseDouble("888") to otdSQLServer_1.Db_employee.RATE rule beneath the While -> rules node.

    1. Select the rules node under the While statement in the Business Rules tree, and click the rule icon on the Business Rules toolbar to add a new rule.

    2. From the Business Rules Designer toolbar, click Class Browser.

      The Class Browser appears.

    3. From the Class Browser, select Double as the class, and parseDouble(String s) as the method. Click Select.

      The Double.parseDouble method box is added to the Business Rules Designer canvas.

    4. Double-click the s (String) field of the Double.parseDouble method box, and enter a value of 888.

    5. Map the result (Double) output node of the Double.parseDouble method box, to the the Double input node of the doubleValue method box.

    6. Map the result (double) output node of the Double.parseDouble method box, to RATE node, under otdSQLServer_1 -> db_employee in the right pane of the Business Rules Designer.

      Image shows the JCD Editor displaying the Copy new Double
Rate doubleValue to otdSQLServer_1.db_employee.RATE rule.
  7. Create the Copy Timestamp.valueOf("2008-08-08 00:00:00.0") to otdSQLServer_1.db_employee.LAST_UPDATE rule under the last rule.

    1. Click the rule icon on the Business Rules toolbar to add a new rule under your last rule.

    2. From the Business Rules Designer toolbar, click the Class Browser button.

    3. From the ClassBrowser, select Timestamp as the class, select thevalueOf(String s) method, and click Select.

      The Timestamp.valueOf method box appears.

    4. Double-click the s (String) field of the Timestamp.valueOf method box and enter 2008-08-08 00:00:00.0 as the value.

    5. Map the result (Timestamp) output node of the Timestamp.valueOf method box to the LAST_UPDATE node, under otdSQLServer_1 -> db_employee in the right pane of the Business Rules Designer.

  8. Create the otdSQLServer_1.db_employee.updateRow rule under the last rule.

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

    2. Right-click db_employee in the left pane of the Business Rules Designer, and choose Select method to call from the popup menu.

      The method selection window appears.

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

      The updateRow method box appears in the Business Rules Designer canvas, and a link connects the db_employee node in the left pane of the Business Rules Designer to the db_employee input node of the updateRow method box.

  9. Create the Copy "Update Done." to FileClient_1.Text rule.

    1. From the Business Rules tree, select the While statement, then click the rule icon on the Business Rules toolbar to add a new rule.

      A new rule is added to the main trunk of the Business Rules tree.

    2. From the Business Rules Designer toolbar's String menu, select Literal String.

      A String method box is added to the Business Rules Designer canvas.

    3. Double-click the value field of the String method box and enter Update Done. as the value.

    4. Map the output node of the String method box, to Text, under FileClient_1 in the right pane of the Business Rules Designer.

  10. Create the FileClient_1.write rule.

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

    2. Right-click the FileClient_1 node in the left pane of the Business Rules Designer, and choose Select method to call from the popup menu.

      The method selection window appears.

    3. Select and double-click write() from the method selection window.

      The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.

  11. Click Save All to save your current changes.

    The completed jcdUpdate Collaboration definition appears as follows:

    Image shows the completed jcdUpdate Java Collaboration
Definition business rules.