Rules Flow Eclipse editor
by Prafull Kumar
Hi All,
I would like to know how we can modify the Rules flow eclipse editor look and
feel and functionality. e.g. If we have a Embedded Sub-Process in the flow and
reduce the size of it, the arrows are still displayed in the main canvas.
How we can fix it? also if we want to open the Embedded Sub-Process in a new
window for easy maintainability/readability of the very complex processes, how
we can achieve it?
Please see the attached snapshot for reference.
Going forward we are also looking to create the custom editor for the nodes.
Please guide us if its possible and there is any document for this.
Regards, Prafull
15 years, 4 months
Removing facts from statefulknowledgeSession's memory
by Ayush
Hi,
In my drools implementation I'm inserting all my facts into working memory
and for every fact received I'm also inserting events into notification
stream.
Now the StatefulKnowledgeSession I'm using is static and it is neither
initialized nor disposed after being initialized for first time. My
application will run for months without restarting and so the same session
will be used without being reinitialized or disposed.
Do I have to retract events explicitly or will it handled by drools
internally? If not then how can I retract them say after 5 minutes?
Also I'm using sliding window and I've not explicitly declared expiry time,
for events, in my drl file. Should I define it or will drools remove them
after the maximum sliding window time defined in rules?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-s...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 4 months
Loading StatefulKnowledgeSession and Session-ID-Concept
by O.S.
Hi,
I have a question concerning the id-concept of StatefullKnowledgeSessions:
int sessionId = ksession.getId();
While looking up the KnowledgeStoreService-Interface I was a little bit
confused about the loadStatefulKnowledgeSession(...) Method:
|*loadStatefulKnowledgeSession*(int id, KnowledgeBase kbase,
KnowledgeSessionConfiguration configuration, Environment environment)|
I think the first parameter is the session id (see above). But why does
he needs the kbase, config and environment too? Is the session id not
global? Is she bound to one or more of the Classes/Instances
(|kbase|,|configuration,||environment)|?
||
|If the id| is bound, it will implicitly mean that there can be more
than one ksessions with the same id?
Kind regards,
O.S.
||
15 years, 4 months
Updating interval events
by anais
Hello.
I'm using Drools in a system of alarms. I have a drl file with rules in
wich I have defined events that are java classes. I have defined timed
events and interval events. My idea is that an external timer inserts some
interval events time to time. Well, the thing is that I need update an
interval event if another event appears.
I have read somewhere in documentation that updating an event is equal to
remove it and insert a new event with the changes made. If I update an
interval event, will its timestamp change? That is, if I update an interval
event, the moment that this event finishes will be delayed? The problem will
be solved if I assign its timestamp to one property of the event?
Thanks in advance.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Updating-interval-eve...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 4 months
NullPointerException when using Drools rule template
by Roger Smith
All -
I tried out Drools rule template with a with a proptotype app. Drools is
throwing NullPointerException as below. I would much appreciate if someone
on this list can help.
java.lang.NullPointerException
at
org.drools.template.parser.DefaultTemplateColumn.createCellCondition(DefaultTemplateColumn.java:68)
at
org.drools.template.parser.DefaultTemplateColumn.addCondition(DefaultTemplateColumn.java:91)
at
org.drools.template.parser.DefaultTemplateRuleBase.createColumnConditions(DefaultTemplateRuleBase.java:105)
at
org.drools.template.parser.DefaultTemplateRuleBase.createTemplateRule(DefaultTemplateRuleBase.java:98)
at
org.drools.template.parser.DefaultTemplateRuleBase.getDTRules(DefaultTemplateRuleBase.java:85)
at
org.drools.template.parser.DefaultTemplateRuleBase.<init>(DefaultTemplateRuleBase.java:64)
at
org.drools.template.parser.TemplateDataListener.<init>(TemplateDataListener.java:76)
at
org.drools.template.parser.TemplateDataListener.<init>(TemplateDataListener.java:52)
at
org.drools.template.ObjectDataCompiler.compile(ObjectDataCompiler.java:44)
Here is my code
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
ObjectDataCompiler converter = new ObjectDataCompiler();
InputStream dis = new FileInputStream( new File(
"/home/pranab/Projects/gridx/ct11_1.drl" ) );
if (null == dis){
System.out.println("null rule template stream");
return;
}
Collection<Map<String,Object>> paramMaps = new
ArrayList<Map<String,Object>>();
Map<String,Object> params = new HashMap<String,Object>();
params.put("summerOnPeakPrimaryRate", new Integer(299));
params.put("summerOnPeakSecondaryRate", new Integer(524));
params.put("summerSemiPeakPrimaryRate", new Integer(176));
params.put("summerSemiPeakSecondaryRate", new Integer(305));
params.put("summerOffPeakPrimaryRate", new Integer(139));
params.put("summerOffPeakSecondaryRate", new Integer(243));
params.put("winterOnPeakPrimaryRate", new Integer(249));
params.put("winterOnPeakSecondaryRate", new Integer(438));
params.put("winterSemiPeakPrimaryRate", new Integer(176));
params.put("winterSemiPeakSecondaryRate", new Integer(305));
params.put("winterOffPeakPrimaryRate", new Integer(139));
params.put("winterOffPeakSecondaryRate", new Integer(243));
paramMaps.add(params);
String drl = converter.compile(paramMaps, dis);
Reader rdr = new StringReader( drl );
kBuilder.add( ResourceFactory.newReaderResource(rdr),
ResourceType.DRL);
The line in blue is throwing the exception. This code is very similar to the
example code in Drools Expert guide.
Best,
Roger
15 years, 4 months
Doubt regardging Drools-RETE
by Harshit Bapna
Hello everyone,
1. If there are not many common facts i.e all rules are operating on
distinct facts / data. Does this mean the algorithm will not bring in much
benefit ?
2. Also if the facts are same but the LHS of a rule is quite different from
others then will RETE have its benefits.
I have gone through the RETE algorithm documentation and RETE node diagram
chart but still finding difficulty to understand it.
Can somebody please provide a layman language link to understand RETE.
15 years, 4 months
Unable to use StatefulKnowledgeSession inside a webservice
by sumatheja
Hi All,
I'm trying to expose a class as a web service using jax ws.
The class has methods using StatefulKnowledgeSession . Everything goes
on well if i omit those fields. Any idea on this??
--
cheers
Sumatheja Dasararaju
15 years, 4 months
Issue with literals in Drools Verifier 5.1.1
by Nathan Bell
Using org.drools.verifier found in "drools-verifier-5.1.1.jar" I get an
org.drools.RuntimeDroolsException if a pattern in a rule LHS contains a
comparison to a literal value using the equals operator.
Please consider the following rule I created solely for the purposes of
isolating this issue.
package com.simple.test.rule
import com.p1s.mps.rulevalidator.TestFact;
rule "TestRule"
when
$fact : TestFact(value == 1)
then
System.out.println($fact.getValue());
end
The following class definition for the TestFact.
package com.p1s.mps.rulevalidator;
public class TestFact
{
private int value;
public TestFact(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + value;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TestFact other = (TestFact) obj;
if (value != other.value)
return false;
return true;
}
}
The following unit test which attempts to use Verifier.
@Test
public final void testVerifierOnLiteral()
{
VerifierBuilder verBuilder =
VerifierBuilderFactory.newVerifierBuilder();
Verifier ver = verBuilder.newVerifier();
String ruleText = getRuleFromResource(TEST_RULE);
ver.addResourcesToVerify( ResourceFactory.newReaderResource(
new StringReader( ruleText ) ), ResourceType.DRL );
Assert.assertTrue(ver.fireAnalysis());
}
Running the test with JUnit produces the following exception.
java.lang.RuntimeException: org.drools.RuntimeDroolsException: Exception
executing ReturnValue constraint
org.drools.rule.ReturnValueRestriction@589f81 : [Error: cannot convert
<1> to a numeric type: class java.lang.Integer [0]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.drools.verifier.builder.VerifierImpl.analyse(VerifierImpl.java:148)
at
org.drools.verifier.builder.VerifierImpl.fireAnalysis(VerifierImpl.java:
117)
at
com.p1s.mps.rulevalidator.NumericConversionTest.testVerifierOnLiteral(Nu
mericConversionTest.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMet
hod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallab
le.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMetho
d.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod
.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.jav
a:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner
.java:73)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner
.java:46)
at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at
org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.jav
a:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4Tes
tReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:197)
Caused by: org.drools.RuntimeDroolsException: Exception executing
ReturnValue constraint org.drools.rule.ReturnValueRestriction@589f81 :
[Error: cannot convert <1> to a numeric type: class java.lang.Integer
[0]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.drools.rule.ReturnValueConstraint.isAllowedCachedRight(ReturnValueCo
nstraint.java:168)
at
org.drools.common.TripleBetaConstraints.isAllowedCachedRight(TripleBetaC
onstraints.java:211)
at
org.drools.reteoo.NotNode.assertObject(NotNode.java:140)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleOb
jectSinkAdapter.java:59)
at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(Com
positeObjectSinkAdapter.java:450)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:378)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:1174)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:1123)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:917)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSes
sionImpl.java:251)
at
org.drools.verifier.builder.VerifierImpl.analyse(VerifierImpl.java:136)
... 26 more
Caused by: org.drools.RuntimeDroolsException: [Error: cannot convert <1>
to a numeric type: class java.lang.Integer [0]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.drools.rule.ReturnValueRestriction.isAllowed(ReturnValueRestriction.
java:236)
at
org.drools.rule.ReturnValueConstraint.isAllowedCachedRight(ReturnValueCo
nstraint.java:162)
... 39 more
Caused by: [Error: cannot convert <1> to a numeric type: class
java.lang.Integer [0]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.mvel2.math.MathProcessor.getInternalNumberFromType(MathProcessor.jav
a:577)
at
org.mvel2.math.MathProcessor._doOperations(MathProcessor.java:155)
at
org.mvel2.math.MathProcessor.doOperations(MathProcessor.java:79)
at
org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation
.java:102)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:1
04)
at org.mvel2.MVEL.executeExpression(MVEL.java:978)
at
org.drools.base.mvel.MVELReturnValueExpression.evaluate(MVELReturnValueE
xpression.java:92)
at
org.drools.rule.ReturnValueRestriction.isAllowed(ReturnValueRestriction.
java:226)
... 40 more
However, if I use the following version of the same rule where I have
added parentheses it works.
package com.simple.test.rule
import com.p1s.mps.rulevalidator.TestFact;
rule "TestRule"
when
$fact : TestFact(value == (1))
then
System.out.println($fact.getValue());
end
Note that both versions of the DRL file compile, run, and produce the
correct results.
Thank You,
Nathan Bell
15 years, 4 months
KnowledgeAgent ChangeSet failing to reload resources
by Fink, Eric [USA]
Greetings. I am using Drools 5.1.1's KnowledgeAgent ChangeSet functionality and have come across an issue.
here is the use case:
Fire up the application with a valid DRL file. Works as designed.
Update the DRL file. ChangeSet senses updated file, KnowledgeBase is updated with updated rules, yadda, yadda. Works as designed.
Update the DRL file and introduce errors in the LHS of the rule. For example, I changed Sensor to Sccensor in the example below and $masterId is not defined. The following is reported as expected:
KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
[2010:11:308 09:11:515:info] KnowledgeAgent performing an incremental build of the ChangeSet
[2010:11:308 09:11:843:debug] KnowledgeAgent has KnowledgeBuilder errors object=Unable to resolve ObjectType 'Sccensor' : [Rule name='18) sensorCount derived variable']
Rule Compilation error : [Rule name='18) sensorCount derived variable']
bass/enrichment/Rule_18__sensorCount_derived_variable_0.java (7:590) : $masterID cannot be resolved
bass/enrichment/Rule_18__sensorCount_derived_variable_0.java (8:624) : $masterID cannot be resolved
bass/enrichment/Rule_18__sensorCount_derived_variable_0.java (9:769) : $masterID cannot be resolved
Update the DRL file to the previously working version. The ChangeSet never senses that the file has been updated. It just runs along checking every x seconds.
Has anyone experienced this? Is there a listener that should be firing somewhere?
Thanks is advance.
- Eric
15 years, 4 months