Showing posts with label OPA. Show all posts
Showing posts with label OPA. Show all posts

August 7, 2012

Overwriting default functionalities like Save, Load of OPA


In OPA, we can modify the default functionalities like Save, Load etc. One example use case for the need of doing this is, by default in OPA if we click on Save, the data will be saved in an xml file, but if we want to save the data in other services like data base or BPM then we are required to overwrite the Save functionality of the OPA.

To overwrite the default functionalities of the OPA like Save, Load etc, follow the below steps

  • Write a java class by implementing an interface “com.oracle.determinations.interview.engine.plugins.data.DataAdaptorPlugin”
The interface contains the below abstract methods

public InterviewUserData load(SecurityToken securityToken, String string,
                                  InterviewRulebase interviewRulebase)
public String[] listCases(SecurityToken securityToken,
                              InterviewRulebase interviewRulebase)
public String save(SecurityToken securityToken, String string,
                       InterviewSession interviewSession)
public boolean dataAdaptorProvidesCaseID()
public InterviewSessionPlugin getInstance(InterviewSessionRegisterArgs interviewSessionRegisterArgs)

  • According to the functionality to be overwritten, we can choose the method and add the desired code to it. For example, if we want to change save functionality of OPA, write the code in the save() method
 
  • Make jar file to the project and copy the jar file to the path “\Release\web-determinations\WEB-INF\classes\plugins” of OPA project and run the OPA project

Note: If we implement the interface, it will overwrite all the functionalities it supports. The OPA expects us to implement those functionalities.

June 7, 2012

Create Custom functions in OPA

Below is the procedure to create custom functions in OPA (Oracle Policy Automation).



  • Copy the determinations-engine.jar file to library path from OPA (the file exists under the path <project>\Release\web-determinations\WEB-INF\lib\)
  • Create a java class by extending the class “CustomFunction”. Note that a separate class is required to define for every custom function to be used in OPA
  • Overwrite the “evaluate” method which will handle the user request
public Object evaluate(EntityInstance entityInstance, Object[] objects)
  • The class would be like below
public class GetLocCountry extends CustomFunction {
    public GetLocCountry() {
        super();
    }
    public Object evaluate(EntityInstance entityInstance, Object[] objects) {
        return null;
    }
}
  • Make jar to the class file (or include all the classes created into a single jar file)
  • Copy the jar file to the below path of the OPA project
<OPA project>\Development\Extensions\lib\
  • Create extension.xml file under Extensions folder. See below sample extension.xml file
<extension>
    <functions>
        <function name="getLocation" return-type="text">
            <arg name="country_name" type="text"/>
            <handler platform="java”     class="cf.services.GetLocCountry"/>
        </function>
    </functions>
</extension>
  • Build and Run the OPA project