Library Business Rule Commands¶
Library business rules can be manipulated from a Library Entity Business Rules level.
The commands that can be performed are as follows:
Command | Purpose |
---|---|
add | Add a new library business rule |
copy | Copies multiple library business rules to a real entity |
Add¶
To add a library business rule, the request may contain the fields below:
{
"command": "add",
"data": {
"NAME" : "Rule4",
"DESCRIPTION" : "description",
"ENABLED" : "1",
"EXPRESSION" : "attr2>0",
"FILTER_EXPRESSION" : "new2>9",
"GROUP_EXPRESSION" : "new5=0",
"GROUP_LIMIT" : "0",
"AGGREGATE_EXPRESSION" : "acc_id<0",
"AGGREGATE_METHOD" : "0",
"PRIORITY" : "1",
"THRESHOLD" : "100",
"INDEX_CONTROL":"",
"INDEX_THRESHOLD":"",
"RULE_KEYWORD_ID_LIST":"1 0:2 1"
}
}
The required fields for adding a rule are:
- EXPRESSION
- THRESHOLD
- NAME
The additional expressions (AGGREGATE_EXPRESSION
, FILTER_EXPRESSION
, GROUP_EXPRESSION
) are optional; it is possible to add a library business rule without specifying any of these expressions. Here is a table specifying the values required for different fields.
Field | Description | Values |
---|---|---|
EXPRESSION | Humanized expression | |
THRESHOLD | Numerical threshold value | Between 0 to 100 |
ENABLED | Name of the library rule | 0 or 1 |
DESCRIPTION | Description of the library rule | |
FILTER_EXPRESSION | Humanized expression for filter | |
AGGREGATE_EXPRESSION | Humanized aggregate expression | |
GROUP_EXPRESSION | Humanized group expression | |
GROUP_LIMIT | Numerical value for group limit | |
AGGREGATE_METHOD | Name of aggregate method | 0 to 4. Here is the mapping of the number to aggregate method:0-Sum 1-Average 2-Maximum 3-Minimum and 4-Count |
INDEX_CONTROL | Numeric value | 0 1 or 2. Mapping of number to index_control: 0-Normal 1-Unlimited and 2-Limited. |
INDEX_THRESHOLD | Valid only if INDEX_CONTROL is 2 | |
PRIORITY | Numeric value between 1 and 10 | |
RULE_KEYWORD_ID_LIST | Array of keyword IDs | List of <category_id keyword_id> separated by colon. A value of 0 in keyword_id fields specify that the rule is attached to all the keywords of that category. |
Copy¶
The request packet must contain the command
and data
elements. The options
element is not required.
{
"command" : "copy",
"data" : {
"entity": "3",
"library": "2",
"rules": ["1"],
"mappings": [
{
"realAttr": "1",
"libAttr": "1"
},
{
"realAttr": "2",
"libAttr": "2"
}
]
}
}
The data element should contain two key-value pairs:
Key | Purpose |
---|---|
entity | ID of the real entity |
library | ID of the library entity |
rules | Rule ids of the rules to be copied |
mappings | Array of attribute mappings |
All the fields are required.
All the library rules specified in rules field will be copied from the library entity specified in library field to the real entity specified in entity filed. mappings should contain an array of attribute ID mappings for the library rules to be copied.
POST /api/repositories/jupiter/library/entities/2/businessrules HTTP/1.1
Content-Type: application/json
{
"command": "copy",
"data": {
"entity": "3",
"library": "2",
"rules": ["1"],
"mappings": [
{
"realAttr": "1",
"libAttr": "1"
},
{
"realAttr": "2",
"libAttr": "2"
}
]
}
}
A job is scheduled to run the copy job in the background; the response to the request will contain the URL of the scheduled task.
{
"url": "/api/repositories/jupiter/scheduler/50"
}