How to write Drool rules in Excel sheet?

混江龙づ霸主 提交于 2019-12-23 02:25:13

问题


Can we write Drool rules in Excel sheet? Can rules be used for simple human readable content? If we can then how it can be done? Please explain.


回答1:


Yes you can. How about reading the section of the user guide called "Decision Tables in Spreadsheets"?

http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/#d0e1157




回答2:


It is better to start with sample rules excel generated using Eclipse Drools Plugin. It gives many things already set up. Just change the data inside and use decision tables excel for your program. In this Drools Decision Table Tutorial, same method is used for Drools 6.4




回答3:


Yes, you can write rules in Spread Sheet Xls and after uploading those rules will automatically convert to drl. If you have lots of similar rules with different values you can make use of Drools Decision Tables. You can define the decision tables in an Excel spreadsheet (the .xls file).

I am attaching simple rule file that may help you In this example we are deciding rate according to Age of renter, Time(Duration of loan), and the sex.

Data Model:

package demopro.demopro;

/**
 * This class was automatically generated by the data modeler tool.
 */

public class Customer implements java.io.Serializable
{

   static final long serialVersionUID = 1L;

   private java.lang.Integer time;
   private java.lang.Integer age;
   private java.lang.Integer interest;
   private java.lang.String gender;
   private java.lang.Integer rate;
   private java.lang.Integer amount;

   public Customer()
   {
   }

   public java.lang.Integer getTime()
   {
      return this.time;
   }

   public void setTime(java.lang.Integer time)
   {
      this.time = time;
   }

   public java.lang.Integer getAge()
   {
      return this.age;
   }

   public void setAge(java.lang.Integer age)
   {
      this.age = age;
   }

   public java.lang.Integer getInterest()
   {
      return this.interest;
   }

   public void setInterest(java.lang.Integer interest)
   {
      this.interest = interest;
   }

   public java.lang.String getGender()
   {
      return this.gender;
   }

   public void setGender(java.lang.String gender)
   {
      this.gender = gender;
   }

   public java.lang.Integer getRate()
   {
      return this.rate;
   }

   public void setRate(java.lang.Integer rate)
   {
      this.rate = rate;
   }

   public java.lang.Integer getAmount()
   {
      return this.amount;
   }

   public void setAmount(java.lang.Integer amount)
   {
      this.amount = amount;
   }

   public Customer(java.lang.Integer time, java.lang.Integer age,
         java.lang.Integer interest, java.lang.String gender,
         java.lang.Integer rate, java.lang.Integer amount)
   {
      this.time = time;
      this.age = age;
      this.interest = interest;
      this.gender = gender;
      this.rate = rate;
      this.amount = amount;
   }    
}

Decision Table(SpreadSheet):



来源:https://stackoverflow.com/questions/19995147/how-to-write-drool-rules-in-excel-sheet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!