Data Adaptor - Sample Code (Autosave with Derby)

The sample Autosave scenario in this example does the following:

 

The sample code demonstrates

 

The sample code provides functionality for requirements such as:

Setup

This sample code needs the following to run:

About the DERBY SQL database schema

Table AUTOSAVE 

 

ID INPUT1 INPUT2 OUTPUT1 OUTPUT2 OUTPUT3 OUTPUT4
VARCHAR(255) VARCHAR(24) VARCHAR(24) VARCHAR(24) VARCHAR(24) VARCHAR(24) VARCHAR(24)

About the ExtFrameworkAutoSave Rulebase

Below is a summary of the rulebase.

The ExtFrameworkAutoSave rulebase has the following attributes in the properties file:

 

The rules are:

The person is eligible if

The person is middleage or older if

The person is on a low income if

The person is an old low income earner if

About the Plugins:

To setup this scenario:

  1. Create the SQL Database. It doesn't have to be DERBY, but that is what the source code is set up for
  2. Create the Rulebase, and build
  3. Copy the rulebase .zip file from the project output directory (e.g. C:\projects\ExtFrameworkAutoSave\Development\output) to the rulebase folder in Web Determinations (e.g. <webroot>\WEB-INF\classes\rulebase)
  4. Copy the code for the AutoSaveTrigger event handler
  5. Copy the code for the AutoSaveSaver data adaptor (you may need to modify the database connection details)
  6. Compile and JAR the AutoSaveTrigger and AutoSaveSaver (you may need class files for your specific database implementation)
  7. Install the JAR file on Web Determinations . More info in article: Create a Plugin
  8. Run a Web Determinations Interview

How the Autosave works

The autosave functionality happens:

 

When the above events are met, the AutosaveTrigger Event Handler calls the save() method of the AutosaveSaver Data Adaptor.

The AutosaveSaver simply saves all of the attributes into the Autosave table in the DERBY database. The mapping of Attributes to the columns of the Autosave table are as follows:

 

ID INPUT1 INPUT2 OUTPUT1 OUTPUT2 OUTPUT3 OUTPUT4
Case ID age income old low_income old_low_income eligible

 

Table 'Autosave' view - start of investigation, to completing an investigation

While going through the Interview, when the user starts an investigation of a goal and the current Case ID is empty - a new Case ID will be created. You can see this in the database; for example:


ID INPUT1 INPUT2 OUTPUT1 OUTPUT2 OUTPUT3 OUTPUT4
8821b2f8-76e3-4762-a4a5-af8c10aac521 NULL
NULL NULL NULL NULL NULL

 

After the Case ID is generated, as the user answers the questions in the investigation (for example, age=31 below), answers and inferenced data will be added onto the same row item in the database (for example, old = Yes, eligible = Yes).


ID INPUT1 INPUT2 OUTPUT1 OUTPUT2 OUTPUT3 OUTPUT4
8821b2f8-76e3-4762-a4a5-af8c10aac521 31 NULL Yes NULL NULL Yes

 

AutoSaveTrigger.java

 

AutosaveSaver.java