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.
14 years
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
14 years
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.
14 years
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
14 years
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
14 years
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
14 years
[flow][bpmn2] Variable not available in workitem?
by David Wynter
Hi,
My first bpmn2 workflow. With this the important part of the bpmn2 xml
definition, transformationTest.bpmn2.
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL
BPMN20.xsd"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools">
<itemDefinition id="_ETLGroupItem"
structureRef="com.example.model.impl.ETLGroupImpl" />
<process processType="Private" isExecutable="true" id="Test" name="Test
Process" >
<!-- process variables -->
<property id="ETLGroup" itemSubjectRef="_ETLGroupItem"/>
<!-- nodes -->
<startEvent id="_1" name="StartProcess" />
<task id="_2" name="ETLGroup" tns:taskName="ETLGroup" >
<ioSpecification>
<inputSet>
</inputSet>
<outputSet>
</outputSet>
</ioSpecification>
</task>
<endEvent id="_3" name="End" >
<terminateEventDefinition/>
</endEvent>
<!-- connections -->
<sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
<sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />
</process>
I have this test case
@Before
public void setUp() throws Exception {
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
kb.add(ResourceFactory.newClassPathResource("transformationTest.bpmn2"),
ResourceType.BPMN2);
if (kb.hasErrors()) {
throw new RuntimeException(kb.getErrors().toString());
}
KnowledgeBaseConfiguration configuration =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
configuration.setProperty("drools.workDefinitions", "WorkDefinitions.conf
etlgroup.conf");
KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase(configuration);
knowledgeBase.addKnowledgePackages(kb.getKnowledgePackages());
session = knowledgeBase.newStatefulKnowledgeSession();
TrackingProcessEventListener trackingprocel = new
TrackingProcessEventListener();
session.addEventListener(trackingprocel);
session.getWorkItemManager().registerWorkItemHandler("ETLGroup", new
ETLGroupWorkItemHandler());
WorkflowLoader wrkflwLdr = new WorkflowLoader();
etlGroup = wrkflwLdr.loadETLGroup("etlGroup",
"/home/david/workspace/EDMEngine/META-INF/content.xml");
}
@Test
public void testSessionRun() {
Map<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("ETLGroup", etlGroup);
session.insert(etlGroup);
ProcessInstance processInstance = session.startProcess("Test", parameterMap);
session.insert(processInstance);
session.fireAllRules();
}
I have this work item handler
public class ETLGroupWorkItemHandler implements WorkItemHandler {
private ETLGroupService service = null;
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
ETLGroup etlGrp = (ETLGroup) workItem.getParameter("ETLGroup");
...
etlGroup in the @Before section is not null but etlGrp is always null? I must
have missed something, but cannot see what it is. Can someone point it out to
me?
Thx.
David
14 years
Support for Drools Guvnor / Expert in Latin America
by Miguel Fernando Cabrera
Hello to all,
In my company (an insurance company in Colombia) and we are evaluating
various BRMS.
We have been testing iLog JRules and now we are evaluating Drools
Expert/Guvnor (or JBoss BRMS).
As I am an open source guy, I want to use Drools. As we use a lot of
open source libraries right now (like CXF) is easy for me to use the BRE as
a library.
However, when planning to use a full BRMS like Guvnor, we will need someone
to install and support it.
The obvious choice would be Red Hat / JBoss, However we have tried to
contact sales department but it has been impossible to get an aswer from
them.
So, my question is, Does Anyone know a company (could be the states or south
america) willing to provide the installation and support services for the
BRMS and the maybe the BRE ?
I really appreciate any help on the matter.
--
Miguel Fernando Cabrera Granados
"A los hombres fuertes les pasa lo que a los barriletes; se elevan cuando es
mayor el viento que se opone a su ascenso." - José Ingenieros
14 years
Using an array column header in Drools Template
by sk
I am given a list of strings (Comma separated) as input and I need to check
if any of the strings satisfy a given condition. I am trying to implement it
using Drools Rule template with an array column header of unknown size.
To be more specific I need to be be able to generalize the below Template to
include any number of names in the eval statement.
The idea is to give any number of names as input and check if any of the
names satisy the condition given in the template.
template header
name[]
package gms.drools.templates;
global java.util.Map nameMap;
import java.util.Map;
template "RuleTemplate_name"
rule "rule_name"
when
//Generalize the below line to check if the nameMap contains any of the
names given in the input //eval(nameMap.containsKey("@{name1}") ||
nameMap.containsKey("@{name2}") || nameMap.containsKey("@{name3}") ||
nameMap.containsKey("@{name4}"))
then
System.out.println("SUCCESS");
end
end template
Please let me know if anyone has a solution for this or any other
suggestions.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Using-an-array-column...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years