Problem with Guvnor 5.1.1, <save> frequently does not save...
by David Shields
I have spent several days writing rules and tests for them in Guvnor, and
kept having strange results. A test would sometimes fail, repeatedly, and
then finally start working after I would delete and recreate some portion
of it, or change a value.
After two of us spent many hours trying to identify the extent of the
problem, we concluded the following:
1. The problem happens under both IE and Firefox.
2. The problem happens less frequently under Firefox if we install and
turn on a third-party plug-in which disables Firefox caching web pages.
3. Saving a new rule or test will allow us to work with it (edit - save -
test scenarios). However, frequently the rule or test will just disappear
once we log out.
4. A "Save" and "Check-in" will often work correctly if we cross our
fingers and do the following:
a. Save it once (the screen updates, and you can check the
version history)
b. Refresh the browser
c. Make the change again
d. Save it a second time
5. After doing a "Save" and "Check-in", you can immediately do a "view
source" and see your changes in place. However, if you then close the
test (or rule) and re-open it, you will often find that the change is
gone, and the test or rule looks like it did before you made the change.
A sample screenshot appears below. In this case, I created the test with
the "performedTime" set to 20-Sep-2008. I ran the test and it failed,
because the rule was checking for greater than or equal to 21-Sep-2008. I
then changed the date on the test to 21-Sep-2008, did a "save changes" and
a "Check-in", and then ran the scenario again.
As you can see below, the asserted object contains the date 20-Sep-2008,
even though the test clearly shows 21-Sep-2008.
Does anybody have any ideas on this? If I copy the above test into a new
test, it will often work the first time, but then it may disappear, once I
logout, even though it was saved and checked-in.
It almost seems like there is something wrong with the imbedded
repository, and / or the first running of the test created fact objects
that are persisting and being found the second time I ran the changed
test. ...
We are running the Final release of Drools Guvnor 5.1.1 found in
drools-5.1.1-guvnor.zip downloaded on 4-Sep-2010
We are running under Tomcat 6.0, with the recommended jar files replaced.
Thanks for your help!
--------------------------------------------------
David Shields
Division of Clinical Informatics
Department of Community and Family Medicine
Duke University Medical Center
Phone (864) 787-8551
14 years, 11 months
How to write rules with optional parts?
by Edward Johnson
How do you do rules that are a sequence of events where some of them are optional?
Example:
Alert if DAVID enters a room after ALICE or after ALICE and BOB
If it were a string, this is roughly equivalant to the regex /ALICE( BOB)? DAVID/
So:
Alice then David => alert
Alice then Bob then David => alert
Alice then Charles then David => no alert
I could write this as two rules but as the rules get more complex it could by hard to manage the resulting combatorial explosion. Here it is as two rules:
Rule 1:
$p1:person (name=="Alice")
$p2:person (name=="David", this after[0,1] $p1)
Rule 2:
$p1:person (name=="Alice")
$p2:person (name=="Bob", this after[0,1] $p1)
$p3:person (name=="David", this after[0,1] $p2)
14 years, 11 months
JBPM processes in Guvnor
by DonC
Hi,
I'm pretty new to guvnor and jbpm. I have guvnor 5.2.0 final running, I'm
trying to extract the processes attached to a package using the
KnowledgeAgent api. I've successfully managed to create a process under the
mortgages package, however when I build a snapshot of the package the
processes do not show.
When I use eclipse to view the repository I can see my process in the
snapshot. When I'm in java using the knowledgeAgent, I can not get the
process out. How am I able to extract the process and execute it?
String url =
"http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/mort...";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newUrlResource( url ), ResourceType.PKG );
assert(kbuilder.hasErrors());
Collection<KnowledgePackage> packageList = kbuilder.getKnowledgePackages();
for (KnowledgePackage kp : packageList) {
System.out.println("package name = " + kp.getName());
Collection<Process> processList = kp.getProcesses();
for (Process p : processList) {
System.out.println(p.getName());
}
}
the size of processList is always 0?
Any help will be appreciated.
Thanks
Don
--
View this message in context: http://drools.46999.n3.nabble.com/JBPM-processes-in-Guvnor-tp3191390p3191...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
Fusion confusion
by Chris Richmond
I have attached my program project with my main FusionMain.java and two
small classes and my rule file Sample.drl.
It's a zip file i have modified to be .piz for mail server reasons.
In the Main I set up and run as STREAM mode session and execute on a
background thread .fireUntilHalt().
Then I inject two objects(DataReading and ConfigEvent)
The Sample.drl rule has the rules:
declare DataReading
@role( event )
end
declare ConfigEvent
@role( event )
end
rule "Detect high data reading"
when
$dr: DataReading(reading > 10.0) from entry-point "My Stream"
then
System.err.println("Data reading > 10");
end
rule "Wait for follup config"
lock-on-active
when
$dr: DataReading(reading > 10.0) from entry-point "My Stream"
not($de: ConfigEvent(this after[0s,10s] $dr))
then
System.err.println("Action");
end
rule "Detect config event"
when
$ce: ConfigEvent() from entry-point "My Stream"
then
System.err.println("Config Event");
end
What I expect is that I would see the DataReading rule fire right
away(it does)
then 5 seconds later when I insert the ConfigEvent I would see it's rule
fire(it does)
But the "Wait for follup config" rule fires no matter what.
To me, that rule should wait and make sure no ConfigEvent object was
inserted within 10 seconds after the DataReading object, but no matter
what that rule fires after 10 seconds. How can I make my inserted
ConfigEvent(inserted within the 10 seconds) satisfy that condition so it
cancels that rule from firing? I am using the latest download from the
site (5.2.0 final) binaries.
Does Fusion in fact work or am I doing something wrong? The zip file
has the entire runnable program and project(have to modify lib
references to point to correct Drools 5.2 binaries).
If the zip file does not come through I will attach the files
individually next.
Thanks,
Chris
14 years, 11 months
Re: [rules-users] How to reuse a result of a rule in an other rule
by mjohansen
Basically, you can either update an object with the results of the first
rule, or create a new object.
Like:
rule "Hungry"
when
$person : Person(hoursSinceLunch>2 || donutsOnDesk==0 ||
candybarsInDrawer==0)
then
$person.setHungry(true);
update($person);
end
rule "Food"
when
$person : Person(hungry==true)
then
$person.lookForFood()
end
or
rule "Hungry"
when
$person : Person(hoursSinceLunch>2 || donutsOnDesk==0 ||
candybarsInDrawer==0)
then
$hungry=new Hungry();
$hungry.setPerson($person);
insert($hungry);
end
rule "Food"
when
$person : Person()
$hungry : Hungry(person==$person)
then
$person.lookForFood()
end
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-reuse-a-result-of-a-rule-in-an-o...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
temporal operator "includes" not working
by Neelesh Deo Dani
Hi,
I've following event declarations and rule:
declare Event
@role(event)
@timestamp(datetime)
datetime : Date
name : String
end
declare Contest
@role(event)
@timestamp (startTimestamp)
startTimestamp : Date
endTimestamp : Date
end
rule "Contest"
no-loop
when
$e : Event(name == "event1")
$contest : Contest(this includes $e)
then
System.out.println("rule Contest fired");
end
The timestamps with Event and Contest objects are set as follows (before insert in state-full session):
// for Contest object
Calendar c = Calendar.getInstance();
c.set(2011, 7, 1);
contestType.set(contest, "startTimestamp", new Date(c.getTimeInMillis()));
c.set(2011, 7, 31);
contestType.set(contest, "endTimestamp", new Date(c.getTimeInMillis()));
// for Event object
c.set(2011, 7, 3);
eventType.set(event, "datetime", new Date(c.getTimeInMillis()));
The condition "this includes $e" in LHS doesn't get evaluated to true and RHS doesn't get executed.
If I change it to "$contest.startTimestamp before $e,
$contest.endTimestamp after $e" which has the same meaning then it
works fine.
Please help in resolving the issue.
Thanks & Regards,
Neelesh
14 years, 11 months
accumlator and BigDecimal
by mjohansen
I'm trying to create an accumulator to sum a BigDecimal. Here's what I wrote:
$upcharge : BigDecimal( )
from accumulate( GroupUpcharges( row>$gb.row && row<=$gu.row, $value :
upcharge),
init( BigDecimal total = BigDecimal.ZERO; ),
action( total=total.add($value); ),
reverse( total=total.subtract($value); ),
result( total ) )
$gb and $gu are set earlier in the WHEN clause.
When I run this, it compiles successfully, but then flows up at run time
with a null pointer exception. What am I doing wrong?
--
View this message in context: http://drools.46999.n3.nabble.com/accumlator-and-BigDecimal-tp3185872p318...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
match longest matching Long in WM
by esstrata
Hi,
I hope you can help me out here with a way to implement this rule:
1) I have String WM
2) I have beans in WM with a property called 'code'
public class MyBean {
private String code;
...
3) I want a rule of the type "Process MyBean with the longest-matching,
not-null code"
Let explain myself a little further with an example.
I have the following MyBean objects in WM with the given code properties:
MyBean [code = 44]
MyBean [code = 443]
MyBean [code = 4432]
MyBean [code = 36]
MyBean [code = 7]
What I want to get is a rule where the following samples would assign to a
variable the given results shown:
4411111 gives MyBean [code = 44]
4433333 gives MyBean [code = 443]
22222 gives null
I think the rule could start like:
rule "Process MyBean with the longest-matching, not-null code"
dialect "mvel"
when
$s : String()
$m : MyBean($s matches /the longest not-null possible MyBean.code/)
then
......
Thank you
--
View this message in context: http://drools.46999.n3.nabble.com/match-longest-matching-Long-in-WM-tp318...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
Using functions to derive values in "accumulate" (LHS)
by Christian Heupel
Hello,
I am trying to write a rule for my drools engine. It is (as far as i get it
right), almost a total standard rule, however I'm having troubles with it
and was hoping you could point me into the right direction (as i was
surprised to see no similar question, I hope it is not too basic).
To give you an understanding of what i want to do: I want to calculate a
number of costs a person had on a series of trips. For each trip, a function
getCost() calculates the total amount of money spent (such as hotel, bar,
...). If the total amount of money spent is higher then the person's maximum
money, we take action. I am trying to use the accumulate function, but it
seems as if I'm not able to call the getCost() function there. The rule
looks like this:
-----------------
rule "Total Costs"
when
$person : Person( eval ($person.maxMoney != null ) )
$totalCost : Number()
from accumulate( $trip : Trip( $cost : $trip.getCost() )
from $person.getTrips(),
sum( $cost )
)
then
// take action
end
-------------------
I have tried it with and without the $trip-variable (since I thought I might
have to use it to call its function).
The error I get looks like this:
Error INTERNAL_ERROR: Error: unknown:70:54 Unexpected token ')'
java.lang.Exception: Error: unknown:70:54 Unexpected token ')'
at
com.fluidops.coremgmt.ruleengine.PolicyTask.readRule(PolicyTask.java:489)
at
com.fluidops.coremgmt.ruleengine.PolicyTask.readRule(PolicyTask.java:419)
I would be very thankful if one of you could help me out here :)
Best regards,
Christian
PS: I already had this question in the drools forum, it was, however not
forwarded to this mailing list, so please forgive me if it is a double post.
14 years, 11 months