All,
I have the following function that I call from all of my rules. When I execute this function, I need to retract that object from working memory. The problem is that when I insert the comment line below I get a compiler error saying that I can only issue a retract on fact handles.
Here is an example of my rule plus the function:
rule "QTY Percentage tolerance - Approval"
salience -25
no-loop true
when
rtvHeader : RtvHeader( totalAmount : totalAmount, status not in (
StatusConstants.MATCHED, StatusConstants.APPROVAL) )
repaymentCode : RepaymentCode( code == "QTY", matchApprv == "Y", tolDollar ==0, tolPercent != 0, tolPercent : tolPercent )
qtyOutput : QTYOutput( sumRTVQty : sumRTVQty , sumCmAndRnr : sumCmAndRnr )
eval( qtyPercentage(qtyOutput, totalAmount, tolPercent) )
then
System.out.println("QTY Percentage tolerance - No Approval");
rtvHeader.setStatus(StatusConstants.APPROVAL
);
openRTVLines(drools.getWorkingMemory(), drools.getWorkingMemory().getQueryResults( "Open RTV Lines" ), StatusConstants.MATCHED_WITHIN_TOLERANCE);
end
function void openRTVLines(WorkingMemory workingMemory, QueryResults results, String status)
{
System.out.println( "We have " + results.size() + " Open RTV Lines" );
for ( Iterator it = results.iterator(); it.hasNext(); ) {
QueryResult result = ( QueryResult ) it.next
();
DetailLine line = ( DetailLine ) result.get( "line" );
line.setStatus(status);
// I need to add this in
// workingMemory.retract(line);
}
}
Thanks in advance,
Ron