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, you have the ability to make its 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 you 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 and select Child→Add DATABASE ACTION.
  • Expand database_action1. Rename database1 to database_StockData and set:
Parameter Name Parameter Value
Database Name:StockData
  • Right-click database_StockData and select Child→Add READ. Rename it read_StockData and 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:

  • Save the document. 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 choices of choice_list_Sector.

  • On the Tree right-click tabbed_pane_Stock_Screener and select Child→Add EVENT PROCESSING.
  • Expand event_processing1 by clicking on its . Right-click event1 and select Child→Add APPLICATION OPENED.
  • Add the ACTION for the APPLICATION OPENED EVENT:
    • Right-click action_group1 and select Child→Add DATABASE ACTION.
    • Rename it database_action_On_Open.
  • Expand database_action_On_Open. Select database2 and rename it database_StockData2. Set:
Parameter Name Parameter Value
Database Name:StockData
  • Right-click on database_StockData2 and select Child→Add READ. Rename it read_Sector_Choices and set:
Parameter Name Parameter Value
Outputs:Sector_Choices
Text:SELECT DISTINCT(Sector) FROM Exchange WHERE Sector <> Null

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

  • Now we populate choice_list_Sector with the Sector_Choices LIST. Under the sub_pane_Containersub_pane_Filters find choice_list_Sector and select its Child DATA VALIDATION.
  • 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:All, %Sector_Choices%
  • Save your 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 USER INTERFACE→TABBED PANE LIST→tabbed_pane_Stock_Screener→data_processing_Stock_Analysis.
  • Right-click SCALAR→map_Query_Report and select Sibling→Add STATISTICS. Rename it count_Symbol and 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 button_Create_Report and 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 and select Child→Add REPEATED EXPAND. Rename it repeated_Price and set:
Parameter Name Parameter Value
Value:$ %Price 3.2f%
  • Right-click repeated_Price and 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 and select Sibling→Add REPEATED COMPUTE. Rename it Zero_revenue and set:
Parameter Name Parameter Value
Value:Revenue_MM==0
  • Right-click Zero_revenue and select Sibling→Add REPEATED EXPAND. Rename it repeated_Revenue and set:
Parameter Name Parameter Value
Value:$ %Revenue_MM%
  • Right-click repeated_Revenue and select Sibling→Add REPEATED MAP. Rename it Show_Revenue and set:
Parameter Name Parameter Value
List:Zero_revenue
Inputs:0.0,1.0
Outputs:%repeated_Revenue%, N/A
Delimiter:%
Output Expansion:REPEATED EXPAND
  • Save your EASAP by clicking on the Save button in the toolbar. If you have errors, you will see messages directing you to problems within your objects that you will need to fix.

Add a Submit ACTION to button_Create_Report:

  • Right-click button_Create_Report and select Child→Add MENU ACTION. Rename it submit_Run_Report and 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 you will use a TABULATED DATA to create a table and populate it with the stock data.

  • Save your EASAP by clicking on the Save button or typing ‘Ctrl-S’.
  • Right-click sub_pane_Actions and 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 and 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 and select Sibling→Add LABEL. Rename it label_Stock_Count and set:
Parameter Name Parameter Value
Label:Total stocks found: %count_Symbol%
  • Save your 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:

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

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

Practical Session 4 | Practical Session 6


Page Tools