@Michael,
take any RuleTable with just the header lines, and you'll get a
spurious rule without conditions and an empty consequence.
Just from looking at the code (so please take this cum grano salis), I see that
DefaultRuleSheetListener calls createNewRuleForRow in initRuleTable,
which is a little early. (Ideally, the rule shouldn't be created until
you see a cell in a new line.) Without major code shunting, adding a
flag to org.drools.template.model.Rule might provide a workaround.
@Steve
I don't think that there is a simple and safe way to fix this problem
without patching the code. Here are three possibilities - you'll have
to judge whether you can bank on the precondition being met.
First: Call fire all rules up front, once, before any facts are
inserted. This will fire the blinds, so to say, and they won't do so
again, for the entire session.
Second: In the code handling AfterActivationFiredEvent, look at the
Activation. If it doesn't have any getDeclarationIDs and no
getObjects/getFactHandles it ought to be the spurious empty rule.
Third: If you are willing to use the instable API, you can inspect all
rules up front, from the knowledge base, and determine the ones that
don't have any CEs (and an empty consequence). This requires a little
advanced coding, but you can get help for this ;-)
Cheers
Wolfgang
On 31/10/2013, Michael Anstis <michael.anstis(a)gmail.com> wrote:
Providing a XLS exhibiting he problem would be beneficial. A unit
test in
drools-decisiontables even more so.
>From what I gather you're saying if the XLS contains no definitions, I.e.
only keywords, Drools is generating a single empty rule.
Sent on the move
On 30 Oct 2013 22:14, "srtatz" <srtatz(a)live.com> wrote:
> I have an xls file with the appropriate header lines to make the xls a
> Drools
> Decision Table that I provide to my users. I validate the content/data
> they
> enter, but do allow it to be "blank", that is, no user data, just the
> Drools
> Decision Table key words, conditions, actions, etc.
>
> When using the stateful knowledge session built using the Drools Decision
> Table, I insert an object implementing AgendaEventListener and override
> the
> afterActivationEvent method to record on the object which row was hit. I
> found that it is saying it hit the first row in the Drools Decision Table
> after the header information. But that corresponds to a blank line,
> since
> the table is blank. It seems to have generated a blank drl rule behind
> the
> scenes with no conditions (so it always succeeds) and no actions. Since
> I
> have logic based on whether or not a rule was successfully selected, this
> selection of a non-existent rule breaks my code.
>
> The user won't really be using a blank spreadsheet, but I need to cover
> the
> situation. The validation is pretty set in stone right now so I don't
> want
> to force the user to have some data.
>
> Can anyone suggest an easy way to stop it from matching the blank line?
>
> Thanks,
>
> Steve
>
>
>
> --
> View this message in context:
>
http://drools.46999.n3.nabble.com/Drools-Decision-Table-with-no-rules-mat...
> Sent from the Drools: User forum mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>