Thank you very much for the precision, I didn't see that. I used
'matches' instead of '==', because using '==' for comparing
Strings in
java is very unsafe since it compares the references and not the
content of the strings. I thought it was the same in drools and I
thought 'matches' was the equivalent of the java '.equals' method.
But now you mention that in drools '==' is correct, I will use it rather.
Aldian
2009/7/16, Edson Tirelli <tirelli(a)post.com>:
Very good! :)
Just FYI, in the case of accumulate, you could also use the collectList()
function to simplify your rule. This:
$alarmList : LinkedList()
from accumulate ( ($e : Element(parentindex!=0) and
$a : Alarm( origin matches
$e.name&& probablecause==45)),
init( LinkedList alarmList = new
LinkedList();),
action( alarmList.add($a);),
reverse( alarmList.remove($a);),
result( alarmList ) );
Is the same as:
$alarmList : List()
from accumulate ( ($e : Element(parentindex!=0) and
$a : Alarm( origin matches
$e.name&& probablecause==45)),
collectList( $a ) );
Also, you can always implement your own functions for accumulate:
http://blog.athico.com/2009/06/how-to-implement-accumulate-functions.html
Finally, I see you are using "matches" operator to compare equal strings.
Not sure if that is what you want, because "==" has different semantics and
better performance than "matches" if what you really want is compare
equality. Remember that in regexps, some characters have special meaning,
for instance, "." is a wildcard for any character. Meaning:
"abc" matches "a.c" -> true
"abc" == "a.c" -> false
Cheers,
Edson
2009/7/16 Gab Aldian <aldian.gp(a)gmail.com>
> After some more investigation, I managed also to make it work with
> collect:
http://drools.pastebin.com/m14f0e329
>
> I would rather not multiplicate rules, because we probably will have
> dozens for our system which is very big and can supervise around a
> thousand equipements in some cases
>
> Thank you very much for the advices
>
> Aldian
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
http://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com