[rules-users] Cutom Attributes in Drools

Vincent LEGENDRE vincent.legendre at eurodecision.com
Thu Sep 13 13:47:54 EDT 2012


It is not a myth ... but indeed, it's hard. 
Most of times, you have to find one guy at client's side who is ready to learn at least the main principles of expert-systems. For my experience, it works well enough (ie most of rules dev time is done by the BA) in about 1 proj out of 3. For the others, an IT guy is still needed to help the BA (which is something doable if you have enough rules to author). 

DSL are hard to set, and harder to maintain, especially while using guvnor (using DSL in a dsrl rule is fine, but dsrl rules for non-IT guys is a myth). 
Usually I try as much as I can to set a business-compliant POJO model (ie simple, almost flat, with fields named in a way they understand what is behind) and no DSL at all... 
For the rules' firing control, it is harder ... 

@dme1 : May be you can think on an agenda filter that looks for the rule's package ? Or use "category rules", which is a rule binded to a category, which acts as a parent rule for all rules under this category (so all rules of the same category will have the same common first conditions, which can be the test of your control fact). But beware of that, there was a bug on sub-categories, or when a rule has more than one category (one the first category is taken if I remember well). A last thing could be to use verifier to ensure that all rules have a first condition that test the control fact . 

@GPatel : your approach sounds great. How much time did you spent to write such a Guvnor alternative ? 


----- Mail original -----

De: GPatel at tsys.com 
À: "Rules Users List" <rules-users at lists.jboss.org> 
Envoyé: Jeudi 13 Septembre 2012 18:47:52 
Objet: Re: [rules-users] Cutom Attributes in Drools 

" I would not store the result of the (missed) activation of a rule in a rule 
attribute, anyway. Can't you just use a dedicated fact(s) for that?" 

I face a similar issue where the target audience are "business" users i.e users that dont really understanding or wish to get into logic. I am finding myself having to resort to all sorts of tricks (using categories/packages/standlone rule editor) to allow business users to easily specify which rules are for what purposes and when they should fire. I just cant rely on them using facts correctly to disable rules that should not fire. In fact, I am now down to using only the standalone editor and saving the rule xml in my tables (not guvnor) so that i have full control over itemized rule display, rule search, knowledgebase creation for different execution profiles, etc. 

Overall, I increasingly tend to think rules for business users is a myth. The business users wants rule-driven systems, yet they dont want to learn drools. And drools DSL just doesnt cut it. 



From: Davide Sottara <dsotty at gmail.com> 
To: rules-users at lists.jboss.org, 
Date: 09/13/2012 01:57 AM 
Subject: Re: [rules-users] Cutom Attributes in Drools 
Sent by: rules-users-bounces at lists.jboss.org 




You can add any metadata using the format @name( "value" ) or @name( 
key=value ). You can then look them up using rule.getMetaData(). 
Please notice that there's a bug (solved by an open pull request) that does 
not let you write just @name. 

In order to use those attributes to control whether a rule fires or not, you 
can use the "declarative agenda", i.e. add meta-rules to your knowledge base 
such as: 

rule "Meta" 
@activationListener('direct') 
when 
// assuming the attribute is @region( [value] ) 
$a : Activation( rule.metaData[ "name" ] != "MyDesiredRegion", $objs : 
objects ) 
// any condition on the tuple here, if needed 
then 
drools.cancelActivation( $a ); 
end 

notice that you'll have to enable the corresponding option first: 
KnowledgeBaseConfiguration kconf = 
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); 
kconf.setOption( DeclarativeAgendaOption.ENABLED ); 
KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase( kconf ); 


If you want to have rules override each other, watch out for an upcoming 
feature, "Defeasible logic". 
I would not store the result of the (missed) activation of a rule in a rule 
attribute, anyway. Can't you 
just use a dedicated fact(s) for that? 

Best 
Davide 



-- 
View this message in context: http://drools.46999.n3.nabble.com/Cutom-Attributes-in-Drools-tp4019692p4019736.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 
_______________________________________________ 
rules-users mailing list 
rules-users at lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120913/786a001c/attachment-0001.html 


More information about the rules-users mailing list