Can I convert xlsl decision table into DRL file in KIE WorkBench?

1,173 views
Skip to first unread message

Gaurav Mehta

unread,
Jan 10, 2018, 7:23:15 AM1/10/18
to Drools Usage
I have converted a big spreadsheet into xls decision table in KIE workbench and validated. But, on converting guided decision table, it is giving many errors e..g functions defined in decision table are not appearing and integer & nulls are showing as String.

I have to use the guided decision table in business process.
Either I need suggestions to solve guided decision table errors

or

convert decision table into DRL file so that I can use rules from DRL file in business tasks.

Kindly suggest best approach.

Michael Anstis

unread,
Jan 10, 2018, 7:27:29 AM1/10/18
to Drools Usage
What are the errors?

Do you have the JAR containing the required classes added as a dependency to your project? 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/d56b8c16-eb11-4952-9e76-68fe6b7fd2d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gaurav Mehta

unread,
Jan 10, 2018, 7:46:42 AM1/10/18
to Drools Usage

Thanks for reverting Michael.

I have created decision table from excel where I have defined some functions also

package com.myteam.qofandvaccinationrules;

//generated from Decision Table

import com.myteam.qofandvaccinationrules.SeasonalFluApplicant;

import java.util.Date;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.text.SimpleDateFormat;

import java.lang.Boolean;

 

 

function int isSuccess(boolean bool) { return bool? 1 : 0; }

 

function Date calculateDateBasedonMonths(Date fromDate, Integer months){

   

    Calendar cal = Calendar.getInstance();

    cal.setTime(fromDate);

    cal.add(Calendar.MONTH, months);

    Date modifiedDate = cal.getTime();

 

    return modifiedDate;

}

 

// rule values at G13, header at G8

rule "SFLUCC001-1-1-1"

               ruleflow-group "SFLUCC001-COHORT"

               agenda-group "SFLUCC001-COHORT"

               when

                              $req:SeasonalFluApplicant(getPAT2_AGE() >= 65)

               then

                              System.out.println("1");

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLU001-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI002-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI004-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI006-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI008-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI010-GROUP").setFocus();

end

 

// rule values at G17, header at G8

rule "SFLUCC002-3-2-1"

               ruleflow-group "SFLUCC002-COHORT"

               agenda-group "SFLUCC002-COHORT"

               when

                              $req:SeasonalFluApplicant(getAST_DAT() != null, getASTRES_DAT() == null, getASTTRTATRISK1_DAT() > calculateDateBasedonMonths(getFIRSTVAC_DAT(), -12.00))

               then

                              System.out.println("1");

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLU006-GROUP").setFocus();

end



On conversion to Guided decision table, functions are not appearing and all operator comparisons are showing as String . i.e. calculateDateBasedonMonths function is not appearing at all and > 65 is coming up as > "65"

package com.myteam.qofandvaccinationrules;

 

import com.myteam.qofandvaccinationrules.SeasonalFluApplicant;

import java.util.Date;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.text.SimpleDateFormat;

import java.lang.Boolean;

 

//from row number: 1

//GMS registration status

rule "Row 1 Seasonal Flu"

               ruleflow-group "SFLUCC001-COHORT"

               agenda-group "SFLUCC001-COHORT"

               dialect "mvel"

               when

                              $req : SeasonalFluApplicant( getPAT2_AGE() >= "65")

               then

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLU001-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI002-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI004-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI006-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI008-GROUP").setFocus();

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLUMI010-GROUP").setFocus();

end

 

//from row number: 7

//GMS registration status

rule "Row 7 Seasonal Flu"

               ruleflow-group "SFLUCC002-COHORT"

               agenda-group "SFLUCC002-COHORT"

               dialect "mvel"

               when

                              $req : SeasonalFluApplicant( getAST_DAT() != "null" , getASTRES_DAT() == "null" , getASTTRTATRISK1_DAT() > "-12") )

               then

                              kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup("SFLU006-GROUP").setFocus();

end



Error coming is "
Unable to Analyse Expression getASTTRTATRISK1_DAT() > "-12": [Error: Comparison operation requires compatible types. Found class java.util.Date and class java.lang.String]

Request you to revert at earliest as it is blocking work from past 3 days


On Wednesday, January 10, 2018 at 5:57:29 PM UTC+5:30, Michael Anstis wrote:
What are the errors?

Do you have the JAR containing the required classes added as a dependency to your project? 
On 10 January 2018 at 12:23, Gaurav Mehta <gaurav...@gmail.com> wrote:
I have converted a big spreadsheet into xls decision table in KIE workbench and validated. But, on converting guided decision table, it is giving many errors e..g functions defined in decision table are not appearing and integer & nulls are showing as String.

I have to use the guided decision table in business process.
Either I need suggestions to solve guided decision table errors

or

convert decision table into DRL file so that I can use rules from DRL file in business tasks.

