2012/2/9 <GPatel@tsys.com>

Beautiful!

How would a business user (non-programmer) write such a rule.

There's some evidence that it's difficult to "un-think" your procedural programming imprinting. A non-programmer might even have the edge over a programmer.

But rule programming isn't a silver bullet - lots of stuff to learn.

The only way I can think of is create a dsl sentence for this specific condition 

Even so.
-W
 


  From: Wolfgang Laun [wolfgang.laun@gmail.com]
  Sent: 02/09/2012 05:02 PM CET
  To: Rules Users List <rules-users@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@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@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
_______________________________________________
rules-users mailing list
rules-users@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
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users