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.java:9)
at
rules.Rule_Check_NotNullof_rfqId_0Eval0Invoker.evaluate(Rule_Check_NotNullof_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
<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>