Simple example with Rule Engine (easy-rules):
- save rules via REST API
- save composite rules via REST API
- process entity through rules via REST API
Java 11
./gradlew bootRun
URL - http://localhost:8080/rules
HTTP Method - POST
{
"name": "person rule 1",
"description": "simple person rule for save",
"priority": 1,
"condition": "person.item.name == \"some item\"",
"action": "savePerson"
}
URL - http://localhost:8080/rules/composite
HTTP Method - POST
{
"name": "composite person rule 1",
"rules": [
{
"name": "person rule 2",
"description": "simple person rule for send to vendor one",
"priority": 1,
"condition": "person.age > 10",
"action": "sendPersonToVendorOne"
},
{
"name": "person rule 3",
"description": "simple person rule for send to vendor two",
"priority": 1,
"condition": "person.item.count == 1",
"action": "sendPersonToVendorTwo"
}
]
}
URL - http://localhost:8080/persons
HTTP Method - POST
{
"name": "some name",
"age": 18,
"item": {
"name": "some item",
"count": 1
}
}
Response:
{
"person rule 1": true,
"composite person rule 1": true
}
URL - http://localhost:8080/persons
HTTP Method - GET
Response:
[
"savePerson",
"sendPersonToVendorOne",
"sendPersonToVendorTwo",
"sendPersonToVendorThree"
]