Skip Navigation Links | |
Exit Print View | |
Oracle Java CAPS Adapter for Oracle Tutorials Java CAPS Documentation |
Oracle Java CAPS Adapter for Oracle Tutorials
About the Oracle Java CAPS Adapter for Oracle Sample Projects
Sample Input Trigger Files and Output Files
Operations Used in the Oracle Sample Projects
About the Oracle Java CAPS Business Process Manager Project
Associating Business Process Manager Operators
Deploying JCD- Based Operations in the Business Process Manager
About the Java Collaboration Definition Sample Project
Importing Non-JBI Based Sample Projects
To Import a Non-JBI Based Sample Project
Creating the Java Collaboration Definition-Based Project for the Oracle Java CAPS Adapter for Oracle
Create the Oracle Database OTD
Create the Inbound and Outbound DTD OTDs
Creating the Collaboration Definitions (Java)
Create the jcdDelete Collaboration Definition
Using the Java Collaboration Editor to create Business Rules
Creating the Business Rules for the jcdDelete Collaboration
Create the jcdDelete Collaboration Business Rules
jcdDelete Collaboration Java Code
Creating the Business Rules for the jcdInsert Collaboration
Create the jcdInsert Collaboration Business Rules
jcdInsert Collaboration Java Code
Creating the Business Rules for the jcdPsSelect Collaboration
Using the Collaboration Editor's Java Source Editor
Create the jcdPsSelect Collaboration Business Rules
Creating the Business Rules for the jcdTableSelect Collaboration
Create the jcdTableSelect Collaboration Business Rules
jcdTableSelect Collaboration Java Code
Creating the Business Rules for the jcdUpdate Collaboration
Create the jcdUpdate Collaboration Business Rules
Creating the Connectivity Maps
Adding Connectivity Maps to a Project
Add the Connectivity Maps to the Project
Populating and Binding the Connectivity Maps using the Connectivity Map Generator
Populate the Connectivity Maps using the Connectivity Map Generator.
Configuring the Adapter Properties
Configuring the Connectivity Map Properties
Configure the Connectivity Map Properties
File1 Inbound Adapter Properties
File2 Outbound Adapter Properties
Oracle1 Outbound Adapter Properties
Configuring the Environment Properties
Configure the Environment Properties
File Adapter Environment Properties
Oracle Adapter Environment Properties
Creating the Deployment Profile
Building and Deploying the Project
Deploying the Project from NetBeans
Creating the BPEL-Based Project for the Oracle Java CAPS Adapter for Oracle
Creating the Business Processes
Create the bpDelete Business Process
Create the bpInsert Business Process
Create the bpPsSelect Business Process
Create the bpTableSelect Business Process
Create the bpUpdate Business Process
Using Business Process Designer to Create Business Rules
Creating the bpDelete Business Rules
Create the bpDelete Business Rules
Creating the bpInsert Business Rules
Create the bpInsert Business Rules
Creating the bpPsSelect Business Rules
Create the bpPsSelect Business Rules
Creating the bpTableSelect Business Rules
Create the bpTableSelect Business Rules
The prjOracle_JCD Project uses five Java Collaborations you created previously. To complete the Collaborations, use the Java Collaboration Editor's Business Rules Designer to create the business rules.
The Java Collaboration Editor also allows you to enter Java code to create business rules. The Java Source code is provided at the end of each Collaboration section, and can be copied into the Collaboration Editor's Java Source Editor to create the Collaboration.
This section contains the following topics:
Creating the Business Rules for the jcdPsSelect Collaboration
Creating the Business Rules for the jcdTableSelect 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.
The Java Collaboration Editor opens to the jcdDelete Collaboration.
A String method box is added to the Business Rules Designer canvas.
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.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The method selection window appears.
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.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The completed jcdDelete Collaboration definition appears as follows:
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.
The jcdInsert Collaboration implements the Input Web Service Operation to read the TriggerInsert.in. file. It then unmarshals data from the input data into the otdInputDTD_DBEmployees OTD, calls the otdOracle OTD, and inserts records into the database via a For Loop. The Collaboration also writes a message to JCD_Insert_output0.dat to confirm an inserted record.
The Java Collaboration Editor opens to the jcdInsert Collaboration.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The method selection window appears.
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.
The method selection window appears.
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.
The Create Variable dialog box appears.
The i1 variable is added to the Business Rules Designer.
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.
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.
The method selection window appears.
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.
The Class Browser appears.
The BigDecimal method box is added to the Business Rules Designer canvas.
The Class Browser appears.
The Double method box is added to the Business Rules Designer canvas.
The Class Browser appears.
The doubleValue method box is added to the Business Rules Designer canvas.
A Date.valueOf method box appears in the Business Rules Designer Canvas.
The method selection window appears.
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.
A new rule is added to the main trunk of the Business Rules tree.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The completed Collaboration definition appears as follows:
The completed Java source code for the jcdInsert Collaboration appears as follows:
package prjOracle_JCD; public class jcdInsert { 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, dtd.otdInputDTD129034179.DBemployees otdInputDTD_DBemployees_1, otdOracle.OtdOracleOTD otdOracle_1, com.stc.connector.appconn.file. FileApplication FileClient_1 ) throws Throwable { FileClient_1.setText( "Inserting records into db_employee table .." ); FileClient_1.write(); otdInputDTD_DBemployees_1.unmarshalFromString( input.getText() ); otdOracle_1.getDB_EMPLOYEE().insert(); for (int i1 = 0; i1 < otdInputDTD_DBemployees_1.countX_sequence_A(); i1 += 1) { otdOracle_1.getDB_EMPLOYEE().setEMP_NO( new java.math.BigDecimal ( otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getEmpNo() ) ); otdOracle_1.getDB_EMPLOYEE().setLAST_NAME ( otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getLastname() ); otdOracle_1.getDB_EMPLOYEE().setFIRST_NAME ( otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getFirstname() ); otdOracle_1.getDB_EMPLOYEE().setRATE( (new Double ( otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getRate() )). doubleValue() ); otdOracle_1.getDB_EMPLOYEE().setLAST_UPDATE( java.sql.Date.valueOf ( otdInputDTD_DBemployees_1.getX_sequence_A( i1 ).getLastDate() ) ); otdOracle_1.getDB_EMPLOYEE().insertRow(); } FileClient_1.setText( "Done Insert." ); FileClient_1.write(); } }
Note - The above code has been wrapped for display purposes.
The jcdPsSelect Collaboration implements the Input Web Service Operation to read the TriggerPsSelect.in file. It then copies the database resultset (as noted in the prepared statement query) into the otdInputDTD_DBEmployee OTD and selects all available records from the database. The Collaboration also writes a message to JCD_PsSelect_output0.dat to confirm when records are selected, or when no records are available.
To create the third Java Collaboration, jcdPsSelect, we will use the Java Source Editor. The Java Source Editor allows you to write your business rules in the editor, or copy code into the Collaboration Editor that you have written with another tool.
jcdPsSelect Collaboration Java Code
The completed Java source code for the jcdPsSelect Collaboration appears as follows:
package prjOracle_JCD; public class jcdPsSelect { 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, dtd.otdOutputDTD1007064608. DBemployee otdOutputDTD_DBemployee_1, com.stc.connector.appconn.file. FileApplication FileClient_1 ) throws Throwable { FileClient_1.setText( "Selecting record(s) from db_employee table via Prepared Statement select .." ); FileClient_1.write(); otdOracle_1.getSelect_ps().setEmpno( new java.math.BigDecimal( "0" ) ); otdOracle_1.getSelect_ps().executeQuery(); if (otdOracle_1.getSelect_ps().resultsAvailable()) { while (otdOracle_1.getSelect_ps().get$Select_psResults().next()) { otdOutputDTD_DBemployee_1.setEmpNo( otdOracle_1.getSelect_ps(). get$Select_psResults().getEMP_NO().toString() ); otdOutputDTD_DBemployee_1.setLastname( otdOracle_1.getSelect_ps(). get$Select_psResults().getLAST_NAME() ); otdOutputDTD_DBemployee_1.setFirstname( otdOracle_1.getSelect_ps(). get$Select_psResults().getFIRST_NAME() ); otdOutputDTD_DBemployee_1.setRate( Double.toString( otdOracle_1. getSelect_ps().get$Select_psResults().getRATE() ) ); otdOutputDTD_DBemployee_1.setLastDate( otdOracle_1.getSelect_ps(). get$Select_psResults().getLAST_UPDATE().toString() ); FileClient_1.setText( otdOutputDTD_DBemployee_1.marshalToString() ); FileClient_1.write(); } } else { FileClient_1.setText( "No record found!" ); FileClient_1.write(); } FileClient_1.setText( "Done Select." ); FileClient_1.write(); } }
Note - The above code has been wrapped for display purposes.
The Java Collaboration Editor opens to the jcdPsSelect Collaboration.
The Collaboration displays the Business Rules window and the Java Source Editor window.
If the code contains any errors they will be listed for you in the Validation window at the bottom of the NetBeans IDE. Correct these errors if necessary, and click the Commit changes button again.
The completed Collaboration definition appears as follows:
The jcdTableSelect Collaboration implements the Input Web Service Operation to read the TriggerTableSelect.in file. It then copies the database resultset into the otdInputDTD_DBEmployee OTD and selects all available records from the database that meet the criteria emp_no = 100. The Collaboration also writes a message to JCD_TableSelect_output0.dat to confirm when records are selected, or when no records are available.
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 TriggerTableSelect.in file is empty.
You can create the jcdTableSelect Java Collaboration business rules by following the steps below, or by copying the jcdTableSelect Collaboration Java Code into the Collaboration Editor's Java Source Editor as described in Using the Collaboration Editor's Java Source Editor.
The Java Collaboration Editor opens to the jcdTableSelect Collaboration.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The method selection window appears.
The select 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 select method box.
The method selection window appears.
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.
The Business Rules Designer adds the necessary code for shortToString type conversion.
The Business Rules Designer adds the necessary code to create the business rule.
The method selection window appears.
The toString method box appears in the Business Rules Designer canvas.
The method selection window appears.
The marshalToString method box appears in the Business Rules Designer canvas, and a link connects otdOutputDTD_DBemployee_1 in the left pane of the Business Rules Designer to the DBemployee input node of the marshalToString method box.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
A new rule is added to the main trunk of the Business Rules tree.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The completed jcdTableSelect Collaboration definition appears as follows:
The completed Java source code for the jcdTableSelect Collaboration appears as follows:
package prjOracle_JCD; public class jcdTableSelect { 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, dtd.otdOutputDTD1007064608.DBemployee otdOutputDTD_DBemployee_1, otdOracle. OtdOracleOTD otdOracle_1, com.stc.connector.appconn.file.FileApplication FileClient_1 ) throws Throwable { FileClient_1.setText( "Selecting record(s) from db_employee table via table select .." ); FileClient_1.write(); otdOracle_1.getDB_EMPLOYEE().select( input.getText() ); while (otdOracle_1.getDB_EMPLOYEE().next()) { otdOutputDTD_DBemployee_1.setEmpNo( otdOracle_1.getDB_EMPLOYEE(). getEMP_NO().toString() ); otdOutputDTD_DBemployee_1.setLastname( otdOracle_1.getDB_EMPLOYEE(). getLAST_NAME() ); otdOutputDTD_DBemployee_1.setFirstname( otdOracle_1.getDB_EMPLOYEE(). getFIRST_NAME() ); otdOutputDTD_DBemployee_1.setRate( Double.toString ( otdOracle_1.getDB_EMPLOYEE().getRATE() ) ); otdOutputDTD_DBemployee_1.setLastDate( otdOracle_1.getDB_EMPLOYEE(). getLAST_UPDATE().toString() ); FileClient_1.setText( otdOutputDTD_DBemployee_1.marshalToString() ); FileClient_1.write(); } FileClient_1.setText( "Done table select." ); FileClient_1.write(); } }
Note - The above code has been wrapped for display purposes.
The jcdUpdate Collaboration implements the Input Web Service Operation to read the TriggerUpdate.in. file and then update the record emp_no = 300. The Collaboration also writes a message to JCD_Update_output0.dat to confirm an updated 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 TriggerTableSelect.in file is empty.
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.
The Java Collaboration Editor opens to the jcdUpdate Collaboration.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The method selection window appears.
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.
The method selection window appears.
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.
The Class Browser appears.
The Double method box is added to the Business Rules Designer canvas.
The Class Browser appears.
The doubleValue method box is added to the Business Rules Designer canvas.
The Date.valueOf method box appears.
The method selection window appears.
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.
A new rule is added to the main trunk of the Business Rules tree.
A String method box is added to the Business Rules Designer canvas.
The method selection window appears.
The write method box appears in the Business Rules Designer canvas. The FileClient_1.write rule is added to the Business Rules tree.
The completed jcdUpdate Collaboration definition appears as follows:
The completed Java source code for the jcdUpdate Collaboration appears as follows:
package prjOracle_JCD; public class jcdUpdate { 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( "Update the Rate and Last_update fields .. " ); FileClient_1.write(); otdOracle_1.getDB_EMPLOYEE().update( input.getText() ); while (otdOracle_1.getDB_EMPLOYEE().next()) { otdOracle_1.getDB_EMPLOYEE().setRATE( (new Double( "888" )).doubleValue() ); otdOracle_1.getDB_EMPLOYEE().setLAST_UPDATE( java.sql.Date.valueOf( "2008-08-08" ) ); otdOracle_1.getDB_EMPLOYEE().updateRow(); } FileClient_1.setText( "Done Update." ); FileClient_1.write(); } }
Note - The above code has been wrapped for display purposes.
For your next step, see Creating the Connectivity Maps .