refreshing rules in 4.0.7, Janino
by Mike Merrill
Hi all,
I'm seeing consistency issues when trying to refresh rules manually. I am
seeing issues with sessions getting different results while I call this
function in a loop. Is there a more proper way of migrating the sessions over
to a rules base that has updated rules?
/**
* Function to compile the drools rules. It reads the rules from the data
access object
* @throws APIException
*/
public static void refreshRules() throws APIException {
if(null == DAO) return;
try {
DAO.getSqlMapClient().flushDataCache();
RULES_BASE.lock();
Package[] packages = RULES_BASE.getPackages();
for(int i = 0; i < packages.length; ++i) {
RULES_BASE.removePackage(packages[i].getName());
}
Properties properties = new Properties();
properties.setProperty( "drools.dialect.java.compiler",
"JANINO" );
PackageBuilderConfiguration cfg = new
PackageBuilderConfiguration( properties );
PackageBuilder builder = new PackageBuilder(cfg);
Collection<DroolsVO> rulesCollection = DAO.getRules();
for(DroolsVO rule : rulesCollection) {
Reader source = new StringReader(rule.getRules());
builder.addPackageFromDrl(source);
}
Package pkg = builder.getPackage();
if(null != pkg) {
RULES_BASE.addPackage(pkg);
}
} catch(... e) {
throw APIExceptionFactory.generateException(e);
} finally {
RULES_BASE.unlock();
}
}
15 years, 7 months
Sudoku example in Guvnor 5.0.0 CR1
by Ingold, Jonathan
Hello,
I was wondering if anyone has tried using Guvnor with the Sudoku example
in examples for 5.0.0 CR1. We are looking at Guvnor's functionality and
I'm have difficulty running any successful scenario's against the Sudoku
rules in Guvnor. I know this is one of the more complex examples in the
drl package but it seems that there would have to be a lot of work done
to get any benefit from Guvnor without rewriting some of the Java
Classes. Anyone willing to share any experiences with this?
Thanks,
Jon
15 years, 7 months
how to use Array type in Drools
by Zeke
Hi,
I am using Drools 4.0.7 GA. I want to use Array type in my rule condition.
My drl is like below:
> package org.drools.examples.test;
>
> import org.drools.examples.HelloWorldExample.Message;
>
> rule "check.array"
> dialect "java"
> when
> m:Message( arr[0] == "1" )
> then
> System.out.println( "===check array ok===" );
> end
arr is an int type array. When I run the test case, I meet below
exception:
> Exception in thread "main" org.drools.RuntimeDroolsException: Exception
> executing predicate eval( arr[0] == "1" )
> at
> org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:216)
> at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
> 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
> org.drools.examples.HelloWorldExample.main(HelloWorldExample.java:69)
> Caused by: org.mvel.CompileException: illegal use of []: unknown type: [I
> at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getCollectionProperty(ReflectiveAccessorOptimizer.java:482)
> at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:274)
> at
> org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
> at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:186)
> at
> org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:21)
> at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
> at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
> at org.mvel.MVEL.executeExpression(MVEL.java:234)
> at
> org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:45)
> at
> org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:209)
> ... 10 more
>
Can anyone kindly tell me how to use Array type in Drools? Thanks in
advance!
- Zeke
15 years, 7 months
Bug in binary package generation?
by Dan Seaver
I built a rule package in Guvnor and downloaded the binary. When I use:
builder.add(ResourceFactory.newInputStreamResource(inStream),
ResourceType.PKG);
I get a NullPointerException. But, if I use Guvnor's "view source", copy the
source to a file, and use:
builder.add(ResourceFactory.newInputStreamResource(inStream),
ResourceType.DRL);
the package is added without an exception and behaves as anticipated. It
appears that the exception generated by the binary package is occurring in
PackageBuilder.addKnowledgeResource (line 495).
Am I using a valid technique for loading binary packages?
I don't have drools source code to trace into the details with Eclipse.
What's the standard procedure for getting drools source code?
Any other suggestions for determining the cause of my problem?
Any and all help is appreciated.
--
View this message in context: http://www.nabble.com/Bug-in-binary-package-generation--tp23263551p232635...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 7 months
Rules formulation question
by Armaghan Mahmud
I'm new to the mailing list so I'll start off by saying hello to everyone.
I've recently started using DROOLS and I seem to have hit a dead end. I'm
trying to pass in an enum and a list into the working memory one at a time
but I would like my rule to first see if it the enum matches a hard coded
enum value. Additionally, I would also like the rule to see if the enum
value that is being passed to the working memory happens to fall in the list
or not. First of all, is it possible to do that in one rule? I've been
trying to do that using "&&" and "contains" keywords but I'm not getting
anywhere. I don't have the code in front of me or I would've pasted it but I
hope you can understand my point. Any help that I can get in this matter
will be greatly appreciated.
Thanks,
Armaghan
15 years, 7 months
Does drools have any trigger?
by Lindy hagan
I was looking at Blaze Advisor documentation it has “when changed”
operator that only fires when an attribute of an object changes. A business
analyst might use it to watch for any important issue, such as a thermostat
warning in a process plant or a particular stock reaching a certain price or
volume.
In similar way does Drools have this feature?
Can any one correct if I am wrong: Rules can be updated by business users
thru BRMS and Guvnor? (I did not get chance to go thru these)
15 years, 7 months