passing null as a condition param

402 views
Skip to first unread message

Qbyte Consulting

unread,
Jan 20, 2021, 12:25:10 AM1/20/21
to Drools Usage
Hi,

Is there a way to pass a null to the conditions param value so the rule isn't encoded like this? $p: PromotionApplication(promotionCode == "null")

Butt like this $p: PromotionApplication(promotionCode == null)

John

Nicolas Héron

unread,
Jan 20, 2021, 2:06:13 AM1/20/21
to Drools Usage
Hi,
you found the solution yourself :)
$p: PromotionApplication(promotionCode == null)
Nicolas

Qbyte Consulting

unread,
Jan 20, 2021, 3:42:16 AM1/20/21
to Drools Usage
sorry I forgot to mention the null value is a param from an Excel decision table, that's why it gets quoted

Toni Rikkola

unread,
Jan 22, 2021, 7:26:10 AM1/22/21
to drools...@googlegroups.com
If you can't move the == null to the column header, you might have to make a separate column.

if plain "promotionCode == null" in the header does not work try "promotionCode == null?" 

The support for the end ? was added in recent versions so depends what you are using if it works or not.

Toni

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/fbc7a24c-290e-4fc7-868b-9925e5d2714dn%40googlegroups.com.

Afzal Shaik

unread,
Dec 6, 2023, 2:30:19 AM12/6/23
to Drools Usage
Hi I too have the same requirement where my drools decision table dont have value in a column means it wont be considered in the when condition
But i want to show as null in drl file  for the attribute which is empty in decision table.

if plain "promotionCode == null" in the header does not work try "promotionCode == null?" 
this didnt worked for me while passing in condition over the top of all row data
Kindly need help regarding this

Toni Rikkola

unread,
Dec 6, 2023, 4:02:51 AM12/6/23
to drools...@googlegroups.com
With XLS decision tables it is possible to make a new column where the header has no parameters and then when that column needs to be included, just use X in the cell.

Toni

Afzal Shaik

unread,
Dec 6, 2023, 4:43:12 AM12/6/23
to Drools Usage
but in my requirement a cell can be empty so i dont want to give any dummy values such as X inside but need to handle it somehow

Afzal Shaik

unread,
Dec 6, 2023, 5:07:44 AM12/6/23
to Drools Usage
Based on your approach after giving value as X
when
$rule: ServiceRuleRequest(validateHierarchy(hierarchy,"Some value"), validateRegion(region,"Some value"), validateType(Type,"X"))
then
Object $obj = new Object();
$obj.setRequirement("Value to be set");
        $obj.setTask("Task to be set");

But i want to show my rule like this where Type is null by default
when
$rule: ServiceRuleRequest(validateHierarchy(hierarchy,"Some value"), validateRegion(region,"Some value"), validateType(Type,null))
then
Object $obj = new Object();
$obj.setRequirement("Value to be set");
        $obj.setTask("Task to be set");

Toni Rikkola

unread,
Dec 11, 2023, 3:19:59 PM12/11/23
to drools...@googlegroups.com
Does typing in null work? If "" quotes are added in the cell this should work. Another option is to make another column for "validateType(Type,null)" where the null is set in the header and Type is set in the column cells.

Toni

Afzal Shaik

unread,
Dec 13, 2023, 12:20:52 AM12/13/23
to Drools Usage
Hi,
Thanks for the reply Toni,
giving null or " " in template cells is not a part of my requirement,
The cells in a condition are blank means drools itself should convert those while compiling into drl file  to null,
Is there any way to do it

Toni Rikkola

unread,
Dec 14, 2023, 6:12:51 AM12/14/23
to drools...@googlegroups.com
For this, I think you need to fork the drools-decisiontables and change the behaviour to this.

Toni

Afzal Shaik

unread,
Dec 18, 2023, 9:15:14 AM12/18/23
to Drools Usage
Hi Toni,
Can you please give me brief walk through in the souce stating what are the changes need to be done and in which area to handle null before compiling the xls Drools template
to .drl file and pushing in working memory, so that i can check with the same and work on it.

Regards Afzal Shaik
Thank You.

Afzal Shaik

unread,
Dec 19, 2023, 1:33:37 AM12/19/23
to Drools Usage
Hi Toni,
I have gone through this code  drools-decisiontables  but the version of this source is 8.45.0 SNAPSHOT,
We are currently using 7.73.0-Final version,
Is there any way can we get the 7.73.0-Final version source. 

Thanks in Advance.
Regards Afzal Shaik,

Toni Rikkola

unread,
Dec 19, 2023, 5:28:01 AM12/19/23
to drools...@googlegroups.com

Afzal Shaik

unread,
Dec 21, 2023, 2:01:45 AM12/21/23
to Drools Usage
Hi Toni,
Thanks for providing the source,
Let me look into it.

Regards Afzal Shaik.

Afzal Shaik

unread,
Dec 21, 2023, 6:28:04 AM12/21/23
to Drools Usage
Hi Toni,
I have gone through the above source and made some changes in excel parser.java where
if(cell == null) {
continue;
}
I am altering it and making custom condition and setting some value if cell is null in my rule table 
after imports and rule table condition, Action keywords
I am getting this exception please guide me with this  
Caused by: org.drools.template.parser.DecisionTableParseException: Unexpected content "Null" in cell C6, leave this cell blank
at org.drools.decisiontable.parser.ActionType.addTemplate(ActionType.java:183)
at org.drools.decisiontable.parser.DefaultRuleSheetListener.codeRow(DefaultRuleSheetListener.java:586)
at org.drools.decisiontable.parser.DefaultRuleSheetListener.processRuleCell(DefaultRuleSheetListener.java:495)
at org.drools.decisiontable.parser.DefaultRuleSheetListener.newCell(DefaultRuleSheetListener.java:363)
at org.drools.decisiontable.parser.xls.ExcelParser.newCell(ExcelParser.java:140)
at org.drools.decisiontable.parser.xls.ExcelParser.processSheet(ExcelParser.java:160)
at org.drools.decisiontable.parser.xls.ExcelParser.parseWorkbook(ExcelParser.java:358)
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:114)
at org.drools.decisiontable.SpreadsheetCompiler.parseResource(SpreadsheetCompiler.java:133)
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:120)
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:93)
now getting this
Reply all
Reply to author
Forward
0 new messages