Hi
I have a rule using xml.
<!-- 1st Rules For Field objects-->
<rule name="Rule1">
<lhs>
<pattern identifier="outterMap" object-type="HashMap" />
<pattern identifier="innerMap" object-type="HashMap">
<from>
<expression>outterMap.get("fact")</expression>
</from>
</pattern>
<pattern identifier="field" object-type="Filterable">
<from>
<expression>innerMap.get("filterable")</expression>
</from>
</pattern>
<pattern identifier = "document" object-type="Document">
<from> <expression>
field.getDocument();")</expression>
</from>
</pattern>
<eval> document.getIsNormalTask()</eval>
</lhs>
<rhs>
field.setDefaultOptionality(Boolean.TRUE);
</rhs>
</rule>
Another Rule is
<!-- 2 nd Rule for Menu Items-->
<rule name="Rule2">
<lhs>
<pattern identifier="outterMap" object-type="HashMap" />
<pattern identifier="innerMap" object-type="HashMap">
<from>
<expression>outterMap.get("fact")</expression>
</from>
</pattern>
<pattern identifier="editMode" object-type="Boolean">
<from>
<expression>innerMap.get("editMode")</expression>
</from>
</pattern>
<pattern identifier="menuItem" object-type="Filterable">
<from>
<expression>innerMap.get("filterable")</expression>
</from>
</pattern>
<pattern identifier = "document" object-type="Document">
<from> <expression>
menuItem.getDocument();")</expression>
</from>
</pattern>
<eval>editMode==true && !document.isInDraftStatus()</eval>
</lhs>
<rhs>
menuItem.setDefaultVisibility((Boolean)true);
</rhs>
</rule>
The total classes that I have are:
Filterable.java
Field.java inherits Filterable (contains Document object)
MenuItem.java inherits Filterable (contains Document object)
Document.java
I am setting up the filter based on rule name such that
for MenuItems rule executed is : Rule2
For Field objects rule executed is :Rule1
The problem is that all the rules are executed for all the objects passed as
facts and statements above <lhs> are matched. As these are diffrent, runtime
error is displayed that error in Rule1, getOptionality for field producing
error.
Basically I want to know should lhs be the same for all the rules in the
Rule Base? And why are all the patterns matched for a given fact in working
memory?
Thanks
--
View this message in context:
http://www.nabble.com/Should-lhs-pattern-be-the-same-for-diffrent-Rules-i...
Sent from the drools - user mailing list archive at
Nabble.com.