How many match rules do you have? You could always set a single “invalid” rule with a low salience (at least lower than your match rules) that is always true and sets the flag that it is invalid. Then put all the rules into the same activation-group so that only one can fire. If the invalid flag is set, that means that the ‘no match’ rule was the only one that could have fired. If it matches, the activation-group will prevent the ‘no match’ rule from firing….
------------------------------
Message: 3
Date: Tue, 18 May 2010 02:56:21 -0700 (PDT)
From: djb <dbrownell83@hotmail.com>
Subject: [rules-users] Using Drools as a glorified Hashmap
To: rules-users@lists.jboss.org
Message-ID: <1274176581461-825851.post@n3.nabble.com>
Content-Type: text/plain; charset=us-ascii
Hi Drools users,
I've got a situation where I've got a list of Drug codes which can only be
used for certain prescription codes.
The traditional method for implementing this is to simply pre-load the
values in a static Hashmap. Then if get() returns null, it is not a valid
combination. O(1), blazingly fast.
The issue with using Drools for this, is that Drools can match a code to a
code, and mark it as valid, but cannot call it invalid, as another rule may
still be relevant. Therefore, using Drools for this would require marking
combinations as valid, and afterwards, doing a linear traversal of the
prescriptions to see if there are any combinations that are not valid.
Is this the case? I would like to try implement it in Drools just for the
sake of consistency, but it seems a bit of a hack.
Thanks,
Daniel
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Using-Drools-as-a-glorified-Hashmap-tp825851p825851.html
Sent from the Drools - User mailing list archive at Nabble.com.