Hmmm, you should be receiving a duplicate variable declaration error...
would you please open a JIRA for us to double check what is happening and
fix the error message?
Meanwhile, try without repeating the constraints on the parent rule in
the child rule:
rule "Definitions TermContractions 1.1"
when
mpr : MPUFacade()
eval(!mpr.isImportant(Constants.FINDING_KEYWORD_Contractions_Frequency))
then
mpr.print("Rule Definitions TermContractions 1.1 Executed");
end
rule "TermContractions 2.8" extends "Definitions TermContractions
1.1"
when
eval(!mpr.isImportant(Constants.FINDING_KEYWORD_TEST))
then
mpr.print("Rule TermContractions 2.8 Executed");
end
Also, remember that unless you use some of the tricks I mentioned
before, both rules will fire.
[]s
Edson
2010/3/5 Moe Alkhafaji <moe.alkhafaji(a)medcpu.com>
Here are the rules that I created (sorry for breaking that in
multiple
emails), I hope this is all the information needed:
rule "Definitions TermContractions 1.1"
when
mpr : MPUFacade()
eval(!mpr.isImportant(Constants.FINDING_KEYWORD_Contractions_Frequency))
then
mpr.print("Rule Definitions TermContractions 1.1 Executed");
end
rule "TermContractions 2.8" extends "Definitions TermContractions
1.1" <=== Line 11
when
mpr : MPUFacade()
eval(!mpr.isImportant(Constants.FINDING_KEYWORD_Contractions_Frequency))
eval(!mpr.isImportant(Constants.FINDING_KEYWORD_TEST))
then
mpr.print("Rule TermContractions 2.8 Executed");
end
On Fri, Mar 5, 2010 at 12:33 PM, Moe Alkhafaji <moe.alkhafaji(a)medcpu.com>wrote:
> Specifically speaking, here is what I get on Eclipse when I do that:
>
>
> nds.when cannot be resolved to a
> type MPU/src/rules
> EEphratOBMain.drl line 11
> Syntax error on token ":", ;
> expected MPU/src/rules
> EEphratOBMain.drl line 11
> Syntax error on token ""Definitions TermContractions 1.1"", .
expected
> MPU/src/rules EEphratOBMain.drl line 11
> Syntax error on token "then", invalid
> AssignmentOperator MPU/src/rules
> EEphratOBMain.drl line 11
> Syntax error, insert ";" to complete
> Statement MPU/src/rules
> EEphratOBMain.drl line 11
> Syntax error, insert ";" to complete
> Statement MPU/src/rules
> EEphratOBMain.drl line 11
> Syntax error, insert ";" to complete
> Statement MPU/src/rules
> EEphratOBMain.drl line 11
>
> Line 11 is:
>
> * rule "TermContractions 2.8" extends "Definitions TermContractions
1.1"*
>
> and "Definitions TermContractions 1.1" is another rule defined in the same
> drl.
>
>
>
> On Fri, Mar 5, 2010 at 12:04 PM, Moe Alkhafaji
<moe.alkhafaji(a)medcpu.com>wrote:
>
>> Thanks Edson, I will try that. However, I have one follow up question. I
>> tried to use the "extends" command and it did not work (it gave me a
syntax
>> error). I am using the latest Drools 5.0 M1. Could it be because the Eclipse
>> Drools plugin does not support this feature yet and if I ignore this error
>> on Eclipse it would still work at runtime?
>>
>> Thanks!
>>
>> 2010/3/5 Edson Tirelli <ed.tirelli(a)gmail.com>
>>
>>
>>> Although I noticed the other day that this is not documented yet,
>>> Drools 5.0.x does support rule inheritance. In your case, it would be
>>> written as:
>>>
>>> rule r1
>>> when
>>> A()
>>> then
>>> // do something
>>> end
>>>
>>> rule r2 extends r1
>>> when
>>> B()
>>> then
>>> // do something else
>>> end
>>>
>>> When using inheritance, the subrule will inherit the whole LHS of
>>> the parent rule.
>>>
>>> Integration test here:
>>>
>>>
>>>
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler...
>>>
>>>
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler...
>>>
>>> In your case, you have an extra requirement that if a child rule
>>> fires, you don't want the parent rule to fire. My suggestion is either
doing
>>> this with a logical condition, or adding drools.halt() on the consequence of
>>> rules that should stop subsequent firings, or using activation-groups +
>>> salience. Example, in the above case, you could have:
>>>
>>> rule r1
>>> activation-group "example rules"
>>> salience 10
>>> when
>>> A()
>>> then
>>> // do something
>>> end
>>>
>>> rule r2 extends r1
>>> activation-group "example rules"
>>> salience 20
>>> when
>>> B()
>>> then
>>> // do something else
>>> end
>>>
>>> Since rule 2 has a higher salience, if it activates it will fire
>>> first, and due to the activation-group, it will cancel the activation of r1
>>> preventing it to fire.
>>>
>>> Hope it helps.
>>>
>>> Edson
>>>
>>> 2010/3/5 malkhafaji <moe.alkhafaji(a)medcpu.com>
>>>
>>>
>>>> Hello,
>>>>
>>>> I know, from searching this forum and posting before, that the concept
>>>> of
>>>> inheritance does not exist today in Drools. However, I have a need for
>>>> it.
>>>> Here is my specific situation:
>>>>
>>>> I have certain rules that have some generic conditions to be fired:
>>>>
>>>> Rule 1
>>>> If A Then X end
>>>>
>>>> Rule 2
>>>> If A, B Then Y end
>>>>
>>>> What I would like to do is, if Rule 2 is true, then I don't want Rule
1
>>>> to
>>>> execute. I have many and many of those rules, so combining all the
>>>> conditions in less number of rules violates our design having rules
>>>> being
>>>> mutually exclusive. That is why I wanted to include this behavior as a
>>>> natural inheritance behavior rather than forcing the flow with logic
>>>> inside
>>>> the rule itself (you will make rules aware of others this way).
>>>>
>>>> So, since there is not built-in feature that allows you to do that, do
>>>> people suggest anything that I can do without having to mix Rule 1 and
>>>> Rule
>>>> 2 into one rule with complex conditional statements? Any ideas?
>>>>
>>>> The only thing I can think of is taking this logic processing outside
>>>> of
>>>> drools, which is something that I am not too excited about.
>>>>
>>>> Thanks.
>>>>
>>>> --
>>>> View this message in context:
>>>>
http://n3.nabble.com/Inheritance-Like-Design-Question-tp430848p430848.html
>>>> Sent from the Drools - User mailing list archive at
Nabble.com.
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>
>>>
>>>
>>> --
>>> Edson Tirelli
>>> JBoss Drools Core Development
>>> JBoss by Red Hat @
www.jboss.com
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>>
>> --
>> Moe Alkhafaji
>> Chief Technology Officer, MedCPU
>> Phone: (630) 290-1113
>> Email: cto(a)medcpu.com
>>
>> This message contains information which may be confidential. Unless you
>> are the addressee, you may not use, copy or disclose to anyone the message
>> or any information contained in this message. If you have received this
>> email in error, please notify cto(a)medcpu.com and please delete the
>> message immediately. In order for the contents of this message to be binding
>> on behalf of MedCPU it must be confirmed in writing by an authorized
>> signatory of MedCPU. Our company accepts no liability for the content of
>> this email unless it is so confirmed. The views or opinions presented herein
>> do not necessarily represent those of the company.
>>
>
>
>
> --
> Moe Alkhafaji
> Chief Technology Officer, MedCPU
> Phone: (630) 290-1113
> Email: cto(a)medcpu.com
>
> This message contains information which may be confidential. Unless you
> are the addressee, you may not use, copy or disclose to anyone the message
> or any information contained in this message. If you have received this
> email in error, please notify cto(a)medcpu.com and please delete the
> message immediately. In order for the contents of this message to be binding
> on behalf of MedCPU it must be confirmed in writing by an authorized
> signatory of MedCPU. Our company accepts no liability for the content of
> this email unless it is so confirmed. The views or opinions presented herein
> do not necessarily represent those of the company.
>
--
Moe Alkhafaji
Chief Technology Officer, MedCPU
Phone: (630) 290-1113
Email: cto(a)medcpu.com
This message contains information which may be confidential. Unless you are
the addressee, you may not use, copy or disclose to anyone the message or
any information contained in this message. If you have received this email
in error, please notify cto(a)medcpu.com and please delete the message
immediately. In order for the contents of this message to be binding on
behalf of MedCPU it must be confirmed in writing by an authorized signatory
of MedCPU. Our company accepts no liability for the content of this email
unless it is so confirmed. The views or opinions presented herein do not
necessarily represent those of the company.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users