Customizing the function handlers of the Omni-Configurator and Visual Modeler repository

You can customize the function handlers in the repository that is shared between the Visual Modeler and the IBM® Sterling Configurator.

About this task

The function handler classes are Java classes that are used to define custom functions that can be invoked by the Omni-Configurator rule engine.

The base function handlers that are provided in the application are defined in the functionHandlers.properties configuration file that is located in the configurator.war/WEB-INF/lib/cmgt-configurator.jar file. The configuration file contains the name of the function handlers and the directory in which the function handler classes are located.

Example of a functionHandlers.properties file:
WEB-INF/classes/com/comergent/apps/configurator/functionHandlers=
CheckLookupFunctionHandler,ChildSum,ChildCount,CountFunctionHandler,IsSelectedHandler,
LengthFunctionHandler,ListFunctionHandler,LookupFunctionHandler,
MaxFunctionHandler,MinFunctionHandler,ParentFunctionHandler,
PropValHandler,StringValue, SumFunctionHandler,ValueFunctionHandler,WebServiceLookup
CheckLookupFunctionHandler=
com.comergent.apps.configurator.function-Handlers.CheckLookupFunctionHandler

Procedure

  1. Create a Java class with the package declaration defined as com.comergent.apps.configurator.functionHandlers. The class declaration must declare that the class extends the AbstractRuleFunctionHandler class. The following methods must be implemented by the Java class.
    Table 1. Java class methods
    Java class methods Description
    public String getFuncName() This method returns the name of the function. It is case-sensitive, which means you can use different function handlers to manage the sum and SUM functions.
    public int getType() This method returns type of the value that is returned by the function. This must be a constant defined in the com.comergent.api.appsservices.rulesEngine.Value class. The AbstractRuleFunctionHandler class method returns Value.STRING. You must override this method if the function returns any other type.
    public Value handle(State state, String prop) This method returns the value that is calculated by the function.
    public boolean isPublicHandler() This method returns true if the function handler is used by a client application. The AbstractRuleFunctionHandler class method returns true. If the function handler is defined as private, you must override this method.
    Note: The custom function handlers must be compiled with the cmgt-configurator.jar and cmgt-rulesEngine.jar files available in the class path. Copy the JAR files from the configurator.war/WEB-INF/lib/ directory.
  2. Go to the location where the Omni-Configurator repository is mounted.
  3. Create a custom function handler properties file CustomFunctionHandlers.properties. Add the details of the custom function handler class SquareValueHandler in the properties file as shown in the following example.

    WEB-INF/classes/com/comergent/apps/configurator/functionHandlers = SquareValueHandler

    SquareValueHandler = com.comergent.apps.configurator.custom.functionHandlers.SquareValueHandler

    Example of a sample properties file:

    WEB-INF/classes/com/comergent/apps/configurator/functionHandlers=
    CheckLookupFunctionHandler,ChildSum,ChildCount,CountFunctionHandler,IsSelectedHandler,
    LengthFunctionHandler,ListFunctionHandler,LookupFunctionHandler,
    MaxFunctionHandler,MinFunctionHandler,ParentFunctionHandler,
    PropValHandler,StringValue, SumFunctionHandler,ValueFunctionHandler,WebServiceLookup
    CheckLookupFunctionHandler=
    com.comergent.apps.configurator.function-Handlers.CheckLookupFunctionHandler
    
  4. Copy the CustomFunctionHandlers.properties file to the properties folder in the Omni-Configurator repository.
  5. Create a JAR file such that it contains the customized function handler class and the CustomFunctionHandlers.properties file.

    For example, create a extensions.jar file such that it contains the com/comergent/apps/configurator/custom/functionHandlers/SquareValueHandler.class and the CustomFunctionHandlers.properties files.

  6. Copy the JAR file to the extensions directory.
    Note: By default, the Helm chart copies the following files while deploying the Visual Modeler application. Create a directory as VM in the configuration repository, if not already present, which is in parallel with the IBM Omni-Configurator.
    • Any *.properties or *.xml file that is placed in the [mounted dir]/VM/properties directory is copied to the <VM_wardir>/WEB-INF/properties directory.
  7. Set the function.handler.files property similar to the following example. This property must be set in the configurator-ext.properties file that is located in the properties folder in the Omni-Configurator repository. If the configurator-ext.properties file does not exist by default, you must create it.

    function.handler.files = /functionHandler.properties,/CustomFunctionHandlers.properties

    The value of the property is a comma-separated list of names of the function handler property files.

    Note: The value of the property must always first point to the file that is provided in the application, followed by a comma-separated list of custom files. The path of a custom file is the context relative path of the file with respect to the location of the extensions.jar file.
  8. Restart the Omni-Configurator pod.

    You can also create function handlers specific to your enterprise by adding the organization code in the CustomFunctionHandlers.properties file. For example, you can create a custom function handler properties file such as matrix_functionHandlers.properties for the organization matrix. In this example, the function handlers that are defined in the properties file are available only to the matrix organization.

Example

OrganizationCode = matrix
MaxFunctionHandler = com.comergent.apps.custom.configurator.functionHandlers.MaxFunctionHandler
.