Creating custom evaluator in drools 5
by Asif Iqbal
Hi,
Im new to drools and am trying to implement the following, and really need to override the evaluator '>' and '<' for strings... Can someone please show me how to do this?
SomeClass(version > "02.00.01" && version < "02.00.20")
regards
I
15 years, 5 months
Validation in Guvnor fails due to unrecognized method of implemented interface
by Brody bach
Hi,
I have a class which implementes several interfaces
class MyClass implements interA, interB, interC {
private String nameA;
private String nameB;
private String ownString;
public String getNameA(){ ---impl of method from interface interA
return nameA;
}
public String getNameB(){ ---- impl method from interface interB
return nameB;
}
public String getOwnString{ ---- own method
return ownString;
}
}
Another class, MyBiggerClass has MyClass as its attribute:
class MyBiggerClass {
private MyClass myClass;
public MyClass getMyClass(){
return myClass;
}
}
In a rule, I use MyBiggerClass as follows:
$mybig : MyBiggerClass()
eval($mybig.getMyClass().getNameB().equals("HelloWorld"))
The evaluation fails, and it said
unable to resolve method using strict-mode: interA.getNameB()
As you can see, the validator checks as if the getNameB was a method of
interA (the first interface).
I'm wondering whether this is a bug, or do I have to somehow change the
structure of my class.
But the question is, why does it check the interfaces not the class itself?
Thanks for advices
Regard
bb
--
View this message in context: http://www.nabble.com/Validation-in-Guvnor-fails-due-to-unrecognized-meth...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 5 months
Drools User Group Meeting - London 17th of July
by Mark Proctor
Up to date details can be found here:
http://www.bsg.co.uk/Page.aspx?id=2924
14:15 -- 18.45, Friday 17th July, BSG House, London, EC1V
The next JBug is being held on Friday 17^th July. Attending the JBug at
BSG will be a fantastic opportunity to:
* Enhance your knowledge and skills through specialist speakers
talking about hot topics
* Share your knowledge with like-minded people
* Network and Socialise
The JBug is a regular gathering of JBoss Professional and other Open
Source product users, developers, technical managers and architects. It
provides a forum that enables users and customers to get together and
discuss new technologies, development methodologies, interesting use
cases and similar technical topics. At each meeting, different speakers
will present on topics that can be suggested by the group.
The agenda for the JBug has now been finalised and it will focus on open
source business rules management system and JBoss BRMS. Presentations
include:
* BRMS Platform 5 Key Note - Mark Proctor, Worldwide JBoss Rules Lead
/State of the Union, Future State/
* BRMS Platform 5 Interactive - Graham Gear, JBoss Solutions Architect
/Simple walk through of using the BRMS Platform/
* BRMS Platform 5 Use Case - BSG
Please click here <http://www.bsg.co.uk/page.aspx?ekfrm=1798> to
register your place at this event.
15 years, 5 months
Comparing multiple accumulations
by Richard Sherman
First I'm new to drools and secondly where I'm working we're using version 4.0.7.
I have a list of accounts and each account contains a list of transactions. I wish to accumulate charge transactions and compare them to an accumulation of payment transactions for a given time period (such as the last month). And it gets slightly more awkward in that if a payment transaction is of a certain type it needs to be converted from a 4 weekly figure to a monthly figure ( using / 4 / 7 * 365 / 12). I've tried to use structures as follows but they are causing the then part of the rule never to fire.
rule "Account in arrears"
salience 10
no-loop
when
$acc : Account( // balance between £500 and £1000
accountBalanceInPence >= 50000 &&
accountBalanceInPence <= 100000
)
$s : MessageInfo( accountNumber == $acc.accountNumber )
Number($charges : intValue) from
accumulate(
(Transaction(
transactionDate > oneMonthAgo &&
amountInPence > 0 &&
$value : amountInPence)
from $acc.transactions),
sum($value)
)
Number($adjustment : intValue) from
accumulate(
(Transaction(
transactionDate > oneMonthAgo &&
amountInPence < 0 &&
transactionCode == "Type 1" &&
$value : amountInPence)
from $acc.transactions),
sum(($value / 4 / 7 * 365 / 12) - $value)
)
Number( intValue > ($charges + $adjustment)) from
accumulate(
(RentTransaction
(transactionDate > oneMonthAgo
$value : amountInPence)
from $acc.transactions),
sum($value)
)
then
$s.setMessage( "Account in arrears" );
update($s); // flag update
end
Thanks
Richard
_________________________________________________________________
With Windows Live, you can organise, edit, and share your photos.
http://clk.atdmt.com/UKM/go/134665338/direct/01/
15 years, 5 months
classLoader issue...
by Jason Davidson
I'm getting this error message too. I'm running Drools 5.0.1 as a
bundle within an OSGi container. Like the parent post indicates it
worked with Drools 4.0.7 and it only happens when I put constraints on
fact fields.
Here's my stack:
Root exception:
java.lang.NoClassDefFoundError: org/drools/base/extractors/
BaseObjectClassFieldReader
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at org.drools.base.ClassFieldAccessorCache
$ByteArrayClassLoader.defineClass(ClassFieldAccessorCache.java:367)
at
org
.drools
.base
.ClassFieldAccessorFactory
.getClassFieldReader(ClassFieldAccessorFactory.java:135)
at org.drools.base.ClassFieldAccessorCache
$CacheEntry.getReadAccessor(ClassFieldAccessorCache.java:315)
at
org
.drools
.base
.ClassFieldAccessorCache.getReadAcessor(ClassFieldAccessorCache.java:
245)
at
org
.drools.base.ClassFieldAccessorStore.wire(ClassFieldAccessorStore.java:
379)
at
org
.drools
.base.ClassFieldAccessorStore.merge(ClassFieldAccessorStore.java:270)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:
466)
at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:388)
at com.cjs.core.rules.RulesEngine.startEngine(RulesEngine.java:102)
at com.cjs.core.rules.RulesEngine.<init>(RulesEngine.java:44)
at com.cjs.core.rules.RulesEngine.getInstance(RulesEngine.java:58)
at
com
.cjs
.core
.rules
.RulesEngineServiceFactory.getEngine(RulesEngineServiceFactory.java:22)
at com.cjs.hazel.rules.test.Activator.start(Activator.java:21)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl
$1.run(BundleContextImpl.java:782)
at java.security.AccessController.doPrivileged(Native Method)
at
org
.eclipse
.osgi
.framework
.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:
773)
at
org
.eclipse
.osgi
.framework
.internal.core.BundleContextImpl.start(BundleContextImpl.java:754)
at
org
.eclipse
.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:
352)
at
org
.eclipse
.osgi
.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
at
org
.eclipse
.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:
1068)
at
org
.eclipse
.osgi
.framework
.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:
557)
at
org
.eclipse
.osgi
.framework
.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
at
org
.eclipse
.osgi
.framework
.internal
.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
at
org
.eclipse
.osgi
.framework
.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:
445)
at
org
.eclipse
.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:
220)
at org.eclipse.osgi.framework.eventmgr.EventManager
$EventThread.run(EventManager.java:330)
> Thanks for your answer !
>
> My configuration seems correct to me, I have all new jars in the
> classpath (the ones indicated in the file README-DEPENDENCIES.txt at
> the
> SVN trunk). I checked them all looking after another
> BaseObjectClassFieldReader class, but only drools-core contains it.
>
> By the way, rules are well compiled and executed, this issue only
> happens when I put constraints on fields. So I think if drools-core
> was
> not in the classpath, nothing would work at all...
>
> Le mercredi 01 juillet 2009 à 08:46 -0400, Edson Tirelli a écrit :
> >
> > It seems to me that the problem is not with the classloader of
> your
> > classes, but the classpath of the drools jars. Are you sure you
> > updated and have all the required new jars in your classpath?
> Drools 5
> > has a few new jars, like drools-api, that need to be available.
> Also,
> > check if there are any older jar still in the classpath that might
> be
> > clashing with the new jars.
> >
> > []s
> > Edson
> >
> > 2009/7/1 Julien Nicoulaud <julien.nicoulaud at bull.net>
> > Hi, I'm migrating my system from Drools 4.0.7 to Drools
> 5.1.0.
> > Now when I try to compile rules that check fact fields, I
> get
> > the
> > following exception:
> >
> > ERROR: EventDispatcher: Error during dispatch.
> > (java.lang.NoClassDefFoundError:
> > org/drools/base/extractors/
> BaseObjectClassFieldReader)
> > java.lang.NoClassDefFoundError:
> > org/drools/base/extractors/BaseObjectClassFieldReader
> >
> > ( http://paste2.org/p/296380 )
> >
> >
> > It seems the classloaders I pass to the configurations are
> not
> > taken in
> > account... I get exactly the same error if I do not specify
> > the
> > classloaders. Here is the code:
> > KnowledgeBuilderConfiguration kBuilderCfg =
> >
> >
> KnowledgeBuilderFactory
> .newKnowledgeBuilderConfiguration(null,classLoader);
> > KnowledgeBuilder knowledgeBuilder =
> >
> > KnowledgeBuilderFactory.newKnowledgeBuilder(kBuilderCfg);
> >
> > KnowledgeBaseConfiguration kbaseConfig =
> >
> >
> KnowledgeBaseFactory
> .newKnowledgeBaseConfiguration(null,multiBundleClassLoader);
> > kbaseConfig.setOption(EventProcessingOption.STREAM);
> > knowledgeBase =
> > KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
> >
> > On Drools 4, we did exactly the same with PackageBuilder
> > instead of
> > KnowledgeBuilder and RuleBase for KnowledgeBase. So the
> > classloaders I
> > pass are the good ones... Is there some trick ?
> >
> > Thanks for any help !
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> > --
> > Edson Tirelli
> > JBoss Drools Core Development
> > JBoss by Red Hat @ www.jboss.com
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 5 months
Drools SubFlow (Sub -Process) query API
by bdoshi
Hi,
I am new to drools and have following scenario and question.
Consider my main flow "A" (runtime instance id 111) which has and invokes
(subprocess)SubFlow "B" (runtime instance id 222).
Question,
Is there an API to find the list of subprocess (subflow) associated with
parent instance or parent process associated with a given subprocess?
e.g. in above case... From process instance 111 can we get handle or
information of 222
or
form process instance 222, can I get information of parent who created this
instance (111).
Thanks,
--
View this message in context: http://www.nabble.com/Drools-SubFlow-%28Sub--Process%29-query-API-tp24434...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 5 months
"Exists" CE behaviour
by Chivotario Martin
Hi ,
I'm trying to use the *Exists *keyword within my rules with the following
snippet :
// Create a session
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
((RuleBaseConfiguration)config).setRuleBaseUpdateHandler( null ); *
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
// Add some objects
for (int i=0; i<5; i++) {
session.insert(new Foo());
}
// Add a DRL to the kbase
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "test/existsTest.drl" ),
ResourceType.DRL);
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
// Fire rules
int fireCount = session.fireAllRules();
*existsTest.drl* :
rule "existsTest"
when
exists (Foo());
//not ( not ( Foo() ) ); (2)
then
System.out.println("Rule fired...");
end
When launched , the rule is not fired (no messages , fireCount 0), but it is
when changing
exists with a double not condition (2).
If the working memory is populated after adding the rules file, the exists
CE works as expected.
* I've used no RuleBaseUpdateHandler preventing automatic activations to be
executed so fireAllRules can be used to get the fireCount, but commenting
this line out doesn't change the results.
Probably i'm doing something wrong so a little help would be very
appreciated.
Regards,
Manuel.
15 years, 5 months
Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:
by Pardeep.Ruhil@lntinfotech.com
Hi,
I have set all the jars file in the classpath, but still m getting the
same exception.
The exception is caused by : Null pointer exception.
I am not able to understand why it is giving me this exception, while in
the mailing list I didn't found anybody having this
exception, everyone else I found has 'Class Not found Exception'.
This is my code snippet :
KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.
newKnowledgeBuilderConfiguration();
config.setProperty("drools.dialect.java.compiler", "ECLIPSE");
KnowledgeBuilder kbuilder =KnowledgeBuilderFactory.newKnowledgeBuilder(
config );
//KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(
"shopingdiscount.drl"), ResourceType.DRL);
This is my exception:
Drools config: unable to use the drools.compiler property. Using default.
It was set to:0
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:jav
:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153)
at
org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderProviderImp
.java:17)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:57)
a
.
.
.
.
Caused by: java.lang.NullPointerException
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:92)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270)
... 69 more
Am I missing anything that is to initialized , so that I can get through
this Null Pointer Exception.
Please help me to through of this situation. I am stuck in this.
Thanks & Regards
Pardeep Ruhil
______________________________________________________________________
15 years, 5 months
Sub flow : event : query
by Vikram Pancholi
Hi,
I am using version 5.1.0 Snapshot for compiler , api and core. My
requirement is as follows
1) Process A -- Main process --loops continuousy though a series of actions
/ splits and joins ...
there is a split constraint written which uses the level (mentioned
below).
2) Process B -- Sub process is as follows
1)Start
2)within process b, i m creating a timer task and sceduling it at say 1000
to insert a fact named Etrigger.
3)Event wait ;;-- waits for Etrigger
4)Increase the value of variable ..say level from 0 -> 1.
5)End the subprocess
But as soon as i insert the fact Etrigger looping of process A hungs up.
I tried using other options as well namely using fusion to insert the
Etrigger, but it doesnt expire even after giving expiry of 1 ms . And i
cannot confgure timer delay using a variable.
Thanks and Regards
*Vikram Pancholi*
15 years, 5 months