Variable length sliding windows?
by Lauer, Will C
I'm evaluating the use of Drools Fusion for a new project and have a question about sliding windows that wasn't clear from the documentation. Does the time specification in a sliding window need to be hardcoded in the rule, or can it be derived from something else? Basically, I'm wondering whether I can write a rule that looks something like
when
...
Window ($win : length)
Number (intValue > $someValue) from accumulate (
Sample($len: length, value > $someThreashold) over window:time ($win),
sum($len) )
then
...
end
I know window:time() supports constant values like "10m", but can the window be driven from one of the other facts in the LHS picked up by the LHS of the rule?
Will Lauer
CA Technologies
Sr Software Architect
Tel: +1-713-625-9410
Cell: +1-979-820-2210
Will.Lauer(a)ca.com
12 years, 10 months
Getting java.lang.ClassCastException: - using Drools 5.3
by kashif10
HI.
I am getting following exception.
Exception in thread "main" org.drools.RuntimeDroolsException:
d1.rule.Rule_8f09c0aa350100000080cb1e0dd40f6fEval4Invoker@f6f66af4 :*
java.lang.ClassCastException: d1.rule.facts.Medication cannot be cast to
d1.rule.facts.Procedure*
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:119)
at
org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:178)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:197)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:72)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:161)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:458)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:386)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
at d1.rule.facts.PatientFacts.loadFactsInSession(PatientFacts.java:6075)
at d1.rule.DREvaluator.startEvaluation(DREvaluator.java:278)
at d1.rule.DREvaluator.main(DREvaluator.java:72)
Caused by: java.lang.ClassCastException: d1.rule.facts.Medication cannot be
cast to d1.rule.facts.Procedure
at
d1.rule.Rule_8f09c0aa350100000080cb1e0dd40f6fEval4Invoker.evaluate(Unknown
Source)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
Following is the rule. I found that due to "or" the Procedure block not
runs.
If I change "or" to "and" than procedure block executed & the error not
produced.
I am not sure what's the problem, I am using Drool 5.3
rule "8f09c0aa350100000080cb1e0dd40f6f"
when #conditions
(
$cepFacts: CEPFacts(id=="D1")
and
eval($cepFacts.initialize())
and
(
(
$DxDate_1 : ( Medication( name equalsIgnoreCase "Ofloxacin" ) )
and
eval($cepFacts.checkRelativeValues($DxDate_1) )
)
or
(
$DxDate_2 : ( Procedure( name equalsIgnoreCase "Pres antibiotic" )
)
and
eval($cepFacts.checkRelativeValues($DxDate_2) )
)
)
and
(
$DxDate_3 : ( Medication( name equalsIgnoreCase "Trazodone" ) )
and
eval($cepFacts.checkTimeIs($DxDate_3)
)
)
then
resultIds.add("8f09c0aa350100000080cb1e0dd40f6f");
end
--
View this message in context: http://drools.46999.n3.nabble.com/Getting-java-lang-ClassCastException-us...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
api's, factories and services
by Mark Proctor
Just a reminder when doing api's
Stage interfaces in internal-api and make sure you do factories for
them, almost never expose "new" constructors to users. We provide both
static factories and a service registry, and we ideally should continue
to support both. i.e. we have
KnowledgeBuilderFactory (static method factory, actually wraps below)
KnowledgeBuilderFactoryService (singleton service)
static example:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder()
singleton service exmaple:
KnowledgeBuilderFactoryService kbuilderfs =
ServiceRegistry.getInstance().get( KnowledgeBuilderFactoryService.class )
KnowledgeBuilder kbuilder = kbuilderfs .newKnowledgeBuilder()
All of our factory services should be registered in
org.drools.util.ServiceRegistryImpl, this has delegation to say OSGi if
it exists (via the service locator pattern). So we become much more
friendly to OSGi or other container environments that are service
locator oriented.
"new" should almost never be used, apart from when construcing say
default or debug listener implementations.
Mark
12 years, 10 months
Guvnor Problem
by arup
Hi all,
I have deployed guvnor 5.1 in WAS 6.1. i get no errors while deploying. the
guvnor link is working fine. but after uploading any pojo model when i'm
trying to validate it, its saying that it cannot find the Class inside the
package. but if i download the model from the guvnor, i'm getting the full
class structure inside the jar. also getting problem while creating the rule
as no facts are coming. do u know why this is happening????
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Problem-tp3790091p3790091.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Drool Function error
by shawn
I write a function in drool, but it always has error.
The error is :The method insertLogical(PreCondition) is undefined for the
type InsertPreCondition
Is it because insertLogical must be used in RHS?
Is there any way to use insertLogical in function or implement the function
in RHS?
code:
import PreCondition;
import Authorization;
function void insertPreCondition(Authorization a) {
// a.getPreCondition() returns an arraylist
for( PreCondition pc : a.getPreCondition() ){
insertLogical( pc );
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drool-Function-error-tp3788965p3788965....
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Trivial bug in Planner 5.4.Beta1 : misleading error message when the wrong entity was annotated with @PlanningEntityCollectionProperty
by aitchnyu
I accidently denoted the wrong class with the annotator
@PlanningEntityCollectionProperty ; a class which was NOT a planning entity.
Apparently, Drools Planner does not attempt to check for such a possibility,
hence I get:
*--OUTPUT--*
Exception in thread "main" java.lang.NullPointerException
at
org.drools.planner.core.domain.solution.SolutionDescriptor.getAllFacts(SolutionDescriptor.java:135)
at
org.drools.planner.core.solution.director.DefaultSolutionDirector.getWorkingFacts(DefaultSolutionDirector.java:129)
at
org.drools.planner.core.solution.director.DefaultSolutionDirector.resetWorkingMemory(DefaultSolutionDirector.java:123)
at
org.drools.planner.core.solution.director.DefaultSolutionDirector.setWorkingSolution(DefaultSolutionDirector.java:97)
at
org.drools.planner.core.solver.DefaultSolver.setPlanningProblem(DefaultSolver.java:97)
at in.co.technovia.examduties.ExamDutiesApp.main(ExamDutiesApp.java:47)
*--OUTPUT--*
Please check for such a possibility in future versions of Drools Planner and
emit a more meaningful error message.
--
View this message in context: http://drools.46999.n3.nabble.com/Trivial-bug-in-Planner-5-4-Beta1-mislea...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Rule nodes in a ruleflow sharing some rules
by Francois Gadrat
Hello drools users,
I have a modeling issue with ruleflows : I would like to know how to having
rule nodes sharing some rules.
Problem:
Lets says i have 3 rule nodes A, B and C in a ruleflow after a split node:
Node A has rules R1, R3 and R5
Node B has rules R2,R3 and R4
Node C has rules R1, R2, R6
so the issue is that there are rules that are common to different rule nodes
and this seems to be a problem with uniqueness of ruleflow-group attribute
and value in both rule and rule node.
Is there a way to achieve this without splitting nodes A,B and C into
smaller nodes?
Would it be possible to achieve this with getting the ruleflow-group rule
attribute as a result of a function call or an evaluation at runtime, in
order to operate a dynamic rule selection?
Something like this in a rule
ruleflow-group (getRuleflowGroup(kcontext))
where from kcontext,
one would get the name of the rule => kcontext.getRule().getName()
one would get the name of current Node from kcontext ?
Thanks for sharing your thoughts and for your time. Francois.
12 years, 10 months