I am new with Drools and I am using Business Central 7.18.0 to implement some rules using the asset Decision Tables (Spreadsheet).
I have achieve to implement some basic rules with excel and try them with Postman using the REST API but now I need to implement a more complex validation using (if possible) the arrays which come in the input in the when condition.
For example, If I have the next object:
package com.myspace.arraystreatmentconditions;
/**
* This class was automatically generated by the data modeler tool.
*/
public class Client implements java.io.Serializable {
static final long serialVersionUID = 1L;
private java.util.List<java.lang.String> cart;
private java.util.List<java.lang.String> client_products;
private java.lang.String client_status;
private java.lang.String serviceability;
private java.lang.String result;
public Client() {
}
public java.util.List<java.lang.String> getCart() {
return this.cart;
}
public void setCart(java.util.List<java.lang.String> cart) {
this.cart = cart;
}
public java.util.List<java.lang.String> getClient_products() {
return this.client_products;
}
public void setClient_products(
java.util.List<java.lang.String> client_products) {
this.client_products = client_products;
}
public java.lang.String getClient_status() {
return this.client_status;
}
public void setClient_status(java.lang.String client_status) {
this.client_status = client_status;
}
public java.lang.String getServiceability() {
return this.serviceability;
}
public void setServiceability(java.lang.String serviceability) {
this.serviceability = serviceability;
}
public java.lang.String getResult() {
return this.result;
}
public void setResult(java.lang.String result) {
this.result = result;
}
public Client(java.util.List<java.lang.String> cart,
java.util.List<java.lang.String> client_products,
java.lang.String client_status, java.lang.String serviceability,
java.lang.String result) {
this.cart = cart;
this.client_products = client_products;
this.client_status = client_status;
this.serviceability = serviceability;
this.result = result;
}
}
Here we have some attributes which are ArrayList.
- "cart" are the the new products that the client is contracting
- "client_products" are the products that the client currently has contracted(portfolio)
I would like to build a rule for Drools in a XLSX file where, in the conditions (not in the action if possible) the rule will check the cart and the actual client products. If the client_status is "Active" and we find any product in the cart which is already in the client portfolio then we will fill the attribute "result" with a message.
My principal idea is do it using a decision table but I am open to hear other solutions. The problem is I can't find example.