[rules-users] Logic in the when clause

Zevenbergen, Alex azevenbergen at paddypower.com
Fri Mar 20 06:54:16 EDT 2009


Thanks very much

________________________________

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: 20 March 2009 10:45
To: Rules Users List
Subject: Re: [rules-users] Logic in the when clause


Well, accesses to embedded objects are a little more complicated, but if
you want it:

rule HomeWinEt
    when
        $f : Fact( $d : details )
             eval( $d.CLOCK_STAGE > 10 &&
                   ($d.HOME_MATCH_SCORE - $d.HOME_FULL_TIME_SCORE >
                    $d.AWAY_MATCH_SCORE - $d.AWAY_FULL_TIME_SCORE))
    then
    # ...
end

Consider asserting the objects stored as the Facts.details as well. This
will let you write the much more declarative (and presumably more
efficient) rule with the "return value" restriction:

rule HomeWinEtxxx
    when
        $d : Detail( CLOCK_STAGE > 10,
                     HOME_MATCH_SCORE > (HOME_FULL_TIME_SCORE +
AWAY_MATCH_SCORE - AWAY_FULL_TIME_SCORE))
        $f : Fact( details == $d )
    then
       # ...
end

-W





2009/3/20 Zevenbergen, Alex <azevenbergen at paddypower.com>


	Thanks,
	 
	this is the rule:
	 
	rule "Home win et" 

	when

	$f : Fact(details.CLOCK_STAGE > 10,(details.HOME_MATCH_SCORE -
details.HOME_FULL_TIME_SCORE) > (details.AWAY_MATCH_SCORE -
details.AWAY_FULL_TIME_SCORE))

	then

	

	

	end

________________________________

	From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
	Sent: 20 March 2009 09:15
	To: Rules Users List
	Subject: Re: [rules-users] Logic in the when clause
	
	
	You could use eval( <expression> ) for this, but I guess it
could also be added as a return value field constraint to the last of
these four fields. Would you mind providing the full pattern?
	-W
	
	
	2009/3/20 Zevenbergen, Alex <azevenbergen at paddypower.com>
	

		Hi,
		 
		quick newbie question about the when clause in a rule.
eg can i get the fact to be tested from the result of two other inputted
facts?
		 
		details.HOME_MATCH_SCORE - details.HOME_FULL_TIME_SCORE
> details.AWAY_MATCH_SCORE - details.AWAY_FULL_TIME_SCORE

		I assumed this would work fine but it doesn't recognise
the '-' as a minus!

		Thanks in advance

		Alex

		 

	
________________________________________________________________________
		Privileged, confidential and/or copyright information
may be contained in this communication. This e-mail and any files
transmitted with it are confidential and intended solely for the use of
the individual or entity to whom they are addressed. If you are not the
intended addressee, you may not copy, forward, disclose or otherwise use
this e-mail or any part of it in any way whatsoever. To do so is
prohibited and may be unlawful. If you have received this email in error

		please notify the sender immediately.
		
		Paddy Power PLC may monitor the content of e-mail sent
and received for the purpose of ensuring compliance with its policies
and procedures.
		
		Paddy Power plc, Airton House, Airton Road, Tallaght,
Dublin 24 Registered in Ireland: 16956
	
________________________________________________________________________
		

		_______________________________________________
		rules-users mailing list
		rules-users at lists.jboss.org
		https://lists.jboss.org/mailman/listinfo/rules-users
		
		



	
________________________________________________________________________
	Privileged, confidential and/or copyright information may be
contained in this communication. This e-mail and any files transmitted
with it are confidential and intended solely for the use of the
individual or entity to whom they are addressed. If you are not the
intended addressee, you may not copy, forward, disclose or otherwise use
this e-mail or any part of it in any way whatsoever. To do so is
prohibited and may be unlawful. If you have received this email in error

	please notify the sender immediately.
	
	Paddy Power PLC may monitor the content of e-mail sent and
received for the purpose of ensuring compliance with its policies and
procedures.
	
	Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24
Registered in Ireland: 16956
	
________________________________________________________________________
	

	_______________________________________________
	rules-users mailing list
	rules-users at lists.jboss.org
	https://lists.jboss.org/mailman/listinfo/rules-users
	
	



________________________________________________________________________
Privileged, confidential and/or copyright information may be contained in this communication. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, you may not copy, forward, disclose or otherwise use this e-mail or any part of it in any way whatsoever. To do so is prohibited and may be unlawful. If you have received this email in error 
please notify the sender immediately.

Paddy Power PLC may monitor the content of e-mail sent and received for the purpose of ensuring compliance with its policies and procedures.

Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24  Registered in Ireland: 16956
________________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090320/eb3c8687/attachment.html 


More information about the rules-users mailing list