The Assess API offers four events that fire at various points during the Process Flow, each of which is described in the following table; click on the appropriate event name in the table to go to related examples.
Name | Encapsulated objects | Description | Event Handler Interface |
---|---|---|---|
OnAfterThinkEvent |
AssessConfig - The assess configuration object provided for this assess request Session Session - The Determinations Engine being used to conduct this assessment |
This event fires immediately after a think has been conducted on the assessment. It provides an opportunity to add add/remove/or alter the data in the session before the assess results are generated and returned. | OnAfterThinkEventHandler |
OnBeforeThinkEvent |
AssessConfig - The assess configuration object provided for this assess request Session - The Determinations Engine Session being used to conduct this assessment |
This event fires after the AssessData has been mapped into the session but before a think has been conducted. It provides the opportunity to augment the data in the session that was provided by the AssessData object. | OnBeforeThinkEventHandler |
OnMapDataEvent |
AssessConfig - The assess configuration object provided for this assess request Rulebase - the rulebase this assessment is going to be conducted using AssessData - the data that the assessment will be based upon |
This event fires prior to the AssessData being mapped into the Determinations Engine Session. It provides an opportunity to augment the data used to conduct the assessment. | OnMapDataEventHandler |
OnReturnResultEvent | AssessResult - the result of the assessment | This event firest after the assessment's results have been calculated but prior to that information being returned. It provides an opportunity to modify the assess results. | OnReturnResultEventHandler |
This example uses a rulebase to calculate the total amount of pocket money a person has to pay. It adds an additional outcome for each child to show the amount of pocket money that child has earned.
package my.sample.determinations.server.plugin;
import com.oracle.determinations.interview.engine.InterviewRulebase;
import com.oracle.determinations.server.assess.data.*;
import com.oracle.determinations.server.assess.extensions.AssessPlugin;
import com.oracle.determinations.server.assess.extensions.AssessPluginRegisterArgs;
import com.oracle.determinations.server.assess.extensions.events.OnMapDataEvent;
import com.oracle.determinations.server.assess.extensions.events.OnMapDataEventHandler;
import com.oracle.determinations.server.exceptions.DeterminationsServerException;
import java.util.List;
/**
* Sample Event handler for the OnMapDataEvent
*/
public class SampleOnMapDataEventHandler implements OnMapDataEventHandler {
private static final String RULEBASE_NAME = "EventExample";
private static final String CHILD_OUTCOME_ATTR = "child_money";
private static final String CHILD_ENTITY_NAME = "child";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnMapDataEventHandler(){
}
/**
* Factory method used to create instances of this event handler
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin
* implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public AssessPlugin getInstance(AssessPluginRegisterArgs args) {
return new SampleOnMapDataEventHandler();
}
/**
* Event handler that adds an additional outcome for each child provided in the Assess Request.
* @param sender - the instance of the assess engine that fired this event
* @param event - the event fired
*/
public void handleEvent(Object sender, OnMapDataEvent event) {
//we only want to handle assess requests for the EventExample rulebase
InterviewRulebase rulebase = event.getRulebase();
if(rulebase.getName().equals(RULEBASE_NAME)){
AssessData data = event.getData();
List childIansts = null;
try{
childInsts = data.getInstances(CHILD_ENTITY_NAME);
} catch (DeterminationsServerException ex) {
//this means there's no child entity instances so there's nothing for us to do
return;
}
//for each child entity instance we want to add a new outcome for the 'child_money' attribute that returns a
//decision report
for(Object obj : childInsts){
AssessEntityInstance inst = (AssessEntityInstance)obj;
AttributeOutcome outcome = new AttributeOutcome(CHILD_OUTCOME_ATTR, OutcomeStyle.DECISION_
REPORT);
inst.addOutcome(outcome);
}
}
}
}
namespace MY.Sample.Determinations.Server.Plugin
{
using System;
using Oracle.Determinations.Masquerade.Lang;
using InterviewRulebase = Oracle.Determinations.Interview.Engine.InterviewRulebase;
using Oracle.Determinations.Server.Assess.Data;
using AssessPlugin = Oracle.Determinations.Server.Assess.Extensions.AssessPlugin;
using AssessPluginRegisterArgs = Oracle.Determinations.Server.Assess.Extensions.AssessPluginRegisterArgs;
using OnMapDataEvent = Oracle.Determinations.Server.Assess.Extensions.Events.OnMapDataEvent;
using OnMapDataEventHandler = Oracle.Determinations.Server.Assess.Extensions.Events.OnMapDataEventHandler;
using DeterminationsServerException = Oracle.Determinations.Server.Exceptions.DeterminationsServerException;
using List = Oracle.Determinations.Masquerade.Util.List;
/**
* Sample Event handler for the OnMapDataEvent
*/
public class SampleOnMapDataEventHandler : OnMapDataEventHandler
{
private const string RULEBASE_NAME = "EventExample";
private const string CHILD_OUTCOME_ATTR = "child_money";
private const string CHILD_ENTITY_NAME = "child";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnMapDataEventHandler()
{
}
/**
* Factory method used to create instances of this event handler
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public virtual AssessPlugin GetInstance(AssessPluginRegisterArgs args)
{
return new SampleOnMapDataEventHandler();
}
/**
* Event handler that adds an additional outcome for each child provided in the Assess Request.
* @param sender - the instance of the assess engine that fired this event
* @param event - the event fired
*/
public virtual void HandleEvent(object sender, OnMapDataEvent Event)
{
//we only want to handle assess requests for the EventExample rulebase
InterviewRulebase rulebase = Event.GetRulebase();
if (rulebase.GetName().Equals(RULEBASE_NAME))
{
AssessData data = Event.GetData();
List childInsts = null;
try
{
childInsts = data.GetInstances(CHILD_ENTITY_NAME);
}
catch (DeterminationsServerException ex)
{
//this means there's no child entity instances so there's nothing for us to do
return;
}
//for each child entity instance we want to add a new outcome for the 'child_money' attribute that returns a decision report
foreach (object obj in childInsts)
{
AssessEntityInstance inst = (AssessEntityInstance) obj;
AttributeOutcome outcome = new AttributeOutcome(CHILD_OUTCOME_ATTR, OutcomeStyle.DECISION_REPORT);
inst.AddOutcome(outcome);
}
}
}
}
}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample/assess/types">
<soapenv:Header/>
<soapenv:Body>
<typ:assess-request>
<typ:config>
<typ:show-silent>false</typ:show-silent>
<typ:show-invisible>false</typ:show-invisible>
<typ:show-properties>false</typ:show-properties>
<typ:show-events>false</typ:show-events>
<typ:resolve-indecision-relationships>false</typ:resolve-indecision-relationships>
</typ:config>
<typ:global-instance>
<typ:person_name>
<typ:text-val>Bob</typ:text-val>
</typ:person_name>
<typ:base_rate>
<typ:number-val>2.0</typ:number-val>
</typ:base_rate>
<typ:total_money outcome-style="decision-report"/>
<typ:list-child>
<typ:child id="fred">
<typ:child_name>
<typ:text-val>Fred</typ:text-val>
</typ:child_name>
<typ:child_age>
<typ:number-val>5.0</typ:number-val>
</typ:child_age>
</typ:child>
<typ:child id="mary">
<typ:child_name>
<typ:text-val>Mary</typ:text-val>
</typ:child_name>
<typ:child_age>
<typ:number-val>7.0</typ:number-val>
</typ:child_age>
</typ:child>
</typ:list-child>
</typ:global-instance>
</typ:assess-request>
</soapenv:Body>
</soapenv:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample/assess/types">
<SOAP-ENV:Header>
<i18n:international>
<i18n:locale>en_GB</i18n:locale>
<i18n:tz>GMT+1000</i18n:tz>
</i18n:international>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<typ:assess-response>
<typ:global-instance>
<typ:total_money type="currency" inferred="true">
<typ:number-val>24.0</typ:number-val>
<typ:decision-report report-style="decision-report">
<typ:relationship-node id="dn:1" source-entity-id="global" source-instance-id="global" hypothetical-instance="false" target-entity-id="child"
relationship-id="children" state="known" inferred="false">
<typ:target instance-id="fred"/>
<typ:target instance-id="mary"/>
</typ:relationship-node>
<typ:attribute-node id="dn:2" entity-id="child" instance-id="fred" hypothetical-instance="false" attribute-id="child_money" type="currency"
text="The amount of pocket money Fred has earned is $10.00." inferred="true">
<typ:number-val>10.0</typ:number-val>
<typ:attribute-node id="dn:3" entity-id="global" instance-id="global" hypothetical-instance="false" attribute-id="base_rate" type="currency"
text="The pocket money base rate is $2.00." inferred="false">
<typ:number-val>2.0</typ:number-val>
</typ:attribute-node>
<typ:attribute-node id="dn:4" entity-id="child" instance-id="fred" hypothetical-instance="false" attribute-id="child_age" type="currency"
text="Fred's age is $5.00." inferred="false">
<typ:number-val>5.0</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:5" entity-id="child" instance-id="mary" hypothetical-instance="false" attribute-id="child_money" type="currency"
text="The amount of pocket money Mary has earned is $14.00." inferred="true">
<typ:number-val>14.0</typ:number-val>
<typ:already-proven-node id="dn:3"/>
<typ:attribute-node id="dn:6" entity-id="child" instance-id="mary" hypothetical-instance="false" attribute-id="child_age" type="currency"
text="Mary's age is $7.00." inferred="false">
<typ:number-val>7.0</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
</typ:decision-report>
</typ:total_money>
<typ:base_rate type="currency">
<typ:number-val>2.0</typ:number-val>
</typ:base_rate>
<typ:person_name type="text">
<typ:text-val>Bob</typ:text-val>
</typ:person_name>
<typ:list-child>
<typ:child id="fred">
<typ:child_money type="currency" inferred="true">
<typ:number-val>10.0</typ:number-val>
<typ:decision-report report-style="decision-report">
<typ:attribute-node id="dn:1" entity-id="global" instance-id="global" hypothetical-instance="false" attribute-id="base_rate" type="currency"
text="The pocket money base rate is $2.00." inferred="false">
<typ:number-val>2.0</typ:number-val>
</typ:attribute-node>
<typ:attribute-node id="dn:2" entity-id="child" instance-id="fred" hypothetical-instance="false" attribute-id="child_age" type="currency"
text="Fred's age is $5.00." inferred="false">
<typ:number-val>5.0</typ:number-val>
</typ:attribute-node>
</typ:decision-report>
</typ:child_money>
<typ:child_name type="text">
<typ:text-val>Fred</typ:text-val>
</typ:child_name>
<typ:child_age type="currency">
<typ:number-val>5.0</typ:number-val>
</typ:child_age>
</typ:child>
<typ:child id="mary">
<typ:child_money type="currency" inferred="true">
<typ:number-val>14.0</typ:number-val>
<typ:decision-report report-style="decision-report">
<typ:attribute-node id="dn:1" entity-id="global" instance-id="global" hypothetical-instance="false" attribute-id="base_rate" type="currency"
text="The pocket money base rate is $2.00." inferred="false">
<typ:number-val>2.0</typ:number-val>
</typ:attribute-node>
<typ:attribute-node id="dn:2" entity-id="child" instance-id="mary" hypothetical-instance="false" attribute-id="child_age" type="currency"
text="Mary's age is $7.00." inferred="false">
<typ:number-val>7.0</typ:number-val>
</typ:attribute-node>
</typ:decision-report>
</typ:child_money>
<typ:child_name type="text">
<typ:text-val>Mary</typ:text-val>
</typ:child_name>
<typ:child_age type="currency">
<typ:number-val>7.0</typ:number-val>
</typ:child_age>
</typ:child>
</typ:list-child>
</typ:global-instance>
</typ:assess-response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This example uses a rulebase to calculate the total amount of pocket money a person has to pay. The calculation is based on the pocket money 'base rate' which is piece of reference data that gets loaded into the session using an event handler.
package my.sample.determinations.server.plugin;
import com.oracle.determinations.engine.Attribute;
import com.oracle.determinations.engine.Session;
import com.oracle.determinations.interview.engine.InterviewRulebase;
import com.oracle.determinations.server.assess.extensions.AssessPlugin;
import com.oracle.determinations.server.assess.extensions.AssessPluginRegisterArgs;
import com.oracle.determinations.server.assess.extensions.events.OnBeforeThinkEvent;
import com.oracle.determinations.server.assess.extensions.events.OnBeforeThinkEventHandler;
/**
* Sample Event handler for the OnMapDataEvent
*/
public class SampleOnBeforeThinkEventHandler implements OnBeforeThinkEventHandler {
private static final String RULEBASE_NAME = "EventExample";
private static final Double BASE_RATE = new Double(5.0);
private static final String BASE_RATE_ATTR = "base_rate";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnBeforeThinkEventHandler() {
}
/**
* Event handler that maps in a reference data value for the attribute base_rate.
* @param sender - the instance of the assess engine that fired this event
* @param event - the event fired
*/
public void handleEvent(Object sender, OnBeforeThinkEvent event) {
InterviewRulebase rulebase = event.getRulebase();
if(rulebase.getName().equals(RULEBASE_NAME)){
//set the reference data value "base_rate"
Session session = event.getSession();
Attribute baseRateAttr = rulebase.getRulebase().getGlobalEntity().getAttribute(BASE_RATE_ATTR);
baseRateAttr.setValue(session.getGlobalEntityInstance(), BASE_RATE);
}
}
/**
* Factory method used to create instances of this event handler
*
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public AssessPlugin getInstance(AssessPluginRegisterArgs args) {
return new SampleOnBeforeThinkEventHandler();
}
}
namespace MY.Sample.Determinations.Server.Plugin
{
using System;
using Oracle.Determinations.Masquerade.Lang;
using RBAttr = Oracle.Determinations.Engine.RBAttr;
using Session = Oracle.Determinations.Engine.Session;
using InterviewRulebase = Oracle.Determinations.Interview.Engine.InterviewRulebase;
using AssessPlugin = Oracle.Determinations.Server.Assess.Extensions.AssessPlugin;
using AssessPluginRegisterArgs = Oracle.Determinations.Server.Assess.Extensions.AssessPluginRegisterArgs;
using OnBeforeThinkEvent = Oracle.Determinations.Server.Assess.Extensions.Events.OnBeforeThinkEvent;
using OnBeforeThinkEventHandler = Oracle.Determinations.Server.Assess.Extensions.Events.OnBeforeThinkEventHandler;
/**
* Sample Event handler for the OnBeforeThink Event
*/
public class SampleOnBeforeThinkEventHandler : OnBeforeThinkEventHandler
{
private const string RULEBASE_NAME = "EventExample";
private static readonly Oracle.Determinations.Masquerade.Lang.Double BASE_RATE = new Oracle.Determinations.Masquerade.Lang.Double(5.0);
private const string BASE_RATE_ATTR = "base_rate";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnBeforeThinkEventHandler()
{
}
/**
* Event handler that maps in a reference data value for the attribute base_rate.
* @param sender - the instance of the assess engine that fired this event
* @param event - the event fired
*/
public virtual void HandleEvent(object sender, OnBeforeThinkEvent Event)
{
InterviewRulebase rulebase = Event.GetRulebase();
if (rulebase.GetName().Equals(RULEBASE_NAME))
{
//set the reference data value "base_rate"
Session session = Event.GetSession();
RBAttr baseRateAttr = rulebase.GetRulebase().GetGlobalEntity().GetAttribute(BASE_RATE_ATTR);
baseRateAttr.SetValue(session.GetGlobalEntityInstance(), BASE_RATE);
}
}
/**
* Factory method used to create instances of this event handler
*
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public virtual AssessPlugin GetInstance(AssessPluginRegisterArgs args)
{
return new SampleOnBeforeThinkEventHandler();
}
}
}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample/assess/types">
<soapenv:Header/>
<soapenv:Body>
<typ:assess-request>
<typ:config>
<typ:show-silent>false</typ:show-silent>
<typ:show-invisible>false</typ:show-invisible>
<typ:show-properties>false</typ:show-properties>
<typ:show-events>false</typ:show-events>
<typ:resolve-indecision-relationships>false</typ:resolve-indecision-relationships>
</typ:config>
<typ:global-instance>
<typ:person_name>
<typ:text-val>Bob</typ:text-val>
</typ:person_name>
<typ:total_money outcome-style="decision-report"/>
<typ:list-child>
<typ:child id="fred">
<typ:child_name>
<typ:text-val>Fred</typ:text-val>
</typ:child_name>
<typ:child_age>
<typ:number-val>5.0</typ:number-val>
</typ:child_age>
</typ:child>
<typ:child id="mary">
<typ:child_name>
<typ:text-val>Mary</typ:text-val>
</typ:child_name>
<typ:child_age>
<typ:number-val>7.0</typ:number-val>
</typ:child_age>
</typ:child>
</typ:list-child>
</typ:global-instance>
</typ:assess-request>
</soapenv:Body>
</soapenv:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample/assess/types">
<SOAP-ENV:Header>
<i18n:international>
<i18n:locale>en_GB</i18n:locale>
<i18n:tz>GMT+1000</i18n:tz>
</i18n:international>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<typ:assess-response>
<typ:global-instance>
<typ:total_money type="currency" inferred="true">
<typ:number-val>60.0</typ:number-val>
<typ:decision-report report-style="decision-report">
<typ:relationship-node id="dn:1" source-entity-id="global" source-instance-id="global" hypothetical-instance="false" target-entity-id="child"
relationship-id="children" state="known" inferred="false">
<typ:target instance-id="fred"/>
<typ:target instance-id="mary"/>
</typ:relationship-node>
<typ:attribute-node id="dn:2" entity-id="child" instance-id="fred" hypothetical-instance="false" attribute-id="child_money" type="currency"
text="The amount of pocket money Fred has earned is $25.00." inferred="true">
<typ:number-val>25.0</typ:number-val>
<typ:attribute-node id="dn:3" entity-id="global" instance-id="global" hypothetical-instance="false" attribute-id="base_rate" type="currency"
text="The pocket money base rate is $5.00." inferred="false">
<typ:number-val>5.0</typ:number-val>
</typ:attribute-node>
<typ:attribute-node id="dn:4" entity-id="child" instance-id="fred" hypothetical-instance="false" attribute-id="child_age" type="currency"
text="Fred's age is $5.00." inferred="false">
<typ:number-val>5.0</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:5" entity-id="child" instance-id="mary" hypothetical-instance="false" attribute-id="child_money" type="currency"
text="The amount of pocket money Mary has earned is $35.00." inferred="true">
<typ:number-val>35.0</typ:number-val>
<typ:already-proven-node id="dn:3"/>
<typ:attribute-node id="dn:6" entity-id="child" instance-id="mary" hypothetical-instance="false" attribute-id="child_age" type="currency"
text="Mary's age is $7.00." inferred="false">
<typ:number-val>7.0</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
</typ:decision-report>
</typ:total_money>
<typ:base_rate type="currency">
<typ:number-val>5.0</typ:number-val>
</typ:base_rate>
<typ:person_name type="text">
<typ:text-val>Bob</typ:text-val>
</typ:person_name>
<typ:list-child>
<typ:child id="fred">
<typ:child_name type="text">
<typ:text-val>Fred</typ:text-val>
</typ:child_name>
<typ:child_age type="currency">
<typ:number-val>5.0</typ:number-val>
</typ:child_age>
</typ:child>
<typ:child id="mary">
<typ:child_name type="text">
<typ:text-val>Mary</typ:text-val>
</typ:child_name>
<typ:child_age type="currency">
<typ:number-val>7.0</typ:number-val>
</typ:child_age>
</typ:child>
</typ:list-child>
</typ:global-instance>
</typ:assess-response>
</SOAP-ENV:Body>
This example uses the OnAfterThinkEventHandler to add additional data to the session based on the value of an attribute that was inferred using the data that was submitted into the session.
package my.sample.determinations.server.plugin;
import com.oracle.determinations.engine.Attribute;
import com.oracle.determinations.engine.Session;
import com.oracle.determinations.interview.engine.InterviewRulebase;
import com.oracle.determinations.server.assess.extensions.AssessPlugin;
import com.oracle.determinations.server.assess.extensions.AssessPluginRegisterArgs;
import com.oracle.determinations.server.assess.extensions.events.OnAfterThinkEvent;
import com.oracle.determinations.server.assess.extensions.events.OnAfterThinkEventHandler;
/**
* Sample Event handler for the OnMapDataEvent
*/
public class SampleOnAfterThinkEventHandler implements OnAfterThinkEventHandler {
private static final String RULEBASE_NAME = "EventExample2";
private static final String ELIGIBLE_INCOME_ATTR = "eligible_income";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnAfterThinkEventHandler() {
}
/**
* Factory method used to create instances of this event handler
*
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public AssessPlugin getInstance(AssessPluginRegisterArgs args) {
return new SampleOnAfterThinkEventHandler();
}
public void handleEvent(Object sender, OnAfterThinkEvent event) {
InterviewRulebase rulebase = event.getRulebase();
Session session = event.getSession();
if (rulebase.getName().equals(RULEBASE_NAME)) {
//we only need to add the additional data if the person has eligible income
Attribute eligibleIncomeAttr = rulebase.getRulebase().getGlobalEntity().getAttribute(ELIGIBLE_INCOME_ATTR);
Double eligibleIncomeVal = null;
if (!eligibleIncomeAttr.isUnknown(session.getGlobalEntityInstance()) && !eligibleIncomeAttr.isUncertain(session.getGlobalEntityInstance()))
eligibleIncomeVal = (Double) eligibleIncomeAttr.getValue(session.getGlobalEntityInstance())
if (eligibleIncomeVal != null) {
//The rulebase data loader takes care of creating and loading the reference data for each applicable month
SampleDataLoader.loadMonthlyRebateData(event.getSession());
//because we've loaded additional data into the session, we must call think on the session again
event.getSession().think();
}
}
}
}
namespace MY.Sample.Determinations.Server.Plugin
{
using System;
using Oracle.Determinations.Masquerade.Lang;
using RBAttr = Oracle.Determinations.Engine.RBAttr;
using Session = Oracle.Determinations.Engine.Session;
using InterviewRulebase = Oracle.Determinations.Interview.Engine.InterviewRulebase;
using AssessPlugin = Oracle.Determinations.Server.Assess.Extensions.AssessPlugin;
using AssessPluginRegisterArgs = Oracle.Determinations.Server.Assess.Extensions.AssessPluginRegisterArgs;
using OnAfterThinkEvent = Oracle.Determinations.Server.Assess.Extensions.Events.OnAfterThinkEvent;
using OnAfterThinkEventHandler = Oracle.Determinations.Server.Assess.Extensions.Events.OnAfterThinkEventHandler;
/**
* Sample Event handler for the OnAfterThink Event
*/
public class SampleOnAfterThinkEventHandler : OnAfterThinkEventHandler
{
private const string RULEBASE_NAME = "EventExample2";
private const string ELIGIBLE_INCOME_ATTR = "eligible_income";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnAfterThinkEventHandler()
{
}
/**
* Factory method used to create instances of this event handler
*
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public virtual AssessPlugin GetInstance(AssessPluginRegisterArgs args)
{
return new SampleOnAfterThinkEventHandler();
}
public virtual void HandleEvent(object sender, OnAfterThinkEvent Event)
{
InterviewRulebase rulebase = Event.GetRulebase();
Session session = Event.GetSession();
if (rulebase.GetName().Equals(RULEBASE_NAME))
{
//we only need to add the additional data if the person has eligible income
RBAttr eligibleIncomeAttr = rulebase.GetRulebase().GetGlobalEntity().GetAttribute(ELIGIBLE_INCOME_ATTR);
Oracle.Determinations.Masquerade.Lang.Double eligibleIncomeVal = null;
if (!eligibleIncomeAttr.IsUnknown(session.GetGlobalEntityInstance()) && !eligibleIncomeAttr.IsUncertain(session.GetGlobalEntityInstance()))
eligibleIncomeVal = (Oracle.Determinations.Masquerade.Lang.Double) eligibleIncomeAttr.GetValue(session.GetGlobalEntityInstance());
if (eligibleIncomeVal != null)
{
//The rulebase data loader takes care of creating and loading the reference data for each applicable month
SampleDataLoader.LoadMonthlyRebateData(Event.GetSession());
//because we've loaded additional data into the session, we must call think on the session again
Event.GetSession().Think();
}
}
}
}
}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample2/assess/types">
<soapenv:Header/>
<soapenv:Body>
<typ:assess-request>
<typ:config>
<typ:show-silent>false</typ:show-silent>
<typ:show-invisible>false</typ:show-invisible>
<typ:show-properties>false</typ:show-properties>
<typ:show-events>false</typ:show-events>
<typ:resolve-indecision-relationships>false</typ:resolve-indecision-relationships>
</typ:config>
<typ:global-instance>
<typ:total_rebate outcome-style="decision-report"/>
<typ:person_income>
<typ:number-val>30000</typ:number-val>
</typ:person_income>
</typ:global-instance>
</typ:assess-request>
</soapenv:Body>
</soapenv:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample2/assess/types">
<SOAP-ENV:Header>
<i18n:international>
<i18n:locale>en_GB</i18n:locale>
<i18n:tz>GMT+1000</i18n:tz>
</i18n:international>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<typ:assess-response>
<typ:global-instance>
<typ:total_rebate type="currency" inferred="true">
<typ:number-val>8648.75</typ:number-val>
<typ:decision-report report-style="decision-report">
<typ:relationship-node id="dn:3" source-entity-id="global" source-instance-id="global" hypothetical-instance="false" target-entity-id="monthlyrebate"
relationship-id="personsmonthlyrebate" state="known" inferred="false">
<typ:target instance-id="Month0"/>
<typ:target instance-id="Month1"/>
<typ:target instance-id="Month2"/>
<typ:target instance-id="Month3"/>
<typ:target instance-id="Month4"/>
<typ:target instance-id="Month5"/>
<typ:target instance-id="Month6"/>
<typ:target instance-id="Month7"/>
<typ:target instance-id="Month8"/>
<typ:target instance-id="Month9"/>
<typ:target instance-id="Month10"/>
<typ:target instance-id="Month11"/>
</typ:relationship-node>
<typ:attribute-node id="dn:1" entity-id="global" instance-id="global" hypothetical-instance="false" attribute-id="eligible_income" type="currency"
text="The portion of the person's annual income eligible for a rebate is $3,000.00." inferred="true">
<typ:number-val>3000.0</typ:number-val>
<typ:attribute-node id="dn:2" entity-id="global" instance-id="global" hypothetical-instance="false" attribute-id="person_income" type="currency"
text="The person's annual gross income is $30,000.00." inferred="false">
<typ:number-val>30000.0</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:4" entity-id="monthlyrebate" instance-id="Month0" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $125.00." inferred="true">
<typ:number-val>125.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:5" entity-id="monthlyrebate" instance-id="Month0" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $0.50." inferred="false">
<typ:number-val>0.5</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:6" entity-id="monthlyrebate" instance-id="Month1" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $25.00." inferred="true">
<typ:number-val>25.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:7" entity-id="monthlyrebate" instance-id="Month1" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $0.10." inferred="false">
<typ:number-val>0.1</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:8" entity-id="monthlyrebate" instance-id="Month2" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $300.00." inferred="true">
<typ:number-val>300.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:9" entity-id="monthlyrebate" instance-id="Month2" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $1.20." inferred="false">
<typ:number-val>1.2</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:10" entity-id="monthlyrebate" instance-id="Month3" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $875.00." inferred="true">
<typ:number-val>875.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:11" entity-id="monthlyrebate" instance-id="Month3" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $3.50." inferred="false">
<typ:number-val>3.5</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:12" entity-id="monthlyrebate" instance-id="Month4" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $175.00." inferred="true">
<typ:number-val>175.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:13" entity-id="monthlyrebate" instance-id="Month4" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $0.70." inferred="false">
<typ:number-val>0.7</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:14" entity-id="monthlyrebate" instance-id="Month5" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $200.00." inferred="true">
<typ:number-val>200.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:15" entity-id="monthlyrebate" instance-id="Month5" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $0.80." inferred="false">
<typ:number-val>0.8</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:16" entity-id="monthlyrebate" instance-id="Month6" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $1,125.00." inferred="true">
<typ:number-val>1125.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:17" entity-id="monthlyrebate" instance-id="Month6" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $4.50." inferred="false">
<typ:number-val>4.5</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:18" entity-id="monthlyrebate" instance-id="Month7" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $800.00." inferred="true">
<typ:number-val>800.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:19" entity-id="monthlyrebate" instance-id="Month7" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $3.20." inferred="false">
<typ:number-val>3.2</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:20" entity-id="monthlyrebate" instance-id="Month8" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $1,950.00." inferred="true">
<typ:number-val>1950.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:21" entity-id="monthlyrebate" instance-id="Month8" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $7.80." inferred="false">
<typ:number-val>7.8</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:22" entity-id="monthlyrebate" instance-id="Month9" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $11.25." inferred="true">
<typ:number-val>11.25</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:23" entity-id="monthlyrebate" instance-id="Month9" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $0.04." inferred="false">
<typ:number-val>0.045</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:24" entity-id="monthlyrebate" instance-id="Month10" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $1,375.00." inferred="true">
<typ:number-val>1375.0</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:25" entity-id="monthlyrebate" instance-id="Month10" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $5.50." inferred="false">
<typ:number-val>5.5</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
<typ:attribute-node id="dn:26" entity-id="monthlyrebate" instance-id="Month11" hypothetical-instance="false" attribute-id="montly_rebate"
type="currency" text="The person's monthly rebate amount is $1,687.50." inferred="true">
<typ:number-val>1687.5</typ:number-val>
<typ:already-proven-node id="dn:1"/>
<typ:already-proven-node id="dn:2"/>
<typ:attribute-node id="dn:27" entity-id="monthlyrebate" instance-id="Month11" hypothetical-instance="false" attribute-id="rebate_rate"
type="currency" text="The monthly rebate rate is $6.75." inferred="false">
<typ:number-val>6.75</typ:number-val>
</typ:attribute-node>
</typ:attribute-node>
</typ:decision-report>
</typ:total_rebate>
<typ:person_income type="currency">
<typ:number-val>30000.0</typ:number-val>
</typ:person_income>
<typ:list-monthlyrebate>
<typ:monthlyrebate id="Month0">
<typ:rebate_rate type="currency">
<typ:number-val>0.5</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month1">
<typ:rebate_rate type="currency">
<typ:number-val>0.1</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month2">
<typ:rebate_rate type="currency">
<typ:number-val>1.2</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month3">
<typ:rebate_rate type="currency">
<typ:number-val>3.5</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month4">
<typ:rebate_rate type="currency">
<typ:number-val>0.7</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month5">
<typ:rebate_rate type="currency">
<typ:number-val>0.8</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month6">
<typ:rebate_rate type="currency">
<typ:number-val>4.5</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month7">
<typ:rebate_rate type="currency">
<typ:number-val>3.2</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month8">
<typ:rebate_rate type="currency">
<typ:number-val>7.8</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month9">
<typ:rebate_rate type="currency">
<typ:number-val>0.045</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month10">
<typ:rebate_rate type="currency">
<typ:number-val>5.5</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
<typ:monthlyrebate id="Month11">
<typ:rebate_rate type="currency">
<typ:number-val>6.75</typ:number-val>
</typ:rebate_rate>
</typ:monthlyrebate>
</typ:list-monthlyrebate>
</typ:global-instance>
</typ:assess-response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This example goes through and removes any outcome that is not known, which will result in the service only returning known outcomes.
package my.sample.determinations.server.plugin;
import com.oracle.determinations.engine.Attribute;
import com.oracle.determinations.engine.EntityInstance;
import com.oracle.determinations.engine.Relationship;
import com.oracle.determinations.engine.Session;
import com.oracle.determinations.interview.engine.InterviewRulebase;
import com.oracle.determinations.server.assess.data.*;
import com.oracle.determinations.server.assess.extensions.AssessPlugin;
import com.oracle.determinations.server.assess.extensions.AssessPluginRegisterArgs;
import com.oracle.determinations.server.assess.extensions.events.OnMapDataEvent;
import com.oracle.determinations.server.assess.extensions.events.OnMapDataEventHandler;
import com.oracle.determinations.server.assess.extensions.events.OnReturnResultEvent;
import com.oracle.determinations.server.assess.extensions.events.OnReturnResultEventHandler;
import com.oracle.determinations.server.exceptions.DeterminationsServerException;
import java.util.ArrayList;
import java.util.List;
/**
* Sample Event handler for the SampleOnReturnResult Event
*/
public class SampleOnReturnResultEventHandler implements OnReturnResultEventHandler {
private static final String RULEBASE_NAME = "EventExample";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnReturnResultEventHandler(){
}
/**
* Factory method used to create instances of this event handler
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public AssessPlugin getInstance(AssessPluginRegisterArgs args) {
return new SampleOnReturnResultEventHandler();
}
/**
* Event handler that filters the outcomes and only returns the whose values are known
* @param sender - the instance of the assess engine that fired this event
* @param event - the event fired
*/
public void handleEvent(Object sender, OnReturnResultEvent event) {
InterviewRulebase rulebase = event.getRulebase();
if(rulebase.getName().equals(RULEBASE_NAME)){
Session session = event.getResult().getSession();
//go through all the calculated outcomes and remove the ones that aren't known
List outcomes = new ArrayList(event.getResult().getData().getAllOutcomes());
for(Object obj : outcomes){
AssessOutcome outcome = (AssessOutcome)obj;
AssessEntityInstance assessOutcomeInstance = outcome.getParent();
EntityInstance outcomeInstance = assessOutcomeInstance.getIdentifier().getEntityInstance(session);
boolean isKnown;
if(outcome instanceof RelationshipOutcome){
Relationship rel = outcomeInstance.getEntity().getRelationship(outcome.getId());
isKnown = rel.isKnown(outcomeInstance);
} else {
Attribute attr = outcomeInstance.getEntity().getAttribute(outcome.getId());
isKnown = !attr.isUnknown(outcomeInstance);
}
if(!isKnown){
assessOutcomeInstance.removeOutcome(outcome);
}
}
}
}
}
namespace MY.Sample.Determinations.Server.Plugin
{
using System;
using Oracle.Determinations.Masquerade.Lang;
using RBAttr = Oracle.Determinations.Engine.RBAttr;
using EntityInstance = Oracle.Determinations.Engine.EntityInstance;
using Relationship = Oracle.Determinations.Engine.Relationship;
using Session = Oracle.Determinations.Engine.Session;
using InterviewRulebase = Oracle.Determinations.Interview.Engine.InterviewRulebase;
using Oracle.Determinations.Server.Assess.Data;
using AssessPlugin = Oracle.Determinations.Server.Assess.Extensions.AssessPlugin;
using AssessPluginRegisterArgs = Oracle.Determinations.Server.Assess.Extensions.AssessPluginRegisterArgs;
using OnMapDataEvent = Oracle.Determinations.Server.Assess.Extensions.Events.OnMapDataEvent;
using OnMapDataEventHandler = Oracle.Determinations.Server.Assess.Extensions.Events.OnMapDataEventHandler;
using OnReturnResultEvent = Oracle.Determinations.Server.Assess.Extensions.Events.OnReturnResultEvent;
using OnReturnResultEventHandler = Oracle.Determinations.Server.Assess.Extensions.Events.OnReturnResultEventHandler;
using DeterminationsServerException = Oracle.Determinations.Server.Exceptions.DeterminationsServerException;
using ArrayList = Oracle.Determinations.Masquerade.Util.ArrayList;
using List = Oracle.Determinations.Masquerade.Util.List;
/**
* Sample Event handler for the SampleOnReturnResult Event
*/
public class SampleOnReturnResultEventHandler : OnReturnResultEventHandler
{
private const string RULEBASE_NAME = "EventExample";
/**
* Public nullary constructor required in order to create the plugin factory instance
*/
public SampleOnReturnResultEventHandler()
{
}
/**
* Factory method used to create instances of this event handler
* @param args - An object encapsulating the initialisation arguments to be provided to help the assess plugin implementation initialise and configure itself.
* @return Always unconditionally returns a new instance of this event handler.
*/
public virtual AssessPlugin GetInstance(AssessPluginRegisterArgs args)
{
return new SampleOnReturnResultEventHandler();
}
/**
* Event handler that filters the outcomes and only returns the whose values are known
* @param sender - the instance of the assess engine that fired this event
* @param event - the event fired
*/
public virtual void HandleEvent(object sender, OnReturnResultEvent Event)
{
InterviewRulebase rulebase = Event.GetRulebase();
if (rulebase.GetName().Equals(RULEBASE_NAME))
{
Session session = Event.GetResult().GetSession();
//go through all the calculated outcomes and remove the ones that aren't known
List outcomes = new ArrayList(Event.GetResult().GetData().GetAllOutcomes());
foreach (object obj in outcomes)
{
AssessOutcome outcome = (AssessOutcome) obj;
AssessEntityInstance assessOutcomeInstance = outcome.GetParent();
EntityInstance outcomeInstance = assessOutcomeInstance.GetIdentifier().GetEntityInstance(session);
bool isKnown;
if (outcome is RelationshipOutcome)
{
Relationship rel = outcomeInstance.GetEntity().GetRelationship(outcome.GetId());
isKnown = rel.IsKnown(outcomeInstance);
}
else
{
RBAttr attr = outcomeInstance.GetEntity().GetAttribute(outcome.GetId());
isKnown = !attr.IsUnknown(outcomeInstance);
}
if (!isKnown)
{
assessOutcomeInstance.RemoveOutcome(outcome);
}
}
}
}
}
}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample/assess/types">
<soapenv:Header/>
<soapenv:Body>
<typ:assess-request>
<typ:config>
<typ:show-silent>false</typ:show-silent>
<typ:show-invisible>false</typ:show-invisible>
<typ:show-properties>false</typ:show-properties>
<typ:show-events>false</typ:show-events>
<typ:resolve-indecision-relationships>false</typ:resolve-indecision-relationships>
</typ:config>
<typ:global-instance>
<typ:person_name>
<typ:text-val>Bob</typ:text-val>
</typ:person_name>
<typ:total_money outcome-style="decision-report"/>
</typ:global-instance>
</typ:assess-request>
</soapenv:Body>
</soapenv:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n"
xmlns:typ="http://oracle.com/determinations/server/10.2/EventExample/assess/types">
<SOAP-ENV:Header>
<i18n:international>
<i18n:locale>en_GB</i18n:locale>
<i18n:tz>GMT+1000</i18n:tz>
</i18n:international>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<typ:assess-response>
<typ:global-instance>
<typ:person_name type="text">
<typ:text-val>Bob</typ:text-val>
</typ:person_name>
<typ:list-child></typ:list-child>
</typ:global-instance>
</typ:assess-response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>