Reputation: 31
I have created a rule
rule "NullCheck_Rule1"
salience 1
dialect "mvel"
date-effective "16-Nov-2017 00:00"
no-loop
when
$cdr : JSONObject( $cdr.optString("name") == null)
then
$cdr.put("Action_1" ,"SEND MAIL");end
and for not null
rule "NullCheck_Rule1"
salience 1
dialect "mvel"
date-effective "16-Nov-2017 00:00"
no-loop
when
$cdr : JSONObject( $cdr.optString("name") != null)
then
$cdr.put("Action_1" , "SEND MAIL");end
and my input is something like this "{\"id\":100,\"name\":null,\"city\":\"Pune\"}"
But its not matching the conditions even if I used condition like $cdr.optString("name") IS NULL
OR $cdr.optString("name") IS NOT NULL
So how to handle null and not null in drools. The version of drools which I am using is 6.5.0.Final.
Upvotes: 0
Views: 2507
Reputation: 1
I imported package in drools import code block to handle NULL or NOT NULL.for examaples "import org.apache.commons.lang3.StringUtils;" package before rule block,use isBlank/isNotBlank function in rule block to handle the Null problome.
Upvotes: 0