User Tools

Site Tools


Practical Session 4 | Practical Session 6

Practical Session 5: Processing Events and Performing Actions

Estimated completion time = 30 minutes.

There are many tools available in EASA to process events and then perform associated actions. By including EVENT PROCESSING in an EASAP, we have the ability to make our user interface be much more dynamic and interactive.

Some examples of situations where processing events will be useful are:

  • Opening a file in a new browser window.
  • Updating data to and from databases.
  • Reading data from files.
  • Performing error checks prior to submitting a run.
  • Refreshing images and data generated as results.
  • Executing specially developed actions via custom code in the API.

Please follow the instructions below to complete this practical session.

Now we add actions to the BUTTON's we created earlier in the tutorial. The first action will read the StockData database using SQL statements.

  • On the EASA pages select EASA→Set Mode→Author and open EASAP Builder.
  • Right-click button_Search_Stock_Data
  • Select Child→Add DATABASE ACTION
  • Expand database_action1
  • Rename database1 to database_StockData

Set:

Parameter Name Parameter Value
Database Name:StockData
  • Right-click database_StockData
  • Select Child→Add READ
  • Rename it read_StockData

Set:

Parameter Name Parameter Value
Outputs:Symbol,Company,Industry,SPIndex,Exchange,Price,Sector, Revenue
File:read_StockData.txt

Note: The read_StockData.txt contains the SQL statement for reading the stock data from the database when the button_Search_Stock_Data button is pressed.


To parameterize the SQL query to include the user specified filters created in the previous sessions, we can modify the read_StockData.txt file with EASA’s Template Editor.

  • Select read_StockData.
  • In the 'Menu Bar' at the top of the Builder select Application→Edit Template…

The Template Editor should open like this:

  • Near the end of the SQL statement after 'WHERE ID>0' highlight the 'replace_exchange' text and replace it with the map_Exchange DOR by double-clicking map_Exchange in the DOR list located on the left side of the Template Editor.
  • Highlight the ‘replace_sector’ text and replace it with the map_Sector DOR by double clicking map_Sector in the DOR List.
  • Highlight the ‘replace_query’ text and replace it with the map_Query DOR.

Note: The DOR values are references to the corresponding object values. When the SQL query is used in read_StockData these DORs are replaced with the current values of the objects.

The Template Editor window should now look something like the following with the three DORs shown in bold blue:

  • Select File→Save and close out of Template Editor.

Now we proceed to create another DATABASE ACTION→DATABASE→READ that is triggered when the EASAP is opened. This ACTION will read all the unique industry sector names from the database. This list of sector names will populate the DATA VALIDATION under inputbox_Sector.

On the Tree:

  • Right-click tabbed_pane_Stock_Screener
  • Select Child→Add EVENT PROCESSING.
  • Expand event_processing1 by clicking on its .
  • Right-click event1
  • Select Child→Add APPLICATION OPENED

Add the ACTION for the APPLICATION OPENED EVENT:

  • Right-click action_group1
  • Select Child→Add DATABASE ACTION
  • Rename it database_action_On_Open
  • Expand database_action_On_Open
  • Select database2
  • Rename it database_StockData2

Set:

Parameter Name Parameter Value
Database Name:StockData
  • Right-click on database_StockData2
  • Select Child→Add READ
  • Rename it read_Sector_Choices

Set:

Parameter Name Parameter Value
Outputs:Sector_Choices
Text:SELECT DISTINCT(Sector) FROM Exchange

Note: The Text: parameter uses the DISTINCT function to pull out only the single unique value from the Sector column.

Now we populate inputbox_Sector with the Sector_Choices LIST.

  • Select the Child DATA VALIDATION under
    tabbed_pane_Stock_screener→sub_pane_Container→sub_pane_Filters→inputbox_Sector
  • Replace the ‘Basic Industries, Capital Goods’ text in the Source: parameter with the DOR %Sector_Choices%. The Source: parameter should now look like the following:
Parameter Name Parameter Value
Source:Sector_Choices
  • Save the EASAP by clicking on the Save button or typing ‘Ctrl-S’.

