Sun Adapter for SQL Server Tutorials

ProcedureCreate the jcdInsert Collaboration Business Rules

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

    The Java Collaboration Editor opens to the jcdInsert Collaboration.

  2. Create the Copy "Inserting records in to db_employee table......" 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 Inserting records in to db_employee table...... 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 otdInputDTD_DB_Employee_1.unmarshalFromString(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 otdInputDTD_DB_Employee_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 unmarshalFromString(String in) from the method selection window.

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

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

      Image shows the Java Collaboration Editor displaying
the otdInputDTD_DB_Employee_1.unmarshalFromString(input.Text) business rule.
  5. Create the otdSQLServerotdSQLServer_1.Db_employee.insert 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 the otdSQLServer_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 insert() from the method selection window.

      The insert 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 insert method box.

  6. Create the For Loop: i1 is less than count of otdInputDTD_DB_Employee_1.X_sequence_A rule.

    1. Click the For Loop icon on the Business Rules toolbar to add a For Loop to the Business Rules tree.

    2. Right-click counter initialization node under the For Loop, and select Local Variable from the popup menu.

      The Create Variable dialog box appears.

    3. In the Create Variable dialog box, enter i1 as the name and select Primitive: int as the type, and click OK.

      The i1 variable is added to the Business Rules Designer.

    4. Select condition: ? under the For Loop on the Business Rules tree.

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

    6. Select Less Than from the method selection window.

      The Less Than method box appears in the Business Rules Designer canvas, and a link connects the i1 variable node in the left pane of the Business Rules Designer to the number1 input node of the i1 method box.

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

    8. Select countX_sequence_A() from the method selection window.

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

    9. Map the result (int) output node of the countX_sequence_A method box, to the number2 (num) input node of the Less Than method box.

    10. Map the result (boolean) output node of the Less Than method box, to the For Loop condition node in the right pane of the Business Rules Designer.

      Image shows the Java Collaboration Editor displaying
the condition: i1 is less than count of otdInputDTD_DB_Employee_1.X_sequence_A
business rule.
  7. Create the Copy i1 + 1 to i1 rule beneath the For Loop -> Steps node.

    1. Select the Steps node under the For Loop and click the rule icon on the Business Rules toolbar to add a new rule.

    2. Right-click the i1variable 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 Add from the method selection window.

      The Add method box appears in the Business Rules Designer canvas, and a link connects the i1 node in the left pane of the Business Rules Designer to the value1 input node of the insert method box.

    4. Double-click the value2 field and enter 1 as the value.

    5. Map the result output node of the Add method box, to the i1 variable node in the right pane of the Business Rules Designer.

  8. Create the Copy Integer.parseInt(otdInputDTD_DBemployees_1.X_sequence_A[i1].EmpNo) to otdSQLServer_1.Db_employee.EMP_NO rule beneath the For Loop -> rules node.

    1. Select the rules node under the For Loop 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 Integer as the class, and parceInt(String s) as the method. Click Select.

      TheInteger.parseInt method box is added to the Business Rules Designer canvas.

    4. Map the EmpNo node, under otdInputDTD_DBemployee_1 -> sequence_A in the left pane of the Business Rules Designer, to the s (String) input node of the Integer.parseInt method box.

    5. Map the result (int) output node of the Integer.parseInt method box, to EMP_NO node, under otdSQLServer_1 otdSQLServer_1 -> db_employee in the right pane of the Business Rules Designer.

      Image shows the JCD Editor displaying the Copy Integer.parseInt(sequence_A[i1].EmpNo)
to otdSQLServer_1.Db_employee.EMP_NO rule.
  9. Create the Copy otdInputDTD_DBemployee_1.X_sequence_A[i1].Lastname to otdSQLServer_1.db_employee.LAST_NAME rule under the last rule.

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

    2. Map the Lastname node, under otdInputDTD_DBemployee_1 -> sequence_A in the left pane of the Business Rules Designer, to the LAST_NAME node, under otdSQLServer_1 otdSQLServer_1 -> db_employee in the right pane of the Business Rules Designer.

  10. Create the Copy otdInputDTD_DBemployee_1.X_sequence_A[i1].Firstname to otdSQLServer_1.db_employee.FIRST_NAME rule under the last rule.

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

    2. Map the Firstname node, under otdInputDTD_DBemployee_1 -> sequence_A in the left pane of the Business Rules Designer, to theFIRST_NAME node, under otdSQLServer_1 otdSQLServer_1 -> db_employee in the right pane of the Business Rules Designer.

  11. Create the Copy Double.parseDouble(otdInputDTD_DBemployees_1.X_sequence_A[i1].Rate) to otdSQLServer_1.Db_employee.RATE rule beneath the For Loop -> rules node.

    1. Select the rules node under the For Loop 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. Map the Rate node, under otdInputDTD_DBemployee_1 -> sequence_A in the left pane of the Business Rules Designer, to the s (String) input node of the Double.parseDouble method box.

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

      Image shows the JCD Editor displaying the Copy Double.parseDouble
to otdSQLServer_1.db_employee.RATE rule.
  12. Create the Copy Timestamp.valueOf(otdInputDTD_DBemployees_1.X_sequence_A[i1].LastDate) to otdSQLServer_1.Db_employee.LAST_UPDATE rule under the last rule.

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

    2. From the Class Browser dialog box, select Timestamp as the class, and select the valueOf(String s) as the method. Click Select

      A Timestamp.valueOf method box appears in the Business Rules Designer Canvas.

    3. Map the LastDate node, under otdInputDTD_DBemployee_1 -> sequence_A in the left pane of the Business Rules Designer, to the s (String) input node of the Timestamp.valueOf method box.

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

  13. Create the otdSQLServer_1.db_employee.insertRow rule under the last 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 the otdSQLServer_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 insertRow() from the method selection window.

      The insertRow 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 insertRow method box.

  14. Create the Copy "Insert Done." to FileClient_1.Text rule under the completed For LOOP.

    1. From the Business Rules tree, select the For Loop, 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 Insert 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.

  15. 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.

  16. Click Save All to save your current changes.

    The completed Collaboration definition appears as follows:

    Image shows the completed jcdInsert Java Collaboration
Definition business rules.