[rules-users] How do I write a rule to detect a missing value in a group of facts?

GPatel at tsys.com GPatel at tsys.com
Thu Feb 9 11:45:08 EST 2012


Beautiful!

How would a business user (non-programmer) write such a rule. The only way I can think of is create a dsl sentence for this specific condition


----- Original Message -----
From: Wolfgang Laun [wolfgang.laun at gmail.com]
Sent: 02/09/2012 05:02 PM CET
To: Rules Users List <rules-users at lists.jboss.org>
Subject: Re: [rules-users] How do I write a rule to detect a missing value in a group of facts?



Don't think procedurally, just write the *rule* for a missing post ;-)

rule "missing fence post"
when
    FencePost( $d: distanceFromStart )
    FencePost( distanceFromStart == $d + 2*FencePost.GAP )
    not FencePost( distanceFromStart == $d + FencePost.GAP )
then
    System.out.println( "Missing: " + ($d + FencePost.GAP) );
end

-W

On 9 February 2012 16:41, mikeg <mike at thegoldners.com> wrote:

> I need to write a rule to identify a missing element in a group of facts.
>
> For example, let us say I want to ensure that my fence has a fence post
> every 8 feet.  My fact declaration is as follows:
>
> declare FencePost
>  identifier : String
>  distanceFromStart: Long
> end
>
> If I add the following facts into my session:
>
> FencePost("a", 0)
> FencePost("x", 8)
> FencePost("e", 24)
>
> I want a rule that will notify the user that there is a missing fence post
> between "x" and "e".
>
> I've been looking into using "collect" into a TreeSet/TreeMap to get a
> collection sorted on the "distanceFromStart", but I cannot figure out how
> to
> compare adjacent elements in the collection.
>
> Any ideas?
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-do-I-write-a-rule-to-detect-a-missing-value-in-a-group-of-facts-tp3729818p3729818.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120209/ebee6540/attachment.html 
-------------- next part --------------
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


-----------------------------------------
The information contained in this communication (including any
attachments hereto) is confidential and is intended solely for the
personal and confidential use of the individual or entity to whom
it is addressed. If the reader of this message is not the intended
recipient or an agent responsible for delivering it to the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, dissemination, copying,
or unauthorized use of this information, or the taking of any
action in reliance on the contents of this information is strictly
prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original
message. Thank you 


More information about the rules-users mailing list