How do you use Ruleflows with StatelessSession's?
by Shahad Ahmed
Does anyone know if it's possible to use a ruleflow with a StatelessSession?
The current documentation and API seem to show examples with
StatefullSessions i.e.:
statefullSession.startProcess(id);
statefullSession.fireAllRules();
etc...
However, there doesn't seem to be anything equivalent in the API for
StatelessSesssion's. I'd really like to be able to use the new sequential
mode (i.e. with a StatelessSession) and ruleflow.
Regards,
Shahad
16 years, 9 months
How to write constraint about a Map inside a Map?
by Felipe Piccolini
Suppouse I have a Map attribute and one of the values is another
Map...how can I check a member of the inner Map?
class MyFact{
Map map;
public MyFact(){
this.map = new HashMap();
}
....setter and getter...
}
-- test --
MyFact myFact = new MyFact();
Map innerMap = new HashMap();
innerMap.put("innerKey", new String("InnerValue"));
Map map = new HashMap();
map.put("mapKey", innerMap);
myFact.setMap(map);
.... set the RuleBase and insert myFact as a fact for the
WorkingMemory...
-------
Now... how should I write the rule to check the innerKey ??
rule "test InnerMap"
when
$mf: MyFact( map['mapKey']['innerKey'] ==
"InnerValue" ) // doesnt work...
....
$mf: MyFact( map['mapKey'].this['innerKey'] ==
"InnerValue" ) // doesnt work...
$mf: MyFact( map['mapKey'].['innerKey'] == "InnerValue" ) //
doesnt work...
$mf: MyFact( $innerMap: map['mapKey'], $innerMap['innerKey'] ==
"InnerValue" ) // doesnt work...
$mf: MyFact( $innerMap: map['mapKey'] -> ($innerMap
['innerKey'] == "InnerValue" )) // doesnt work...
Thanks.
Felipe Piccolini M.
felipe.piccolini(a)bluesoft.cl
16 years, 11 months
Using JBoss Rules in cases where users need to add / remove rules
by Robert Burdick
Hello All:
I am trying to figure out if JBoss Rules will be suitable for my
application
needs. Maybe you can give some insight.
My application needs to implement / use a rules engine for evaluating
conditions and firing off events when those conditions are met. So far
this
sounds exactly like the sort of thing that JBoss Rules is for. The
twist is
that my application will also provide an administrative utility that
allows
admins to add or remove rules, as well as modify the conditions that
trigger
these rules. Can JBoss Rules be used to do this? All of the examples
I've
seen so far seem to incorporate rules whose consequences are fixes, but
with
changeable conditions. For example, there are lots of samples out there
like an insurance application. Such an example has consequences such as
offerQuote, turnDownCustomer etc. that don't change, but with conditions
that do change. For example, today offer quotes to all good drivers,
tomorrow change the rule to offer quotes to all good drivers over the
age of
18. The conditions change, but the basic actions in the system are
common.
What I think my requirement implies is a way to define rules with
conditions
and the corresponding consequences code at runtime. This seems to imply
that the application code needs to be dynamic, in order to allow users
to
define arbitrary consequence code. Has anyone ever tried to do
something
this generic with JBoss Rules, and better, can you fill me in on how to
go
about this?
Thanks, Robert
17 years
Agenda filter based on package name
by Hooman Mozaffari
It seems "Rule" class doesn't store its parent "Package" information and Rule.getPackage() always returns null.
I would like to create an AgendaFilter based on package name but there is no way to get the parent package of each rule.
Thanks,
Hooman
public class PackageNameAgendaFilter implements AgendaFilter {
private final String packageSuffix;
private final boolean accept;
public PackageNameAgendaFilter(String packageSuffix){
this(packageSuffix, true);
}
public PackageNameAgendaFilter(String packageSuffix, boolean accept){
this.packageSuffix = packageSuffix;
this.accept = accept;
}
public boolean accept(Activation activation) {
if(activation.getRule().getPackage().startsWith(packageSuffix))
return accept;
else
return false;
}
}
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
17 years, 1 month
Parameterized Queries?
by Robert Crawford
Does anyone know how to use parameterized queries? I'm trying to retrieve
ONLY the results for a single installation, with a query like this:
query "find errors for site"
validationError: ValidationError(this.siteId == $1)
end
QueryResults results = session.getQueryResults("find errors for site", new
Object[] {siteId});
I get the error
"org.drools.RuntimeDroolsException: Exception executing predicate
org.drools.base.mvel.MVELPredicateExpression
Caused by: org.mvel.PropertyAccessException: unable to resolve property: $1"
I'm pretty sure I'm not writing the rule correctly in the DRL; does anyone
know the correct syntax? The manual isn't clear on this.
Thanks!
17 years, 2 months
Drools 4.0 StateExampleWithDynamicRules Question
by Daren Chylinski
Hello,
I am a new Drools user working my way through the examples. To test my
understanding of how the rules work, I modified the
StateExampleUsingSalience.drl file used in the
StateExampleWithDynamicRules example. The result of my change
conflicted with my understanding of how the rules should work.
I made two modifications in the StateExampleUsingSalience.drl file. The
two modifications (shown below) are the commenting out of the two lines
in the RHS portion of the "B to D" rule. My understanding of how this
would affect the result was: because the "D" State object never changes
state to "State.FINISHED" the RHS portion of the "D to E" rule (shown
below) would not execute because the first pattern in the LHS would fail
to find a State object in working memory that met the criteria of the
constraint groups defined within it.
My question is: Why does the "D to E" rule in the
StateExampleDynamicRules.drl execute the statements in the RHS portion
of the rule?
>From StateExampleUsingSalience.drl: My changes in this file are the two
lines commented out in the RHS portion.
rule "B to D"
when
State(name == "B", state == State.FINISHED )
d : State(name == "D", state == State.NOTRUN )
then
//System.out.println(d.getName() + " finished" );
//d.setState( State.FINISHED );
end
>From StateExampleDynamicRules.drl: This is the rule where I expected
the RHS portion to NOT get executed because there aren't any State
objects in working memory that have their name == "D" and its state ==
State.FINISHED because the setState( State.FINISHED ) was never executed
on the "D" state object.
rule "D to E"
when
State(name == "D", state == State.FINISHED )
e : State(name == "E", state == State.NOTRUN )
then
System.out.println(e.getName() + " finished" );
e.setState( State.FINISHED );
end
After my modifications, the output was:
A finished
B finished
C finished
E finished
I did not expect the "E finished" message to be printed.
Regards,
Daren
17 years, 2 months
Package.clear() doesn't clear RuleFlows
by ekke
there's no comment in JavaDoc, but I think a clear() on a Package
should clear all Rules and all RuleFlows.
but: after clear() the Rules went away, but the RuleFlows are still there.
I tested the behaviour with
....getPackage().getRules().length;
....getPackage().getRuleFlows().size();
getRules().length was Zero as expected
getRuleFlows().size() was 1 as before the clean
then I tried
.....removeRuleFlow("myID");
but its still there.
should I open a JIRA ?
ekke
--
View this message in context: http://www.nabble.com/Package.clear%28%29-doesn%27t-clear-RuleFlows-tf452...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 2 months
Re: [rules-users] how to specify classpath dependencies in .drl files.
by Mark Proctor
Godmar Back wrote:
> I agree that it may not belong into the .drl file, though loading
> bytecode through the classloader via getResourceAsStream() also seems
> a rather ad-hoc solution.
>
>
I've already told you, that you are mistaken here. You do not need to
keep bytecode hanging around, and available via getResourceAsStream()
for any compilation to work. I can generate a class at runtime, in
memory, add it to a classloader and have the engine compile against it
without getResourceAsStream() being able to search for and return the
.class' bytecode.
> Some module system that allows the bundling of class and rules into
> modules, and the specification of dependencies between them, is
> clearly needed.
>
>
Yes in the rule agent and the deployment configuration properties system.
> - Godmar
>
> On 9/26/07, Mark Proctor <mproctor(a)codehaus.org> wrote:
>
>> Godmar Back wrote:
>> On 9/26/07, Mark Proctor <mproctor(a)codehaus.org> wrote:
>>
>>
>> Simple add the class at runtime to a classloader and use that classloader
>> as
>> the root classloader of the packagebuilder.
>>
>>
>> This would work if the class loader I provide implements
>> getResourceAsStream to match its behavior in loadClass (which most
>> class loaders do) - so you are correct here.
>>
>> The problem, however, is that I don't know which .jar files to include
>> in that class loader's path, *unless* I keep track of these .jar files
>> elsewhere - say in a configuration file, as a command line switch, or
>> by hardwiring it in my code.
>>
>> My proposal is to allow the user to specify the location of these jar
>> files in the .drl file, which a special classloader would then
>> automatically include as it encounters this declaration in the .drl
>> file.
>>
>> - Godmar
>>
>>
>> I don't think DRL files should be hard coded to Jars, I would rather see
>> this configuration else where. What you are talking about is deployment
>> configuraiotn issus, which is a difference concern and belongs in something
>> more like the RuleAgent. I beleve there are already plans to allow the
>> RuleAgent to specify locations to lookup classes at runtime.
>>
>> Mark
>>
>>
>
>
17 years, 2 months
Re: [drools-user] 4.0.2
by Brian Enderle
Has this been released? I looked on the Download page today and only 4.0.1
from Aug 30th is available. Is it only available thru SVN?
Thanks,
Brian Enderle
17 years, 2 months
classpath issue
by Krishnan
I am including the following libraries :-
D:\programs\java\jdk1.5.0\bin\javaw -classpath
"O:\fieldstation\jars\antlr\antlr-runtime-3.0.jar
;O:\fieldstation\jars\Drools\drools-compiler-4.0.0.jar
;O:\fieldstation\jars\Drools\drools-core-4.0.0.jar
;O:\fieldstation\jars\Drools\drools-decisiontables-4.0.0.jar
;O:\fieldstation\jars\Drools\drools-jsr94-4.0.0.jar
;O:\fieldstation\jars\mvel\mvel14-1.2rc1.jar
;O:\fieldstation\jars\janino\janino-2.5.7.jar" -Ddrools.compiler=JANINO
com.makesys.fs.app.adapter.AdapterServerWrapperImpl
I have included all the drools libraries, antlr library, janino library and
mvel library. I have also included the option to specify the JANINO
compiler. I have not done any code change to imply
janino compiler (Is this needed ?)
Below is the stack trace I get
EXCEPTION [org.drools.RuntimeDroolsException: Unable to load dialect '
org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java']
STACK [org.drools.RuntimeDroolsException: Unable to load dialect '
org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(
PackageBuilderConfiguration.java:138)
at org.drools.compiler.PackageBuilderConfiguration.init(
PackageBuilderConfiguration.java:114)
at org.drools.compiler.PackageBuilderConfiguration.<init>(
PackageBuilderConfiguration.java:87)
at com.makesys.fs.is.cfi.CfiRulesLoader.getPackageBuilder(
CfiRulesLoader.java:45)
at com.makesys.fs.is.cfi.CfiRulesLoader.loadRuleFiles(
CfiRulesLoader.java:54)
at com.makesys.fs.is.cfi.CfiRulesLoader.createRules(CfiRulesLoader.java
:37)
at com.makesys.fs.is.cfi.CfiAdapter.collectHelper(CfiAdapter.java:469)
at
com.makesys.fs.is.cfi.Cisco.showCmds.ipRoute.CfiAdapterShowIpRoute.collect(
CfiAdapterShowIpRoute.java:38)
at com.makesys.fs.app.adapter.BaseAdapterWithArchiveInfo.activate(
BaseAdapterWithArchiveInfo.java:106)
at com.makesys.fs.app.adapter.UnicastAdapterImpl.activate(
UnicastAdapterImpl.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java
:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(
TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in
the classpath
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(
JavaDialectConfiguration.java:98)
at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(
JavaDialectConfiguration.java:56)
at org.drools.compiler.PackageBuilderConfiguration.buildDialectRegistry(
PackageBuilderConfiguration.java:134)
... 20 more
]
Any help will be appreciated.
TIA,
Krishnan.
--
Sivaramakrishna Iyer Krishnan (Anand)
Never assume the obvious is true.
- William Safire
17 years, 2 months