public class RuleSystem extends Object implements Serializable
| Constructor and Description |
|---|
RuleSystem(String ruleSystemName,
IDataProvider dataProvider)
This constructor initializes a rule system of the given name by reading data from the
credentials given in the data source URL.
|
RuleSystem(String ruleSystemName,
IDataProvider dataProvider,
RuleInputConfigurator inputConfig)
This constructor initializes a rule system of the given name by reading data from the
credentials given in the data source URL.
|
| Modifier and Type | Method and Description |
|---|---|
Rule |
addRule(Map<String,String> inputMap)
This method adds a new rule to the rule system.
|
Rule |
addRule(Rule newRule)
This method adds the given rule to the rule system with a new rule id.
|
void |
addRuleInput(RuleInputMetaData ruleInput)
This method adds a new rule input to this rule system.
|
static void |
createNewRuleSystem(RuleSystemMetaData metaData,
IDataProvider dataProvider)
Utility method to create a new rule system via the given data provider
|
boolean |
deleteRule(Rule rule)
This method deletes the given rule from the rule system.
|
boolean |
deleteRule(String ruleId)
This method deletes an existing rule from the rule system.
|
void |
deleteRuleInput(String ruleInputName)
This method deletes the rule input of the given name from this rule system.
|
static void |
deleteRuleSystem(String ruleSystemName,
IDataProvider dataProvider)
Utility method to delete a rule system backed by the given data provider
|
List<Rule> |
getAllApplicableRules(Map<String,String> inputMap)
This method returns a list of all the rules in the rule system.
|
List<String> |
getAllColumnNames()
Returns the names of all the columns in the rule system, including the unique
input and output column names
|
List<Rule> |
getAllRules()
This method returns a list of all the rules in the rule system.
|
List<Rule> |
getConflictingRules(Rule rule)
This method returns a list of rules conflicting with the given rule.
|
List<String> |
getInputColumnNames()
Returns the names of all the columns in the rule system, excluding the unique
input and output column names
|
RuleSystemMetaData |
getMetaData()
this method returns the metadata corresponding to this rule system.
|
String |
getName()
Returns the name of the rule system
|
Rule |
getNextApplicableRule(Map<String,String> inputMap)
This method returns the next rule that will be applicable to the inputs
if the current rule applicable to the were to be deleted.
|
String |
getOutputColumnName() |
Rule |
getRule(Map<String,String> inputMap)
This method returns the rule applicable for the given combination of rule
inputs.
|
Rule |
getRule(Object request)
This method returns the rule applicable for the given combination of rule
inputs.
|
Rule |
getRule(String ruleId)
This method returns the applicable rule for the given input criteria.
|
String |
getUniqueColumnName() |
void |
reload()
This method reloads the whole rule system by pulling fresh configuration and data from the data provider
|
Rule |
updateRule(Rule oldRule,
Rule newRule)
This method updates an existing rules with values of the new rule given.
|
public RuleSystem(String ruleSystemName, IDataProvider dataProvider) throws RuleConflictException
ruleSystemName - Name of the rule system to be instantiateddataProvider - An IDataProvider to load rules fromRuleConflictExceptionpublic RuleSystem(String ruleSystemName, IDataProvider dataProvider, RuleInputConfigurator inputConfig) throws RuleConflictException
ruleSystemName - Name of the rule system to be instantiateddataProvider - An IDataProvider to load rules frominputConfig - Configuration to support custom data types and behaviour for rule inputsRuleConflictExceptionpublic static void createNewRuleSystem(RuleSystemMetaData metaData, IDataProvider dataProvider)
metaData - dataProvider - public static void deleteRuleSystem(String ruleSystemName, IDataProvider dataProvider)
ruleSystemName - public List<Rule> getAllRules()
public List<Rule> getAllApplicableRules(Map<String,String> inputMap)
inputMap - map of rule input values for which applicable rules are to be returnedpublic Rule getRule(Object request) throws IllegalAccessException
request - A simple Object with @RuletteInput annotation on required fields
valuesIllegalAccessException - if rule inputs cannot be accessed on the objectpublic Rule getRule(Map<String,String> inputMap)
inputMap - Map with input names as keys and their String values as
valuespublic Rule getRule(String ruleId)
ruleId - Unique id of the rule to get looked up.Rule object if a rule with the given id exists. null
otherwise.public Rule addRule(Map<String,String> inputMap) throws RuleConflictException
inputMap - The rule input values for which a new rule is to be addedRuleConflictException - if the rule to be added is a conflicting rulepublic Rule addRule(Rule newRule) throws RuleConflictException
newRule - The new rule to be addedRuleConflictException - if the rule to be added is a conflicting rulepublic Rule updateRule(Rule oldRule, Rule newRule) throws RuleConflictException
oldRule - An existing rulenewRule - The rule containing the new field values to which the old
rule will be updated.RuleConflictException - if the updated rule is a conflicting rulepublic boolean deleteRule(String ruleId)
ruleId - Unique id of the rule to be deletedpublic boolean deleteRule(Rule rule)
rule - The Rule to be deleted.public List<Rule> getConflictingRules(Rule rule)
rule - Rule objectpublic Rule getNextApplicableRule(Map<String,String> inputMap)
inputMap - Map with column Names as keys and column values as
values.Rule object if a rule is applicable after the currently
applicable rule is deleted. null if no rule is applicable after the
currently applicable rule is deleted. null id no rule is currently
applicable.public String getUniqueColumnName()
public String getOutputColumnName()
public String getName()
public List<String> getAllColumnNames()
public List<String> getInputColumnNames()
public RuleSystemMetaData getMetaData()
RuleSystemMetaData for this rule systempublic void addRuleInput(RuleInputMetaData ruleInput)
ruleInput - The rule input definition to be addedpublic void deleteRuleInput(String ruleInputName)
ruleInputName - The rule input definition to be deletedpublic void reload()
throws RuleConflictException
RuleConflictExceptionCopyright © 2020. All rights reserved.