Boolean global issue
by Dan Seaver
So, I'd like to have a ruleset that returns true or false. The way I set that
up in one of the version 5 candidate releases is to use a Boolean global and
use drools.getWorkingMemory().setGlobal("result", new Boolean(false)) to
change the value of the global. I could then access the updated value in the
code by using the old style getGlobal.
However in version 5 Final release, the global value changes fine within the
ruleset, but is not updated when I access it via ExecResults. I imagine the
reason for this is that immutable variables are handled differently in the
final release than in the candidate release, but need to know whether this
is by design.
Here is the RuleSet I'm using:
package BooleanTest
global Boolean result
rule "Initialize"
salience -1
when
then
drools.getWorkingMemory().setGlobal("result", new Boolean(false));
System.out.println("Initialized result to false");
end
rule "Display result"
salience -2
when
then
System.out.println("result is " + result);
end
Here is the pertinent code:
cmds.add(CommandFactory.newSetGlobal("result", null, true));
ExecutionResults execResults = ksession.execute(CommandFactory
.newBatchExecution(cmds));
for (String identifier : execResults.getIdentifiers()) {
System.out.format(String.format("Identifier: %s, Value: %s \n",
identifier, execResults.getValue(identifier)));
}
Here is the output:
Initialized result to false
result is false
Identifier: result, Value: null
--
View this message in context: http://www.nabble.com/Boolean-global-issue-tp24040774p24040774.html
Sent from the drools - user mailing list archive at Nabble.com.
14 years, 10 months
Web based decision tables
by Dan Seaver
Can someone tell me the appropriate way to use web-based decision tables?
They seem to work fine if I create them in Guvnor, and then build and deploy
the binary package from Guvnor. However, if I copy the gdst from Guvnor to
Eclipse and use KnowledgeBuilder.add to attempt to add the resource as a
DTABLE or BRL resource type, I get a NullPointerException or
CannotResolveClassException.
Any help would be appreciated.
Thanks,
Dan
--
View this message in context: http://www.nabble.com/Web-based-decision-tables-tp24042079p24042079.html
Sent from the drools - user mailing list archive at Nabble.com.
14 years, 10 months
Getting rule metadata and LHS information in consequence
by dhari
I have an unusual requirement. The application we are developing contains
more than 100 rules. All rules are just to validating the data pass in
facts. Upon failure, we log the error message. The requirement is to log
rule name and LHS condition (fact attributes, constant data, comparative
operators etc) of the rule that failed rule.
I am not sure is there any way to get this information dynamically from the
working memory/rule base or other possible source. I wonder if some has
implemented such scenario in the past and could help me.
Regards,
Shabbir
--
View this message in context: http://www.nabble.com/Getting-rule-metadata-and-LHS-information-in-conseq...
Sent from the drools - user mailing list archive at Nabble.com.
14 years, 10 months
Inserting Collection into WorkingMemory
by VinuJay
Hi my fact object looks like this,
class ProcessRequest {
Long requestId;
String processType;
String assigneeUsers;
List<String> businessData;
//Getters and Setters
}
I have inserted the fact object into working memory in this way
WorkingMemory workingMemory = ruleBase.newStatefulSession();
FactHandle factObject = workingMemory.insert(processRequest );
workingMemory.fireAllRules();
My question is how to use the values in the business data for comparison in
the rules.drl file rule "Audit"
when
p: ProcessRequest(processType == "Audit" && SSN == 1234) then
p.setAssigneeUsers("AuditUser1");
end
When i try with the above rule it says no field extractor found for SSN, SSN
is part of the businessdata(List<String>)
Please do suggest me
1. How to make the Workingmemory aware of the Collection - businessData 2.
Change the rules.drl file syntax to access values from Collection.
--
View this message in context: http://www.nabble.com/Inserting-Collection-into-WorkingMemory-tp23975474p...
Sent from the drools - user mailing list archive at Nabble.com.
14 years, 10 months
Problem with parallel subflows
by tom
Hi there! I am using drools 5.0 final. I tried to implement 2 subflows which
are polling for database entries.
More exactly: my application consists of 1 process that splits up into 2
subflows (AND - split). Both subflows
Consist of a timer, followed by an action node (java code). When I start the
application it seems that only one of the
Subflows is executed, but twice! (although subflow-IDs are correctly set).
If I change the action-node to MVEL input, everything works fine! If I start
just one of the
Subprocesses, they work correctly. I am calling fireUntilHalt in a new
thread, followed by startProcess(X) , like
It is recommended in the docu.
Does anyone know this problem?
Greets
Tom
14 years, 10 months
multiple .drl files
by Chris Richmond
Hello all,
I want to create a baseline rules file with Fusion that does some basic
aggregating that I know I will need later.things like keep running averages
over the last minute or so of several object values.
Is it possible to then "inherit" or at least reference those aggregates I am
keeping track of from another .drl file in some way.allowing me to always
keep my basic aggregation functions in one rule file and then add additional
rules/functions to my rule memory space later.or must any further rules that
wish to reference those aggregate or statistics objects also be contained
within the same .drl file? I understand I can have multiple .drl files, but
I am wondering specifically about referencing objects and variables created
in another rules file.
Thanks,
Chris
14 years, 10 months
Drools fusion memory management
by Chris Richmond
Hello,
I wanted to ask this question in a separate email so as to keep each email
to one topic for easier thread following. Let me know if you prefer
multiple questions per email next time.
I am using Drools fusion basically with some success where I am at this
point only running some aggregates and calling some java functions when a
running average over the last 1 minute or so drops below a certain value.
The sources for those values come from objects I am injecting into memory
space, but I am not specifically calling retraction code since it is my
understanding that I can set the policy in the rule file for how long to
hold objects in memory. So for example I have this rule which simpoly
outputs to out when the average goes above 100 for the last 10 items(you can
tell I created mine based on the stock ticker). It seems to be working, but
I have some questions to ensure I understand before moving forward.
So below the "declare MyObject" with assigning it role event with a default
expiration of 2 minutes. Is my undertanding correct that fusion will
disregard thos objects that are injected without me having to take any other
action?
Also, in my "show averages" rule below, if I did ont have the "declare
MyObject" delcaration with expiration policy set, would fusion automatially
throw away MyObjects older than the last 10 based on my rule no longer
needing them? If it would, then which takes priority, the expires
declaration for MyObject or the no longer needed by my aggregate rule below.
I am assuming that the rule would keep them beyond 2 minutes it it was
necessary, but is this correct? If the rule as written would not
automatically remove objects from memory space, then is there something I
could do to tell the rule to do so when it is no longer needed by my
aggregate?
Thanks,
Chris
<imports removed>
# default dialect for the semantic code will be MVEL
dialect "mvel"
# tells the engine that a object instance will assume the
# role (semantics) of events and that the default retention
# policy will be 2 minutes
declare MyObject
@role( event )
@expires( 2m )
end
rule "show averages"
when
$n : Number( doubleValue > 100 ) from accumulate (
$stat:MyObject($bc: byteCount, srcIPAddress == "10.5.0.4") over
window:length(10) from entry-point "MyObject stream",
average( $bc )
)
then
System.err.println("average: " + $n)
end
14 years, 10 months
setFocus
by Earnest Dyke
Converting a 4.0.7 project to 5.0.1 and StatefulKnowledgeSession does not have a .setFocus method like StatefulSession has. How do I accomplish the same function in 5.0.1?
Earnie!
14 years, 10 months
Throwing runtimeException 4.0.7 not supposed
by surya_n2007
Throwing runtime exception in this example inserted person object as person
name is null. Ideally need to add error
"P01" and in second rule checks for precondition "P01" exist and skip rule.
But i am getting the below error.
Please let me know this is bug, i dont want to check again "Second Rule"
name object is not null.
I think this is happening since drools frist try to run all rules before
start execution.
please let me know whether anything wrong on my end.
Rule Engine COde :
Person person = test.new Person();
// Name name = person.new Name();
// person.setName(name);
workingMemory.insert(person);
rule "First Rule" salience 100 lock-on-active true
when
person : Person()
eval(person.name == null)
then
person.errors.add("P01");
System.out.println("Rule 1 invoked"+person.errors);
update(person);
end
rule "Second Rule" salience 99 lock-on-active true
when
person : Person()
eval(!person.errors.contains("P01"))
eval(person.name.firstName=="Bob")
then
person.name.suffix="Mr";
System.out.println("Rule 2 invoked");
end
org.drools.RuntimeDroolsException:
com.sample.Rule_Second_Rule_0Eval1Invoker@4b42aa1e :
java.lang.NullPointerException
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:82)
at
org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:148)
at
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(SingleTupleSinkAdapter.java:29)
at
org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:157)
at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(CompositeTupleSinkAdapter.java:73)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at com.sample.DroolsTest.main(DroolsTest.java:36)
Caused by: java.lang.NullPointerException
at com.sample.Rule_Second_Rule_0.eval1(Rule_Second_Rule_0.java:14)
at
com.sample.Rule_Second_Rule_0Eval1Invoker.evaluate(Rule_Second_Rule_0Eval1Invoker.java:20)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:77)
... 14 more
--
View this message in context: http://www.nabble.com/Throwing-runtimeException-4.0.7-not-supposed-tp2400...
Sent from the drools - user mailing list archive at Nabble.com.
14 years, 10 months