[rules-users] how to return additional information from method in 'eval'

Aeternitas gotischerose at yahoo.de
Tue Jun 26 11:13:50 EDT 2007


Hello.

I have the following problem:
Let's imagine we have type like this - 
public class Interval{
  private long start;
  private long end;
  private int usage;
 ...
}

Now I need to insert in DB new Interval, but before doing it I have to
check, whether DB doesn't have any interval, which intersects new one and
satisfies some rules (e.g. rules for summ of usage...). I use eval for it -
I have method, which can check it using DB services etc. But... eval can
return only boolean... I want to know also why I can't insert this interval
(e.g. which intervals prevent to do it). For me it will be comfortable to do
something like this:

when
...
  # $intervals - collection of intervals, which intersects new interval
   $intervals : eval(newInterval)
  #<check whether size of intervals is great than 0>
then
  # We can insert such interval and using global variable we inform about
it. 'error' it is collection of 
  # mistakes
  error.add("new interval can't be inserted because of " + <some information
from $intervals> );

But it will not work (or maybe new engine, version 4, will allow such 'eval'
using ?). Could you advice anything?

(Method, which I use in eval have no access to the working memory, so I
can't use global variables. Also I don't want to fire such method again in
"then" section to know "why I can't insert new interval")...

I hope I have described my problem clearly. Thanks in advance
Maxym
-- 
View this message in context: http://www.nabble.com/how-to-return-additional-information-from-method-in-%27eval%27-tf3982935.html#a11307462
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list