Hi
 
I am using Drools 4.0 version with .xml file.
Here is my java program.
 
<-------------------------------------------------------------------------------->
 
package com.wipro.rfq.report.bean;
import java.io.InputStreamReader;
import java.io.Reader;
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.RuleBaseFactory;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
public class Validator {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  try {
         //load up the rulebase
            final RuleBase ruleBase = readRule();
            StatefulSession workingMemory = ruleBase.newStatefulSession();
           
            RFQBean bean=new RFQBean();
            bean.setM_country("India");
            bean.setM_deadLine("two days");
            bean.setM_dueDate("24/10/2007");
            bean.setM_fsUMC("4");
            bean.setM_lotSize("5");
            bean.setM_mtrlType("6");
            bean.setM_partId("1100");
            bean.setM_product("lux");
            bean.setM_rfqId("1234");
           
            workingMemory.insert( bean );
            workingMemory.fireAllRules();
  }catch(Exception e){
         System.out.println("The description of error is "+e);
        }
       
 }
 
 private static RuleBase readRule() throws Exception {
  final Reader source = new InputStreamReader( Validator.class.getResourceAsStream( "/rules/Check.xml" ) );
  
  final PackageBuilder builder = new PackageBuilder();
  
  builder.addPackageFromXml( source );
  
  final Package pkg = builder.getPackage();
  
  final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
        ruleBase.addPackage( pkg );
        return ruleBase;
    }
 public static class RFQBean {
  private String m_rfqId;
  private String m_partId;
  private String m_product;
  private String m_country;
  private String m_lotSize;
  private String m_mtrlType;
  private String m_fsUMC;
  private String m_deadLine;
  private String m_dueDate;
  public String getM_country() {
   return m_country;
  }
  public void setM_country(String m_country) {
   this.m_country = m_country;
  }
  public String getM_deadLine() {
   return m_deadLine;
  }
  public void setM_deadLine(String line) {
   m_deadLine = line;
  }
  public String getM_dueDate() {
   return m_dueDate;
  }
  public void setM_dueDate(String date) {
   m_dueDate = date;
  }
  public String getM_fsUMC() {
   return m_fsUMC;
  }
  public void setM_fsUMC(String m_fsumc) {
   m_fsUMC = m_fsumc;
  }
  public String getM_lotSize() {
   return m_lotSize;
  }
  public void setM_lotSize(String size) {
   m_lotSize = size;
  }
  public String getM_mtrlType() {
   return m_mtrlType;
  }
  public void setM_mtrlType(String type) {
   m_mtrlType = type;
  }
  public String getM_partId() {
   return m_partId;
  }
  public void setM_partId(String id) {
   m_partId = id;
  }
  public String getM_product() {
   return m_product;
  }
  public void setM_product(String m_product) {
   this.m_product = m_product;
  }
  public String getM_rfqId() {
   return m_rfqId;
  }
  public void setM_rfqId(String id) {
   m_rfqId = id;
  }
 }
}
<----------------------------------------------------------------------------------------------------->
 
And my .xml file is the following:
 
<------------------------------------------------------------------------------------------------------>

<?xml version="1.0" encoding="UTF-8"?>

<package name="rules"

xmlns="http://drools.org/drools-4.0"

xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"

xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">

<import name="com.wipro.rfq.report.bean.Validator.RFQBean" />

<import name="java.util.regex.Pattern" />

<global identifier="bean" type="com.wipro.rfq.report.bean.Validator.RFQBean" />

<rule name="Check_NotNullof_rfqId"> <!--start of rule 1-->

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_rfqId">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_rfqId is null");

</rhs>

</rule> <!--end of rule 1-->

<rule name="Check_NotNullof_partId">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_partId">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_partId is null");

</rhs>

</rule>

<rule name="Check_NotNullof_product">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_product">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_product is null");

</rhs>

</rule>

<rule name="Check_NotNullof_country">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_country">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_country is null");

</rhs>

</rule>

<rule name="Check_NotNullof_lotSize">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_lotSize">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_lotSize is null");

</rhs>

</rule>

<rule name="Check_NotNullof_mtrlType">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_mtrlType">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_mtrlType is null");

</rhs>

</rule>

<rule name="Check_NotNullof_fsUMC">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_fsUMC">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_fsUMC is null");

</rhs>

</rule>

<rule name="Check_NotNullof_deadLine">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_deadLine">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_deadLine is null");

</rhs>

</rule>

<rule name="Check_NotNullof_Date">

<lhs>

<pattern identifier="bean" object-type="RFQBean" >

<field-constraint field-name="m_dueDate">

<literal-restriction evaluator="==" value="null" />

</field-constraint>

</pattern>

</lhs>

<rhs>

System.out.println("The value of m_dueDate is null");

</rhs>

</rule>

<rule name="temp">

<lhs>

<eval>bean.getM_dueDate().trim().equals("24/10/2007")</eval>

</lhs>

<rhs>

System.out.println("The entered date is "+bean.getM_dueDate());

</rhs>

</rule>

</package>

 

<---------------------------------------------------------------------------------------------------------------------------------------------------->

Now i want to know that how can i use a method of    "RFQBean"  class inside the <lhs></lhs> and <rhs></rhs>tag

And please mail me the description of all the tags that i can use in a rule based .xml file.

Also how can i know that whether a particular rule has been fired or not.


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com