Sun Adapter for Oracle Tutorials

Creating the Business Rules for the jcdDelete Collaboration

The jcdDelete Collaboration implements the Input Web Service Operation to read the TriggerDelete.in file and then delete the record emp_no = 500. The Collaboration also writes a message to JCD_Delete_output0.dat to confirm a deleted record.


Note –

The where clause in the business rule reads the trigger value as a placeholder for input. This permits you to modify the query to select a specific record. Also note that all records are selected from the database when the TriggerDelete.in file is empty.


ProcedureCreate the jcdDelete Collaboration Business Rules

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

    The Java Collaboration Editor opens to the jcdDelete Collaboration.

  2. Create the Copy "Deleting record............" to FileClient_1.Text rule.

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

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

    2. Double-click the value field of the String method box and enter Deleting record............ as the value.

    3. Map the output node of the String method box, to Text, under FileClient_1 in the right pane of the Business Rules Designer. To do this, click on the output node of the String method box, and drag your cursor to the Textnode, under FileClient_1 in the right pane of the Business Rules Designer.

      A visible link now connects the output node of the String method box and the Text node. The Business Rules tree now displays the new rule: Copy "Deleting record............" to FileClient_1.Text.

      Image shows the Java Collaboration Editor displaying
the Copy "Deleting record............" to FileClient_1.Text business rule.
  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.

      Image shows the Java Collaboration Editor displaying
the FileClient_1.write business rule.
  4. Create the otdOracle_1.Db_employee.delete(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 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 delete(StringsWhere) from the method selection window.

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

      Image shows the Java Collaboration Editor displaying
the otdInformix_1.Db_employee.delete(input.Text) business rule.
  5. Create the Copy "Delete Done." 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 Delete 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.

      Image shows the Java Collaboration Editor displaying
the Copy "Delete Done." to FileClient_1.Text business rule.
  6. 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.

  7. Click Save All to save your current changes.

    The completed jcdDelete Collaboration definition appears as follows:

    Image shows the completed jcdDelete Java Collaboration
Definition business rules.

jcdDelete Collaboration Java Code

The completed Java source code for the jcdDelete Collaboration appears as follows:


package prjOracle_JCD;


public class jcdDelete
{

   public com.stc.codegen.logger.Logger logger;

   public com.stc.codegen.alerter.Alerter alerter;

   public com.stc.codegen.util.CollaborationContext collabContext;

   public com.stc.codegen.util.TypeConverter typeConverter;

   public void receive( com.stc.connector.appconn.file.FileTextMessage input, 
otdOracle.OtdOracleOTD otdOracle_1, com.stc.connector.appconn.file.FileApplication FileClient_1 )
       throws Throwable
   {
       FileClient_1.setText( "Delete record .." );
       FileClient_1.write();
       otdOracle_1.getDB_EMPLOYEE().delete( input.getText() );
       FileClient_1.setText( "Done delete." );
       FileClient_1.write();
   }

}

Note –

The above code has been wrapped for display purposes.