Application Context
Objective
To configure the Application Context for an event process and use it to insert data into a table.
Prerequisites
- Start Fiorano Enterprise Server (FES) and Fiorano Peer Server (FPS)
- Login to the eStudio application
- Understand the basic menus and perspectives (panels) in the eStudio application
Scenario
- Use two databases which have a table each with the following contents:
- EmployeeDetails with columns Emp_Id, Emp_Name, Dept_Id, Dept_Name and Dept_Manager
- DeptDetails with columns Dept_Id, Dept_Name and Dept_Manager.
- Create an Application Context and configure the Feeder with the same schema.
- Send values 'Emp_Id', 'Emp_Name' and 'Dept_Id' as input from the Feeder.
- Configure a DB component with the Select query that fetches the 'Dept_Name' and the 'Dept_Manager' values from the DeptDetails table based on 'Dept_Id' sent from the Feeder.
- Configure another DB component with the Insert query which inserts a new record into 'EmployeDetails' table with 'Emp_Id', 'Emp_Name' from the Application Context and 'Dept_Id', 'Dept_Name', 'Dept_Manager' values from the DB component configured with the Select query.
Components used
Setting up the Example
While simple data transformation from source Event Port to target ports is a necessity, there are times when a target Event Port needs information which was produced by a Business component that occurred previously in the workflow. Consider a Fiorano Micro Services Platform event process representing a ten-step business process. Each step is implemented using a Business component. The Application Context enables a Business component representing the tenth step to use information generated by the second Business component.
Configuring Feeder
The Feeder provides input which is used to query the DeptDetails table as well as to set the Application Context. To configure the Feeder, follow the steps below:
- Add an event process with the name 'Application_Context_Eg'.
- Drag the Feeder component from the Util category in the Micro Service Palette to the Fiorano Orchestrator.
Figure 1: Adding Feeder component to the Fiorano Orchestrator Double-click Feeder1 in the Fiorano Orchestrator to open the Configuration Property Sheet (CPS). Use the valid schema in the Schema editor in the Message Type Configuration panel.
Figure 2: Copying the Schema to the FeederClick the ellipsis button that is present next to the 'Select Root Element' below Schema editor to select the root element of the schema.
Figure 3: Clicking the Select Root Element ellipsis buttonSelect Input in the Root Element dialog box and click OK.
Figure 4: Selecting root element- Click Next to move to the Message Details Configuration panel.
Figure 5: Navigating to Message Details Configuration Panel
- In Message Details Configuration panel, click Generate Sample which will open the XSD Sample Generation Dialog.
Figure 6: Clicking 'Generate Sample' in the Message Details Configuration Panel - Set the max value in No.of Repeatable elements to be generated as '1' and click OK.
Figure 7: Setting No. of Repeatable elements to be generated - Click Finish to complete the Feeder1 component configuration.
Figure 8: Clicking 'Finish' to complete Feeder1 configuration
Configuring the DB component to execute Select Query
Configure a DB component to execute a Select SQL query on the 'DeptDetails' table. To configure the DB component, perform the actions below:
Drag the DB component from the DB category in the Service Palette to the Fiorano Orchestrator. Rename the DB component from 'DB1' to 'DBSelect'.
Figure 9: Adding DB component to Fiorano Orchestrator and renaming itRenaming the DB component is to distinguish it from the other DB component to be configured with the Insert query.
Configure select query to fetch data from the 'DeptDetails' table based on 'Dept_ID'. To understand how to configure a Select query, refer to the DB Basics - Select and Insert Statements section.
- After the query "SELECT * FROM "SYSTEM"."DEPTDETAILS" is configured in Select Query Builder, go to WHERE tab and click the Add button. Select the column 'DEPT_ID' from the Column drop-down menu and click OK.
Figure 10: Adding WHERE clause to the Select query - Select query details appear under SQL Statement Details.
Figure 11: Select query
Configuring the DB component to execute Insert Query
Configure another DB component to execute the Insert query on the EmployeeDetails table to insert the details of a new employee. To configure the DB component, perform the actions below:
- Drag the DB component from the DB category in the Service Palette to the Fiorano Orchestrator. Rename the DB component from 'DB1' to 'DBInsert'.
Figure 12: Adding DB component to Fiorano Orchestrator and renaming it - Configure Insert query to insert a new record into the EmployeeDetails table. To understand how to configure a Select query, refer to the DB Basics - Select and Insert Statements section.
Figure 13: Insert Query
Defining the Application Context on Component Port
To configure the Application Context, perform the actions below:
- Click inside the Application_Context_Eg in the Fiorano Orchestrator.
- In the Properties panel, click the Application Context tab. To enable Application Context, check the Application Context checkbox. In the Application Context property, select the XSD option as the XML schema type.
Figure 14: Selecting Application Context and its Schema Type - Click the Edit Schema button and copy the schema entered in the Feeder CPS.
Figure 15: Entering the schema in Application Context window - Click the Select Root Element ellipsis button, select the root the element 'Input' from the Root Element pop-up window and click OK twice to save the Application Context configuration.
Figure 16: Selecting Root Element The application context is available throughout the event process. This Application Context instance can be saved by providing a name for it in the Value text field of 'Application Context' properties.
After a value is provided, empty XML will be present throughout the application unless it is configured at any of the out ports. Once Application Context is configured at an out port, the value is propagated into the message flow.
Configure Route Transformation
Application Context is used to provide values for the columns EMP_ID and EMP_NAME and then to execute the Insert query in 'DB_Insert' to add a record to the EmployeeDetails Table. If the application context is not set, these values get eliminated once the 'Feeder1' sends its message to the 'DB_Select'.
To configure route transformation, perform the following actions:
- Connect the output port of the Feeder component to the input port of DB_Select and the output port of DB_Select to the input port of DB_Insert.
- To configure Application Context at any of the output ports, right-click the Feeder output port, go to the Configure Application Context and select the Mapper Project to open the Fiorano Mapper tool window.
Figure 17: Opening Fiorano Mapper Tool - The Mapper window shows the output port structure and the application context structure. The data that is to be propagated from this port and is to be made available all through the event process can now be configured. Configure the mapper transformation by connecting the values EmpId, EmpName and DeptId.
Figure 18: Configuring Mappings - DB_Select was configured to execute the Select query: SELECT * FROM "SYSTEM"."DEPTDETAILS" WHERE "DEPT_ID" = ?. The DEPT_ID value is fetched from the input given in the Feeder. Right-click the route connecting Feeder and DB_Select and navigate to the Mapper editor.
Figure 19: Opening Fiorano Mapper Tool on route connecting Feeder1 and DB_Select Configure the mapper transformation by connecting the element 'DeptId' under the Input Structures panel and 'DEPT_ID' under the Output Structures panel. Save and close the Mapper Tool.
The result of this query will be used in the next step.
Figure 20: Configuring transformations on route connecting Feeder1 and DB_Select- DB_Insert was configured to execute the Insert query: INSERT INTO "SYSTEM"."EMPLOYEEDETAILS" ( "EMP_ID", "EMP_NAME", "DEPT_ID", "DEPT_NAME", "DEPT_MANAGER" ) VALUES ( ?, ?, ?, ?, ? ).
- Right click the route connecting DB_Select and DB_Insert and navigate to the Mapper Project window. Connect the mapper transformations as shown in the figure below. The values for the columns DEPT_ID, DEPT_NAME and DEPT_MANAGER are obtained from the output of 'DB_Select' (OUT_PORT under Input Structures panel). Save the transformations and close the Mapper Tool.
Figure 21: Configuring transformations on route connecting DB_Select and DB_Insert - Drag the Display component from the Util category in the Service Palette to the Fiorano Orchestrator. Connect the output port of DB_Insert to the input port of the Display component so that the final output of the record inserted into the 'EmployeeDetails' table is displayed in the Display window.
Figure 22: Connecting Display component to DB_Insert
Running the Example
Open the Application_Context_Eg Event Process Orchestrator and perform the actions below:
- Click the Check Resource and Connectivity icon (or press ALT+SHIFT+C) to check resource and connectivity.
- Click the Run Event Process icon (ALT+SHIFT+R) to run the event process. Feeder1 and Display1 windows get opened.
- Add a breakpoint on the route connecting 'Feeder1' and 'DB_Select' by right-clicking the route and selecting Add Breakpoint under Interceptor .
Figure 23: Adding breakpoint - In the Feeder window, provide the values for 'EmpId', 'EmpName' and 'DeptId' and click Send.
Figure 24: Sending input from Feeder - The message will be stored on the route connecting 'Feeder1' and 'DB_Select'.
- Right-click the route and select the View Fiorano Debugger option from the Interceptor right-click menu option.
- In the Fiorano Debugger, select the route name that appears in the Breakpoints section.
- Click the Application Context tab which displays the Application Context that has been set and is available throughout the event process.
- Click the Send button. DB_Select executes the Select query on the DeptDetails table based on the 'Dept_Id' sent from the Feeder component and fetches 'Dept_Name' and 'Dept_Manager' values. Using 'Emp_Id', 'Emp_Name' values from the Application Context and 'Dept_Id', 'Dept_Name', 'Dept_Manager' values from DB_Select output, a new record is inserted into the 'EmployeeDetails' table.
Figure 25: Checking the Application Context configured
- In the Display window, the UpdateCount value can be seen as '1' which indicates successful insertion of data into the table.
Figure 26: The Display component with Insert Query result
Reference
- Download Application_Context_Eg event process and import it to the Event Process Repository in the Server Explorer in eStudio to understand the configuration used in this example and to execute the working sample.
- Please note that the options used in this example are basic so as to get an overview of the application. To explore other options present in the DB, Feeder and Display, refer to the sections: DB, Feeder and Display respectively.