We have configured the EASAP to read data from the database, and now we need to process that data by revisiting the DATA PROCESSING branch.

  • Expand:
    TABBED PANE LIST→tabbed_pane_Stock_Screener→data_processing_Stock_Analysis
  • Right-click SCALAR→map_Query_Report
  • Select Sibling→Add STATISTICS
  • Rename it count_Symbol

Set:

Parameter Name Parameter Value
List:Symbol
Function:COUNT

Note: count_Symbol will have a value of the number of stocks returned by the SQL query performed from pressing the button_Search_Stock_Data BUTTON.

Now that we've defined count_Symbol, we can add logic to button_Create_Report to be enabled only when the count_Symbol SCALAR is greater than 0.

  • Select sub_pane_Actions→button_Create_Report

Set:

Parameter Name Parameter Value
Enable if:count_Symbol>0

In order to improve the formatting of some of the stock data read from the database, we can now add some list objects to the data_processing_Stock_Analysis→LIST branch.

  • Right-click on data_processing_Stock_Analysis→LIST
  • Select Child→Add REPEATED EXPAND
  • Rename it repeated_Price

Set:

Parameter Name Parameter Value
Value:$ %Price 3.2f%
  • Right-click repeated_Price
  • Select Sibling→Add REPEATED COMPUTE
  • Rename it Revenue_MM and set:
Parameter Name Parameter Value
Value:Revenue/1E+6
Type:INTEGER
  • Right-click Revenue_MM
  • Select Sibling→Add REPEATED COMPUTE
  • Rename it Zero_revenue

Set:

Parameter Name Parameter Value
Value:Revenue_MM==0
  • Right-click Zero_revenue
  • Select Sibling→Add REPEATED EXPAND
  • Rename it repeated_Revenue

Set:

Parameter Name Parameter Value
Value:$ %Revenue_MM%
  • Right-click repeated_Revenue
  • Select Sibling→Add REPEATED MAP
  • Rename it Show_Revenue

Set:

Parameter Name Parameter Value
List:Zero_revenue
Inputs:0.0,1.0
Outputs:%repeated_Revenue%, N/A
Delimiter:%
Output Expansion:REPEATED EXPAND
  • Save the EASAP by clicking on the Save button in the toolbar. If there is an error, a message will be displayed providing details of the problem within an objects that will need to be fixed.

Add a Submit ACTION to button_Create_Report:

  • Right-click sub_pane_Actions→button_Create_Report
  • Select Child→Add MENU ACTION
  • Rename it submit_Run_Report

Set:

Parameter Name Parameter Value
Action:Submit

At this point, the stock data is ready for display within the user interface of the EASAP. To display the results from read_StockData we use a TABULATED DATA to create a table and populate it with the stock data.

  • Save the EASAP by clicking on the Save button or typing ‘Ctrl-S’.
  • Right-click tabbed_pane_Stock_Screener→sub_pane_Actions
  • Select Sibling→Add SUB PANE
  • Rename it sub_pane_Search_Results
  • Right-click sub_pane_Search_Results
  • Select Child→Add TABULATED DATA
  • Rename it tabulated_data_Data_Output

Set:

Parameter Name Parameter Value
Column Titles:Symbol, Company Name, Industry Name, S&P Index, Exchange, Price, Sector, Revenue ($MM)
Columns:Symbol, Company, Industry, SPIndex, Exchange, repeated_Price, Sector, repeated_Revenue
Width:1010
Height:400

Now we will add a LABEL to display the total number of stocks found by the SQL query by displaying the value of count_Symbol.

  • Right-click tabulated_data_Data_Output
  • Select Sibling→Add LABEL
  • Rename it label_Stock_Count

Set:

Parameter Name Parameter Value
Label:Total stocks found: %count_Symbol%
  • Save the EASAP by clicking on the Save button or typing ‘Ctrl-S’.

At this point, the EASAP tree should look similar to the following:

After clicking on the Test Web Browser button (), the EASAP should look like this:

We have now completed Practical Session 5 and either proceed to the next session or take a break and exit out of EASAP Builder.

At this point, the application should query the database and allow filtering of results. All that remains is the report generation.

Practical Session 4 | Practical Session 6