Temporal reasoning with external persistence not working
by Aman Teja
I am trying to use an external storage for loading and persisting objects.
But when I try a set a temporal reasoning rule it start to fail. The rule,
test code and exception are given below. Please help
// rules file
package foo.externalwm;
global foo.ExternalStorage session;
import foo.externalwm.YUser
import foo.externalwm.Test
declare User
@role(event)
end
declare Contest
@role(event)
end
rule "test"
dialect "java"
when
$c1:Contest() from session.getContestByName("Contest1")
User(this after[0,3m] $c1) from session.getUserByIndex(0)
then
System.out.println("rule fired");
end
// ************ code
public class Test {
public static void main(String[] args) throws Exception {
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption( EventProcessingOption.STREAM );
KnowledgeBase k = init(); // read and compile rules done here
final StatefulKnowledgeSession ksession =
k.newStatefulKnowledgeSession();
ExternalStorage session = new ExternalStorage();
ksession.setGlobal("session", session);
ksession.fireAllRules();
}
***********EXCEPTION
Exception in thread "main" org.drools.RuntimeDroolsException: Unexpected
exception executing action
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction@669a4cb
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:996)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:730)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at foo.externalwm.Test.main(Test.java:55)
Caused by: java.lang.ClassCastException: org.drools.common.DefaultFactHandle
cannot be cast to org.drools.common.EventFactHandle
at
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:332)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:111)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:127)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:137)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:137)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:141)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143)
at org.drools.reteoo.Rete.assertObject(Rete.java:107)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:260)
at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:343)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:994)
... 4 more
--
View this message in context: http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persis...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 6 months
accumulate Functions with self coded classes as result type
by Andre
i implemented an accumulate function which uses Datatypes, which i coded my
self , see example
the function return a list of ResourceMatch Objects, but when i try access
that objects i get an NullPointerrException (nothing more) (yes i imported
that class in the DRL)
so it seems that there has to be some kind of registration, so drools, can
handle these objectsm right ?
or what did i forget?
rule "Request counting analysed Resources By Id"
when
$list: List()
from accumulate($neu : RequestCtx() over
window:time(1m),countMatchingAnalysedResourcesInRequest($neu) )
ResourceMatch( $id: uri.toString(), count > 1 ) from $list
then
System.out.println( "Id " + $id + ": " );
System.out.println("Request counting Resources By Id Rule Workss");
channels["AuthZBlocking"].send(new ItemCacheEntry(new Item((String)$id),
new Date(System.currentTimeMillis()+ 8000)));
end
--
View this message in context: http://drools.46999.n3.nabble.com/accumulate-Functions-with-self-coded-cl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 6 months
Any suggestions to implement exclusions and avoid update
by Wishing Carebear
Hi,
Below are 2 rules, rule1 has higher precedence than rule2. Rule2 should not
execute if Rule 1 executes.
1) One way to get this working is to check the null value.
2) If the update is not called, the Rule2 gets executed using the previous
null value of potentialTheftRating.
Is there any other way to implement this requirement.
rule "Rule 1 PotentialTheft0"
ruleflow-group "TheftRating0"
salience 10
no-loop
lock-on-active
when
$client : Client()
$policy : Service(productType == "Vehicle Insurance") from
$client.service
$car : Vehicle(potentialTheftRating == null, vehicleType ==
vehicleTypeType.CAR, convertible == Boolean.TRUE) from $policy.vehicle
then
modify ($car) {
setPotentialTheftRating( potentialTheftRatingType.HIGH )
}
update($client);
end
rule "Rule2 PotentialTheft0"
ruleflow-group "TheftRating0"
no-loop
lock-on-active
when
$client : Client()
$policy : Service(productType == "Vehicle Insurance") from
$client.service
$car : Vehicle(potentialTheftRating == null,vehicleType ==
vehicleTypeType.CAR, price >= 20000, price <= 45000, highTheftProbabilty ==
Boolean.FALSE ) from $policy.vehicle
then
modify ($car) {
setPotentialTheftRating( potentialTheftRatingType.MODERATE )
}
update($client);
end
14 years, 6 months
Writting a fusion query with specific time intervals
by Amila Suriarachchi
As I understood Drools fusion supports sliding windows which can either time
based on message length based. But can I write a query with specific time
intervals?
For an example Lets say my CEP engine recive events which has order value.
Now I want to fire an event if the orders within 8.00 am to 9.00 am have
less than $40000. In generally firing an event if there are less that $40000
total order value within any working hour (i.e 8.00 am 5.00 pm)
is it possible to do this?
--
View this message in context: http://drools.46999.n3.nabble.com/Writting-a-fusion-query-with-specific-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 6 months
Starting Guvnor in Eclipse
by Justin Case
Hi all,
any Eclipse users around here?
I have followed the instructions here:
https://github.com/droolsjbpm/droolsjbpm-build-bootstrap/blob/master/READ...
for Eclipse Helios+EGit+m2eclipse.
I downloaded 5.2.0.Final from https://github.com/droolsjbpm/guvnor.git, imported
all Maven projects it could find in the directory (except guvnor-docs which
misses something and I didn't care).
The Guvnor application will start in development mode, but:
- Firefox is causing often 100% CPU with it (might be the development mode)
- Eclipse Development Mode view shows LOTS of errors like this:
[ERROR] [org.drools.guvnor.Guvnor] - Errors in
'file:/C:/PocDev/GitHome/git/guvnor/droolsjbpm-ide-common/src/test/java/org/drools/ide/common/client/modeldriven/SuggestionCompletionEngineTest.java'
[ERROR] [org.drools.guvnor.Guvnor] - Line 47: No source code is
available for type
org.drools.ide.common.server.rules.SuggestionCompletionLoader; did you forget to
inherit a required module?
[ERROR] [org.drools.guvnor.Guvnor] - Line 49: No source code is
available for type java.util.jar.JarInputStream; did you forget to inherit a
required module?
Again, one can work also like this but seeing hundreds of errors is not helping
at all when I try to tinker with something somewhere. Plus there's the 100% CPU
thing... where and what should I inherit more than Maven is configured already
to inherit?
Tinkering around:
- I set all other projects as dependencies
- I set to export all sources from all projects (but there it bitches also about
missing java.util sources, who cares about these?)...
- added all these sources to the run configuration
nothing changed, I still have the above errors from both system libraries AND
project dependencies.
Or do I experience the problem mentioned in this message?
http://markmail.org/message/h52xvo4j52msambe#query:+page:1+mid:lg4mlgiof4...
Thanks for any hints,
JC
14 years, 6 months