I would have thought using some rule like this would solve your
problems?
Rule "identify non-overlapping intervals"
When
$i: Interval()
not exists Interval( ( this.intersects($i) ) )
Then
//Add $i to database
End
Rule "identify overlapping intervals"
When
$i: Interval()
$ii: Interval( ( this.intersects($i) ) )
Then
//$i intersects $ii
End
"This" is only available in v4, but I'm confident these rules can be
written in v3 syntax too.
Perhaps I have misunderstood your requirement.
With kind regards,
Mike
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Aeternitas
Sent: 26 June 2007 16:14
To: rules-users(a)lists.jboss.org
Subject: [rules-users] how to return additional information from method
in'eval'
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-i
n-%27eval%27-tf3982935.html#a11307462
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