calling a function from the facts model
by Nadav Hashimshony
Hi.
After importing the fact model to guvnor i open try to create a new rule.
in the left side i see the fact model, i click the "+" and get all the
members of the fact class (all my members are public).
my question is, why cant i see the methods of the facts class?
i want to use a method that receives a parameter and returns an answer, then
check that answer in the rule and do something accordingly.
example:
currently my rule look like
rule "Rule-04"
salience 100
activation-group "mygrp"
no-loop true
when
d : myFacts( isOne == "false", isTwo == "true", hasThree == "true")
then
System.out.println("Rule 04 activated");
d.someMethodDone();
i want it to be something like:
when
d : myFacts( isOne == "false", isTwo == "true", hasNumber("three")
== "true")
then
System.out.println("Rule 04 activated");
d.someMethodDone();
i want hasNumber to be a function i give a parameter too and check it return
how can this be done?
Thanks.
Nadav.
14 years, 2 months
Re: [rules-users] fireUntilHalt and timing of rule activations
by Greg Barton
Nope, you're not missing anything. What you need is a control object of some sort thst's inserted after all of the "real" data is inserted. (See attached project for an example.) Rules will look like this, if the control object is called BatchLatch and data objects A:
rule "CountAs"
dialect "java"
salience -1
when
l : Latch()
a : A( latch == l )
then
retract(a);
l.incACount();
System.out.println("Found an A in " + bl);
end
Note that the A object being processed is tied back to the latch. This is so multiple latches can be processed simultaneously and their processing won't be intermingled. This is necessary because there's no guarantee that two Latch objects aren't in working memory at once. (Though you could create a rule that enforces this.)
GreG
--- On Sat, 10/2/10, Norman C <rent_my_time(a)yahoo.com> wrote:
> From: Norman C <rent_my_time(a)yahoo.com>
> Subject: [rules-users] fireUntilHalt and timing of rule activations
> To: rules-users(a)lists.jboss.org
> Date: Saturday, October 2, 2010, 10:22 AM
> Hi All,
>
> In my app, I have a separate thread calling fireUntilHalt()
> continuously. I
> have quite a few rules, and I am using salience extensively
> to control the order
>
> in which rules are executed. What I have seen (by adding
> an event listener) is
> that as a new fact is inserted, various rules are
> activated. Often, the
> fireUntilHalt will start executing fireNextItem in
> DefaultAgenda before all of
> the activations are complete. So if the rule with the
> highest salience
> value hasn't been activated at this point, then the first
> rule to be fired isn't
>
> the correct one.
>
> This can be worked around by waiting for insert to return
> and then calling
> fireAllRules(). But it seems like the session should
> block fireUntilHalt from
> trying to execute activated rules until all activations are
> complete. Or am I
> missing something here?
>
> thanks,
> Norman
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
14 years, 2 months
Download CREDIT DEBIT example-
by Aman
Currently I am reading this drools expert documentation, I came across this
example-
Where can I download this example?
rule "increase balance for credits"
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
CashFlow( type == CREDIT,
accountNo == $accountNo,
date >= ap.start && <= ap.end,
$amount : amount )
then
acc.balance += $amount;
end
rule "decrease balance for debits"
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
CashFlow( type == DEBIT,
accountNo == $accountNo,
date >= ap.start && <= ap.end,
$amount : amount )
then
acc.balance -= $amount;
end
14 years, 2 months
fireUntilHalt and timing of rule activations
by Norman C
Hi All,
In my app, I have a separate thread calling fireUntilHalt() continuously. I
have quite a few rules, and I am using salience extensively to control the order
in which rules are executed. What I have seen (by adding an event listener) is
that as a new fact is inserted, various rules are activated. Often, the
fireUntilHalt will start executing fireNextItem in DefaultAgenda before all of
the activations are complete. So if the rule with the highest salience
value hasn't been activated at this point, then the first rule to be fired isn't
the correct one.
This can be worked around by waiting for insert to return and then calling
fireAllRules(). But it seems like the session should block fireUntilHalt from
trying to execute activated rules until all activations are complete. Or am I
missing something here?
thanks,
Norman
14 years, 2 months
Re: [rules-users] java.io.StreamCorruptedException: invalid stream header:
by Arne
I get a very similar exception when try to execute the rules from my
application. Have you ever solved the problem? Any help with this?
Caused by: java.io.StreamCorruptedException: invalid stream header: 3C3F786D
at
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
at
org.drools.common.DroolsObjectInputStream.<init>(DroolsObjectInputStream.java:55)
at
org.drools.common.DroolsObjectInputStream.<init>(DroolsObjectInputStream.java:49)
at
org.drools.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:189)
at
org.drools.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:158)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:408)
... 75 more
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/java-io-StreamCorrupt...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months