Hi,
    I would like to execute specific rules from the rule file(.xml).
Find the rule file content below. There are three rules are available in
the xml file(Rule names: 1.Check_NotNullof_rfqId ,
2.Check_NotNullof_partId and 3.validateFullName)
    First time we are trying to execute 1.Check_NotNullof_rfqId and
2.Check_NotNullof_partId rules. next time we are trying to execute
3.validateFullName rule
 
We have tried the following option 
 
The rule name start with "Check" require to set only "rfq" global
identifier.
So when we execute first two rules we followed following approach
workingMemory.setGlobal("rfq",rfqbean);
workingMemory.fireAllRules(new RuleNameStartsWithAgendaFilter( "Check"
));  
 
but it gives following NullPointerException. It is trying to execute
validatefullname rule also.
Caused by: java.lang.NullPointerException
at
rules.Rule_Check_NotNullof_rfqId_0.eval0(Rule_Check_NotNullof_rfqId_0.ja
va:9)
at
rules.Rule_Check_NotNullof_rfqId_0Eval0Invoker.evaluate(Rule_Check_NotNu
llof_rfqId_0Eval0Invoker.java:16)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:71)
... 12 more
 
When  we execute third rule alone. we followed following approach
workingMemory.setGlobal("loanApplication",loanApplicationbean);
workingMemory.fireAllRules(new RuleNameStartsWithAgendaFilter(
"validate" ));
 
 
Please help us to resolve this issue
 
XML rule File
 
<?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" />
 <global identifier="rfq"
type="com.wipro.rfq.report.bean.Validator.RFQBean" />
  
 <rule name="Check_NotNullof_rfqId">            <!--start of rule 1-->
  <lhs>
   <eval>(rfq.getM_rfqId() =="null") ||
(rfq.getM_rfqId().trim().equals(""))</eval>
  </lhs>
  <rhs>
   System.out.println("The value of m_rfqId is null");
  </rhs>
 </rule>                   
 
 <rule name="Check_NotNullof_partId"> 
  <lhs>
   <eval>(rfq.getM_partId() =="null") ||
(rfq.getM_partId().trim().equals(""))</eval>
  </lhs>
  <rhs>
   System.out.println("The value of m_partId is null");
  </rhs>
 </rule>
 
 <import name="com.wipro.loan.validation.bean.LoanApplicationBean" />
 <global identifier="loanApplication"
type="com.wipro.loan.validation.bean.LoanApplicationBean" />
 

  <rule name="validateFullName">
  <lhs>
 
    <eval>loanApplication.getFullName() == null ||
loanApplication.getFullName().trim().equals("")</eval>
  </lhs>
 <rhs>
  System.out.println("full name is null from xml");
  </rhs>
  </rule>
</package>



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
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to