Hi,
I am trying to work on below rules, there are no compilation errors and all
rules getting executed.
Obersation:
1. Able print message in first rule consequence.
2. Unable to print message in second rule consequence.
3. Not getting exception in the last rule. The Test Data i am working on
should generate one exception in the last rule.
It would be really very helpful if anyone can help.
Thanks and Regards,
Ritesh
Below is my DRL File:
import java.util.List;
import java.math.*;
import java.util.*;
import java.text.*;
import org.apache.commons.lang.*;
declare DistinctAT
d_auditT : String
end
declare ActualSum
auditT : String
tranType : String
sumOfThree : BigDecimal
end
rule "insert combined sum"
agenda-group "init"
auto-focus true
no-loop true
salience 10
dialect 'java'
when
GNMVT( movTransactionType == 'OD', $movType : idMovMovementType,
$tradeSta : movTradeStatus,
$fndCstPrc : movFundCostPrice, $movTranType : movTransactionType,
$movAuditT : movAuditTrail )
//not ActualSum(auditT == $movAuditT, tranType == $movTranType)
then
BigDecimal actSum =
resltForMovTyp($movType).multiply(resltForMovTrdSts($tradeSta)).multiply($fndCstPrc);
ActualSum $as = new ActualSum();
$as.setAuditT($movAuditT);
$as.setTranType($movTranType);
$as.setSumOfThree(actSum);
insert($as);
System.out.println("AT :" + $movAuditT + " Actual Sum :" +
actSum);
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Second").setFocus();
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Third").setFocus();
end
rule "insert distinct AT"
agenda-group "Second"
auto-focus true
dialect 'java'
when
$a : ActualSum( $AT : auditT )
not DistinctAT( d_auditT == $AT )
then
DistinctAT $disAT = new DistinctAT();
$disAT.setD_auditT($AT);
insert($disAT);
//System.out.println("Distinct Audit Trial :" + $AT + "TotlNet
:" +
$lfna_MO.getPtnaFundTotalNetAsset());
//System.out.println("TotlNet :" +
$lfna_MO.getPtnaFundTotalNetAsset());
System.out.println("Done!");
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Third").setFocus();
end
global ExceptionList exceptions
rule "gpMiscellaneous_Operation"
agenda-group "Third"
when
$r_MO : RuleMetaData(ruleName == "gpMiscellaneous_Operation" )
$lfna_MO : GLFNA(ptnaFundTotalNetAsset != 0)
DistinctAT( $dAT: d_auditT )
$total : BigDecimal()
from accumulate( ActualSum( auditT == $dAT, $actSum_Main : sumOfThree ),
sum( $actSum_Main ) )
eval(
chkRuleExpre( $total,$lfna_MO,$r_MO )
)
then
BaseExceptionBuilder builder =
BaseExceptionBuilder.createBaseExceptionBuilder($r_MO);
BaseException e = builder.createException();
exceptions.add(e);
System.out.println("Done Main Rule");
end
function boolean chkRuleExpre(BigDecimal ttl, GLFNA l, RuleMetaData r)
{
double val = Math.abs( 100 * ttl.doubleValue() /
l.getPtnaFundTotalNetAsset().doubleValue() );
if (val > (Double) r.getRuleArg("Miscellaneous_Operation_Low"))
{return true;}
else{return false;}
}
function BigDecimal resltForMovTyp(String str)
{
if (str.equals("E") || str.equals("R"))
{ return BigDecimal.valueOf(-1.0); }
else
{ return BigDecimal.valueOf(1.0); }
}
function BigDecimal resltForMovTrdSts(String str)
{
if (str.equals("XX"))
{ return BigDecimal.valueOf(-1.0); }
else
{ return BigDecimal.valueOf(1.0); }
}
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Unable-to-Access-Fact...
Sent from the Drools - User mailing list archive at
Nabble.com.