I'm using Drools templates to generate Rules from a spreadsheet. I have some problems with empty cell. Does anybody know how to check if a cell or the variable is empty? This is the template:
template header
pid
department
maxAmount
storeId
package X.X.X
declare MaxAmountStore
amount : Integer
storeId : String
end
template "FOO"
rule "MaxAmountStore_@{row.rowNumber}"
when
Product(pid == "@{pid}")
Product(departmentId == "@{department}")
then
System.out.println("New MaxAmountStore: @{maxAmount} (store: @{storeId})");
insert( new MaxAmountStore(@{maxAmount}, "@{storeId}"));
end
end
Is it possible to have an empty storeId?
I think you need this: if there's nothing in the cell, you don't care about the departmentId value and want to fire the rule based on pid alone.
template "FOO"
rule "MaxAmountStore_@{row.rowNumber}"
when
Product( pid == "@{pid}"&&
("" == "@{department}" || departmentId == "@{department}") )
then
...
end