Contents

Objective

To configure 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 eStudio application
  • Understand the basic menus and perspectives (panels) in eStudio application

Scenario

  1. Use two databases which has one table each with the following contents respectively:
    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 Feeder with the same schema.
  3. Send values 'Emp_Id', 'Emp_Name' and 'Dept_Id' as input from Feeder.
  4. Configure a DB component with Select query that fetches 'Dept_Name' and 'Dept_Manager' values from the DeptDetails table based on 'Dept_Id' sent from Feeder.
  5. Configure another DB component with Insert query which inserts a new record into 'EmployeDetails' table with 'Emp_Id', 'Emp_Name' from Application Context and 'Dept_Id', 'Dept_Name', 'Dept_Manager' values from DB component configured with 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 before 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. By using application context, you can enable a Business component representing the tenth step to use information generated by the second Business component.

Configuring Feeder

Feeder provides the input which is used to query the DeptDetails table as well as to set the Application Context. To configure Feeder, follow the below steps:

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

  2. Drag the Feeder component from Util category in the Micro Service Palette to the Fiorano Orchestrator.


    Figure 1: Adding Feeder component to Fiorano Orchestrator

  3. Double-click Feeder1 in the Orchestrator to open Configuration Property Sheet (CPS). Use the valid schema in the Schema editor in 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 Schema to Feeder

  4. Click button that is present next to 'Select Root Element' below Schema editor to select the root element of the schema.


    Figure 3: Clicking Select Root Element ellipsis button

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

    Figure 4: Selecting root element

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


    Figure 5: Navigating to Message Details Configuration Panel
  7. In Message Details Configuration panel, click Generate Sample which will open XSD Sample Generation Dialog.


    Figure 6: Clicking 'Generate Sample' in 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 DB component to execute Select Query

Configure a DB component to execute a Select SQL query on 'DeptDetails' table. To configure the DB component, perform the following actions:

  1. Drag the DB component from 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 Insert query.

  2. Configure select query to fetch data from 'DeptDetails' table based on 'Dept_ID'. To understand how to configure a Select query, refer DB Basics - Select and Insert Statements.

  3. After the query "SELECT * FROM "SYSTEM"."DEPTDETAILS" is configured in Select Query Builder, go to WHERE tab and click Add button. Select the column 'DEPT_ID' from the Column drop-down and click OK.


    Figure 10: Adding WHERE clause to Select query

  4. Select query details appear under SQL Statement Details.


    Figure 11: Select query

Configuring DB component to execute Insert Query

Configure another DB component to execute the Insert query on EmployeeDetails table to insert the details of a new employee. To configure the DB component, perform the following actions:

  1. Drag the DB component from 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 Application Context on Component Port

To configure Application Context, perform the following actions:

  1. Click inside the Application_Context_Eg Orchestrator.

  2. In Properties panel, click Application Context tab. To enable Application Context, check the Application Context checkbox. In the Application Context property, select XSD option as the XML schema type.


    Figure 14: Selecting Application Context and its Schema Type

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


    Figure 15: Entering the schema in Application Context window

  4. Click Root drop-down, select the root element and click Save icon to save the Application Context configuration.


    Figure 16: Selecting Root Element

  5. Now, the application context gets available throughout the event process. This Application Context instance can be save by providing a name in the Value text field of 'Application Context' properties.

    Icon

    If a value is provided, empty XML will be present through out the application, unless it is configured at any of the out ports. Once Application Context is configured at one of the out ports, the value is propagated in 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 in the EmployeeDetails Table. If the application context is not set, these values would be lost once the 'Feeder1' sends its message to 'DB_Select'.

To configure route transformation, perform the following actions:

  1. Connect output port of Feeder component to input port of DB_Select and output port of DB_Select to input port of DB_Insert.

  2. To configure Application Context at any of the output ports, right-click the Feeder output port, go to Configure Application Context and select Mapper Project to open 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 available all through the event process can now be configured. Configure the mapper transformation by connecting the corresponding 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 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 Input Structures panel and 'DEPT_ID' under 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. Make the mapper transformations as shown in the below figure. 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 Util category in the Service Palette to the Fiorano Orchestrator. Connect the output port of DB_Insert to the input port of Display component to display the final output in Display window after a record gets successfully inserted into 'EmployeeDetails' table.


    Figure 22: Connecting Display component to DB_Insert

Running the Example

Open Application_Context_Eg Event Process Orchestrator and perform the following actions:

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

  2. Click 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. This message will be stored on the route connecting 'Feeder1' and 'DB_Select'. Click the route. Go to 'Fiorano Debugger' and select the route again. Now, click 'Application Context' tab which will display the Application Context that has been set and available throughout the event process.

  6. DB_Select executes Select query on DeptDetails table based on 'Dept_Id' sent from Feeder component and fetches 'Dept_Name' and 'Dept_Manager' values. Using 'Emp_Id', 'Emp_Name' values from Application Context and 'Dept_Id', 'Dept_Name', 'Dept_Manager' values from DB_Select output, a new record is inserted into 'EmployeeDetails' table.


    Figure 25: Viewing created Application Context

  7. In the Display window, UpdateCount value can be seen as '1' which indicates the successful insertion of data into the table.


    Figure 26: Display component with Insert Query result

Reference

Please note that the options used in this example are minimum, which helps you to get an overview of the application. To explore the other options present in the DB, Feeder and Display, refer sections: DBFeeder and Display respectively.

Adaptavist ThemeBuilder EngineAtlassian Confluence