Re: [rules-users] Replacement for eval
by Greg Barton
If you use bean property conventions for naming your methods you can use a regular condition element. for instance, you could rename emptyMessageFinder() to isMessageFound() or getMessageFound() and your condition would look like this:
when
m : Message(messageFound == true)
then
...
end
And when you do this the rete is used, birds sing in the trees, and world peace will be declared.
GreG
On Nov 16, 2010, at 5:37, Nirmal Fernando <nirmal070125(a)gmail.com> wrote:
Hi,
I have two questions.
1) Is there any other way/method in Drools to test the truth value of a condition other than "eval"?
In almost all rules of my application needs to test conditions, and it takes ages to run using "eval".
2) Say I have a java method which returns a boolean, and I have used it within an "eval" function. (eg: eval(message.emptyMessageFinder()) )
This "emptyMessageFinder()" method will return a "boolean" if there's an empty message. This function is containing many loops and recursive operations.
Will I get a performance improvement if I alternate the above such that the "emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage)
in the Message class to true and false, and I'm using following in my drl.
when
m: Message()
m.emptyMessageFinder()
eval(m.anyEmptyMessage) //can I use eval here??
......
If someone can answer these questions it would be a great help!
Thank you in advance!
--
Best Regards,
Nirmal
C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.
Blog: http://nirmalfdo.blogspot.com/
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 7 months
OutOfMemoryError during marshalling with NOT conditions
by ulibube
A little while back someone posted a message about an OutOfMemoryError
problem when marshalling a knowledgebase containing rules with NOT
conditions:
http://drools-java-rules-engine.46999.n3.nabble.com/OutOfMemoryError-on-m...
Someone created a JIRA issue for him, which says that it's fixed, but there
are two comments on it now saying that it is not (in 5.1.1), one of them
being mine:
https://jira.jboss.org/browse/JBRULES-2453
I don't know the recommended procedure for requesting a bug to be reopened
or cloned, which is why I am posting here. My apologies. I am quite
convinced that there is still a bug in that code.
For illustration, below is a little rule base which lets me reproduce the
issue. The three fact types are pretty simple, and I insert 2 facts for
DCMSeries and about 630 for DCMInstance. The marshalling breaks if done
after inserting the facts and before a call to fireAllRules. Marshalling
afterwards does not consistently exhibit this issue. Eliminating the "not"
condition also "fixes" the problem.
Uli
package mypackage
import somepackage.DCMInstance
import somepackage.DCMSeries
import somepackage.StackingOrder
rule "Stack Default"
when
DCMSeries( $suid : uid )
DCMInstance( seriesUID == $suid, $iuid: uid )
not StackingOrder(instanceUID == $iuid)
then
end
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/OutOfMemoryError-duri...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months
Fusion temporal operators, time units
by Nathan Bell
Fusion seems to only support days, hours, minutes, seconds and
milliseconds for the units of time used with temporal operators. For
example consider the following rule (which works correctly):
rule "AdmittedInLast7Days"
dialect "java"
when
$now : RuleTime()
$account : PatientAccount(this after[-7d,0s] $now )
then
System.out.println("AdmittedInLast7Days fired");
End
Now suppose that I want an alternate version of this rule that instead
of firing for patients admitted in the last 7 days it fires for patients
admitted in the last 7 months, or years. Is there built-in support for
doing this? If not, does anyone have suggestions on the best way to
approach this?
Thank You,
Nathan Bell
15 years, 7 months
Replacement for eval
by Nirmal Fernando
Hi,
I have two questions.
1) Is there any other way/method in Drools to test the truth value of a
condition other than "eval"?
In almost all rules of my application needs to test conditions, and it takes
ages to run using "eval".
2) Say I have a java method which returns a boolean, and I have used it
within an "eval" function. (eg: eval(message.emptyMessageFinder()) )
This "emptyMessageFinder()" method will return a "boolean" if there's an
empty message. This function is containing many loops and recursive
operations.
Will I get a performance improvement if I alternate the above such that the
"emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage)
in the Message class to true and false, and I'm using following in my drl.
when
m: Message()
m.emptyMessageFinder()
eval(m.anyEmptyMessage) //can I use eval here??
......
If someone can answer these questions it would be a great help!
Thank you in advance!
--
Best Regards,
Nirmal
C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.
Blog: http://nirmalfdo.blogspot.com/
15 years, 7 months
Drools flow question on proper exception handling / use of faults
by Liße, Jan
Hi,
I have a process workflow where an exception might occur within one Action. I need to react on this exception in the workflow. That means I don't want to skip the entire processing
I just want to react properly by setting an error variable and skip this specific item (my process iterates over a list of items).
Now I tried to model my Action together with a Fault Node within a CompositeNode as seen in the User manual section on exception handling. The outgoing connection
of my Action is connected with the Fault. The outgoing connection of the CompositeNode is connected with the next Action. When I run the process it comes to the Action node and hangs there if no exception occurs (the next Action is never reached). Looking at the model this is reasonable since the outgoing connection leads to the Fault node. So my question is how can I properly model this kind of exception handling, where I need two ways of execution (one if everything goes fine, and one for fault handling)? Wrapping everything inside a CompositeNode alone does not seem to be sufficient...
Thanks in advance for any help!
-Jan
15 years, 7 months
Drools Flow - problem with parameter mapping
by matus
Hi,
I recently run into some problems when trying to create a simple holiday
request process.
I defined process variables but I struggle to understand how to access them
in Human Task.
In my User Task ,,holiday approval" I have this as a description:
#{employee} requested holiday for #{length} days
I set both variables when I start the process and the result looks as
expected, for example ,,John requested holiday fo 14 days.
But lets say I want a manager approving the holiday request to add his
response as a variable. How do I do that?
I tried to use the Result mapping with someting like this: response=response
but I get an error saying ,,There is no ID/IDREF binding for IDREF
'_2_response'.
Also if I manage to get this running, how do I set this variable in a client
app?[using WS_HT]
I am sorry if I am asking realy basic things, but I realy need some advice.
Bellow is the process definition.
Thanks a lot, matus
<?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/MODELBPMN20.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="_employeeItem" structureRef="String" />
<itemDefinition id="_lengthItem" structureRef="String" />
<itemDefinition id="_managersItem" structureRef="String" />
<itemDefinition id="_responseItem" structureRef="String" />
<process processType="Private" isExecutable="true" id="com.sample.test"
name="test process" tns:packageName="defaultPackage" >
<!-- process variables -->
<property id="employee" itemSubjectRef="_employeeItem"/>
<property id="length" itemSubjectRef="_lengthItem"/>
<property id="managers" itemSubjectRef="_managersItem"/>
<property id="response" itemSubjectRef="_responseItem"/>
<!-- nodes -->
<startEvent id="_1" name="StartProcess" />
<userTask id="_2" name="Holiday approval" >
<ioSpecification>
<dataInput id="_2_CommentInput" name="Comment" />
<dataInput id="_2_SkippableInput" name="Skippable" />
<dataInput id="_2_ContentInput" name="Content" />
<dataInput id="_2_TaskNameInput" name="TaskName" />
<dataInput id="_2_PriorityInput" name="Priority" />
<dataOutput id="_2_responseOutput" name="response" />
<inputSet>
<dataInputRefs>_2_CommentInput</dataInputRefs>
<dataInputRefs>_2_SkippableInput</dataInputRefs>
<dataInputRefs>_2_ContentInput</dataInputRefs>
<dataInputRefs>_2_TaskNameInput</dataInputRefs>
<dataInputRefs>_2_PriorityInput</dataInputRefs>
</inputSet>
<outputSet>
<dataOutputRefs>_2_responseOutput</dataOutputRefs>
</outputSet>
</ioSpecification>
<dataInputAssociation>
<targetRef>_2_CommentInput</targetRef>
<assignment>
<from xs:type="tFormalExpression">#{employee} requested holiday
for #{length} days </from>
<to xs:type="tFormalExpression">_2_CommentInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_2_SkippableInput</targetRef>
<assignment>
<from xs:type="tFormalExpression">false</from>
<to xs:type="tFormalExpression">_2_SkippableInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_2_ContentInput</targetRef>
<assignment>
<from xs:type="tFormalExpression"></from>
<to xs:type="tFormalExpression">_2_ContentInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_2_TaskNameInput</targetRef>
<assignment>
<from xs:type="tFormalExpression">Holiday Approval</from>
<to xs:type="tFormalExpression">_2_TaskNameInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_2_PriorityInput</targetRef>
<assignment>
<from xs:type="tFormalExpression"></from>
<to xs:type="tFormalExpression">_2_PriorityInput</to>
</assignment>
</dataInputAssociation>
<dataOutputAssociation>
<sourceRef>_2_response</sourceRef>
<targetRef>_2_response</targetRef>
</dataOutputAssociation>
<potentialOwner>
<resourceAssignmentExpression>
<formalExpression>#{managers}</formalExpression>
</resourceAssignmentExpression>
</potentialOwner>
</userTask>
<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>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.sample.test" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="16" y="16" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_2" >
<dc:Bounds x="96" y="16" width="100" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="340" y="16" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_1-_2" >
<di:waypoint x="40" y="40" />
<di:waypoint x="146" y="40" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_2-_3" >
<di:waypoint x="146" y="40" />
<di:waypoint x="364" y="40" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
15 years, 7 months
JBoss Rule Trace feature with 5.0
by Kinjal Khandhar
Hi All,
Can anybody help me with Drools Audit Log(Rule Trace) feature.
My goal is to check which rule got executed,in what sequence and which
conditions got evaluated and which did not.
Any help/pointers greatly appreciated.
Thanks in advance.
Regards,
Kinjal
15 years, 7 months