Kindly suggest best approach.

--
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.

Michael Anstis

unread,
Jan 10, 2018, 8:01:30 AM1/10/18
to Drools Usage
You did not state whether the project in which you have added the XLS and converting to Guided Decision Table also has a dependency for whatever JAR contains class SeasonalFluApplicant

To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.

Michael Anstis

unread,
Jan 10, 2018, 8:03:07 AM1/10/18
to Drools Usage
XLS is simple. It just uses String replacement.

The Guided Decision Table conversion tries to derieve the data-type for the column (in the resulting Guided Decision Table) from the known data model (i.e. classes in the project classpath including dependencies).

if the data-type cannot be determined it defaults to String.
Message has been deleted
Message has been deleted

Gaurav Mehta

unread,
Jan 10, 2018, 8:44:31 AM1/10/18
to Drools Usage

SeasonalFluApplicant.java is internal java file created as DO and present in same package as Guided Decision table. And on edit in Guided DT, it is showing the DO name also. Not sure, where I can add it in dependency.


I will send you project zip shortly

Can you let me know where exactly I have to enter DO file in classpath in KIE ?
Auto Generated Inline Image 1

Michael Anstis

unread,
Jan 10, 2018, 8:50:58 AM1/10/18
to Drools Usage
If the class was defined with the Data Object editor it will already be on the project classpath.

I wait the ZIP..

To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Gaurav Mehta

unread,
Jan 10, 2018, 9:15:03 AM1/10/18
to Drools Usage
On attaching Zip file, getting error. Is there any other way, I can send files.

Gaurav Mehta

unread,
Jan 10, 2018, 12:24:26 PM1/10/18
to Drools Usage
Hi Michael

In meantime, request you to give suggestion on my second issue in above post.

functions are showing in the xls decision table e.g calculateDateBasedonMonths but in the generated guided decision table, rule is created but in the condition, function calculateDateBasedonMonths is not appearing at all.


Regards
gaurav

Michael Anstis

unread,
Jan 10, 2018, 1:08:19 PM1/10/18
to Drools Usage
Functions should have been converted to DRL assets.

To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.

Gaurav Mehta

unread,
Jan 10, 2018, 1:11:39 PM1/10/18
to Drools Usage
Yes complete function is created in the DRL assets. But, in the rule condition, where the function is called, function name is not appearing

Decision Table:

$req:SeasonalFluApplicant(getAST_DAT() != null, getASTRES_DAT() == null, getASTTRTATRISK1_DAT() > calculateDateBasedonMonths(getFIRSTVAC_DAT(), -12.00))


Guided Decision Table:
$req : SeasonalFluApplicant( getAST_DAT() != "null" , getASTRES_DAT() == "null" , getASTTRTATRISK1_DAT() > "-12") )

You can see calculateDateBasedonMonths is not appearing.


Regards

Michael Anstis

unread,
Jan 10, 2018, 1:22:29 PM1/10/18
to Drools Usage
I await your ZIP for further investigation then.

To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.

Gaurav Mehta

unread,
Jan 11, 2018, 10:00:36 AM1/11/18
to Drools Usage
Hi Michael

Attaching the zip file

Facing 2 issues:


1) Functions that we are calling in CONDITION in xls, they are appearing fine in Decision Table.

On conversion to Guided Decision Table, 2 files are created

  1. Function DRL file

  2. Guided Decision Table

But in Guided Decision table, in the conditions, function is not coming up due to which we are getting compile type errors.


E.g. calculateDateBasedonMonths function given below not coming up

 

For Example

Code in Decision Table : $req:SeasonalFluApplicant(getASTTRTATRISK1_DAT() > calculateDateBasedonMonths(getFIRSTVAC_DAT(), -12))

Code in Guided Decision Table : $req : SeasonalFluApplicant( getASTTRTATRISK1_DAT() > "-12" )

 

2) Integer are showing in double quotes in guided decision table


$req : SeasonalFluApplicant( getPAT2_AGE() >= "65" )



Though in DRL it is showing as 

$req : SeasonalFluApplicant( getPAT2_AGE() >= 6" )


Kindly help.

myrepo_SampleProj.zip

Gaurav Mehta

unread,
Jan 11, 2018, 9:52:21 PM1/11/18
to Drools Usage
Hi

Request you to revert on our issues. I have attached zip file in yesterday post

Michael Anstis

unread,
Jan 12, 2018, 8:21:44 AM1/12/18
to Drools Usage
The problem appears to be that the workbench does not support expressions on the RHS of the operator correctly.

Can you please raise a DROOLS JIRA and attach your ZIP.

Thanks,

Mike

On 12 January 2018 at 02:52, Gaurav Mehta <gaurav...@gmail.com> wrote:
Hi

Request you to revert on our issues.  I have attached zip file in yesterday post
--
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+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages