2

I am working on an application in Java in which various properties of a PRODUCT is set, based on the rules set by the client. The system should be able to save the rules defined by the Client and the properties should be set based on conditions defined in the rule. sample rules will be like:

------------RULE1
 IF CLIENT_TYPE='INDIVIDUAL' and SALARY < 5000
       FEECODE = 101
       VALUECODE =102
 ELSE
       FEECODE = 103
       VALUECODE= 100

------------RULE2
  IF CLIENT_TYPE='COMPANY'
        FEECODE = 105
        VALUECODE =302
  ELSE
        FEECODE = 303
        VALUECODE= 402

I'm storing the conditions and operators in CONDITION table and Parameters (SALARY,CLIENT_TYPE,FEECODE,VALUECODE .. etc) and their categories in PARAMETERS table. The Intermediate statements between IF - ELSE Block is stored in a Separate Table, CONDITION_STATEMENT. (similar (not exact) to the table structure defined in second answer here: Storing Business Logic in Database)

Now I'm facing an issue that these PARAMETERS are populated in memory (not in Database) at the time of firing the rule, and each PARAMETER behaviour is different w.r.to each other. Say in the above rule, SALARY will be populated in one variable (not always in same variable in every scenarios) and CLIENT_TYPE in another variable. Considering this, how can write a generic rule engine for all these scenarios? OR Am I missing some thing in this?

The Table Structure is as below:

PARAMETER Table
---------------
PARAM_ID
CATEGORY_ID
PARAMETER
PARAMETER_DESC

CONDITION Table
---------------
RULE_ID
RELATION_OPERATOR
PARAMETER
CONDITIONAL_OPERATOR
VALUE


CONDITION_STATEMENT Table
---------------------
id
RULE_ID
STATEMENT
VALUE
Community
  • 1
  • 1
Umesh C G
  • 45
  • 5

0 Answers0