Contents

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

  1. Use two databases which have a table each with the following contents:
    1. EmployeeDetails with columns Emp_Id, Emp_Name, Dept_Id, Dept_Name and Dept_Manager
    2. DeptDetails with columns Dept_Id, Dept_Name and Dept_Manager.
  2. Create an Application Context and configure the Feeder with the same schema.
  3. Send values 'Emp_Id', 'Emp_Name' and 'Dept_Id' as input from the Feeder.
  4. 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.
  5. 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:

  1. Add an event process with the name 'Application_Context_Eg'.

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

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

     Use this Schema for the present Example

    <?xml version="1.0" encoding="UTF-8"?>

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.fiorano.com/fesb/test">

       <xsd:element name="Input">

          <xsd:complexType>

             <xsd:sequence>

                <xsd:element name="EmpId" type="xsd:string"/>

                <xsd:element name="EmpName" type="xsd:string"/>

                <xsd:element name="DeptId" type="xsd:string"/>

             </xsd:sequence>

          </xsd:complexType>

       </xsd:element>

    </xsd:schema>



    Figure 2: Copying the Schema to the Feeder

  4. Click 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 button

  5. Select Input in the Root Element dialog box and click OK.

    Figure 4: Selecting root element

  6. Click Next to move to the Message Details Configuration panel.


    Figure 5: Navigating to Message Details Configuration Panel
     
  7. 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

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

  9. 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:

  1. 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 it

    Icon

    Renaming the DB component is to distinguish it from the other DB component to be configured with the Insert query.

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

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

  4. 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:

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

Defining the Application Context on Component Port

To configure the Application Context, perform the actions below:

  1. Click inside the Application_Context_Eg in the Fiorano Orchestrator.

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

  3. Click the Edit Schema button and copy the schema entered in the Feeder CPS.


    Figure 15: Entering the schema in Application Context window

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

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

    Icon

    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:

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

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

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

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

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

    Icon

    The result of this query will be used in the next step.



    Figure 20: Configuring transformations on route connecting Feeder1 and DB_Select

  6. DB_Insert was configured to execute the Insert query: INSERT INTO "SYSTEM"."EMPLOYEEDETAILS" ( "EMP_ID", "EMP_NAME", "DEPT_ID", "DEPT_NAME", "DEPT_MANAGER" ) VALUES ( ?, ?, ?, ?, ? ).

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

  8. 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:

  1. Click the Check Resource and Connectivity icon (or press ALT+SHIFT+C) to check resource and connectivity.

  2. Click the Run Event Process icon (ALT+SHIFT+R) to run the event process. Feeder1 and Display1 windows get opened.

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

  4. In the Feeder window, provide the values for 'EmpId', 'EmpName' and 'DeptId' and click Send.


    Figure 24: Sending input from Feeder

  5. The message will be stored on the route connecting 'Feeder1' and 'DB_Select'.
    1. Right-click the route and select the View Fiorano Debugger option from the Interceptor right-click menu option.
    2. In the Fiorano Debugger, select the route name that appears in the Breakpoints section.
    3. Click the Application Context tab which displays the Application Context that has been set and is available throughout the event process.
    4. 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

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

Adaptavist ThemeBuilder EngineAtlassian Confluence