Rules Engine - Open Data API

The Open Data API supports the same Rules Engine functionality as SuperWEB2. The Rules Engine is used for applying business rules to table queries. For example: the mandatory fields rule automatically adds required fields/field values to queries and the field exclusion rule restricts specific combinations of fields that are permitted in queries.

By configuring the Rules Engine for the Open Data API you can apply the same restrictions to API results as through the SuperWEB2 browser interface.

Activate Rules for the Open Data API

For most rules there are two steps required to activate and configure the rule:

  1. Configure the rule settings in SuperADMIN. If you have already enabled a particular rule for SuperWEB2 then you will already have completed this step. The Open Data API will use the same configuration settings.
  2. Enable the rule in the RulesEngine.xml file. SuperWEB2 and the Open Data API have their own separate copies of this configuration file, so you will need to repeat this step on the Open Data API copy of this file.

The Open Data API copy of the RulesEngine.xml configuration file is located in <tomcat_home>\webapps\webapi#rest#v1\WEB-INF\data\.repository\RulesEngine.xml.

To activate a particular rule through the API:

  1. Locate the following section:

        <rules:RulesPipe name="OpenDataApiRules">
            <rules:rule-name name="TableCellsNumberRule"/>
            <rules:rule-name name="FieldExclusionRule"/>
            <!-- <rules:rule-name name="MandatoryFieldsRule"/> -->
        </rules:RulesPipe>
  2. Remove the comments from any rules you want to activate and/or comment out any rules you want to deactivate. For example, to apply the mandatory fields rule, remove the comments as follows:

        <rules:RulesPipe name="OpenDataApiRules">
            <rules:rule-name name="TableCellsNumberRule"/>
            <rules:rule-name name="FieldExclusionRule"/>
            <rules:rule-name name="MandatoryFieldsRule"/>
        </rules:RulesPipe>
  3. Save your changes and restart the Tomcat service.

Enabling the Mandatory Fields Rule for the Open Data API

If you want to enable mandatory fields through the API, then you need to do the following:

  • Enable the rule in the OpenDataApiRules section. This enforces the mandatory fields restriction through the API. 
  • Enable the rule in the NewTableRules section. This automatically adds the mandatory field items to queries submitted to the API:
    <rules:RulesPipe name="NewTableRules">
        <rules:rule-name name="MandatoryFieldsRule"/> 
    </rules:RulesPipe>

This configuration will ensure that any mandatory fields are automatically added to API queries.

Do not uncomment the instance of the MandatoryFieldsRule in the CDataOnlineEditRules section. This configuration is not supported by the Open Data API.