Sun Adapter for Oracle 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 otdOracleotdOracle_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 otdOracle_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 new BigDecimal(otdInputDTD_DBemployees_1.X_sequence_A[i1].EmpNo) to otdOracle_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 BigDecimal as the class, and BigDecimal(String val) as the (constructor) method. Click Select.

      The BigDecimal 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 val (String) input node of the BigDecimal method box.

    5. Map the result (BigDecimal) output node of the BigDecimal method box, to EMP_NO node, under otdOracle_1 otdOracle_1 -> DB_EMPLOYEE in the right pane of the Business Rules Designer.

      Image shows the JCD Editor displaying the Copy new BigDecimal
EmpNo to otdOracle_1.DB_EMPLOYEE.EMP_NO rule.
  9. Create the Copy otdInputDTD_DBemployee_1.X_sequence_A[i1].Lastname to otdOracle_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 otdOracle_1 otdOracle_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 otdOracle_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 otdOracle_1 otdOracle_1 -> DB_EMPLOYEE in the right pane of the Business Rules Designer.

  11. Create the Copy new Double(otdInputDTD_DBemployees_1.X_sequence_A[i1].Rate).doubleValue to otdOracle_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 Double(String s) as the (constructor) method. Click Select.

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

    4. Right-click the result (Double) output node of the Double method box and select Browse this type from the popup menu.

      The Class Browser appears.

    5. From the Class Browser, select Double as the class, and doubleValue() as the method. Click Select.

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

    6. 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 method box.

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

    8. Map the result (double) output node of the doubleValue method box, to RATE node, under otdOracle_1 -> DB_EMPLOYEE in the right pane of the Business Rules Designer.

      Image shows the JCD Editor displaying the Copy new Double
doublevalue888 to otdOracle_1.DB_EMPLOYEE.RATE rule.
  12. Create the Copy Date.valueOf(otdInputDTD_DBemployee_1.X_sequence_A[i1].LastDate) to otdOracle_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 Date as the class, and select the valueOf(String s) as the method. Click Select

      A Date.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 Date.valueOf method box.

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

  13. Create the otdOracle_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 otdOracle_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.