[rules-users] Retract in a function
Ronald R. DiFrango
ron.difrango at gmail.com
Wed Oct 3 09:28:41 EDT 2007
Michael,
Those detail lines are in working memory for sure. In fact the query it
self only works on working memory objects.
As far as I know you can not place the results of a queryResult in the LHS.
Ron
On 10/3/07, Anstis, Michael (M.) <manstis1 at ford.com> wrote:
>
> Can you not get a reference to a DetailLine in the LHS?
>
> If you have not inserted DetailLine objects into working memory how can
> you expect to retract them?
>
> If you have inserted DetailLine's into working memory what does query
> "Open RTV Lines" return, can it be joined into the LHS? (or split into two
> rules)?
>
> ------------------------------
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Ronald R. DiFrango
> *Sent:* 03 October 2007 14:01
> *To:* Rules Users List
> *Subject:* [rules-users] Retract in a function
>
> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071003/ee235b95/attachment.html
More information about the rules-users
mailing list