Re: [rules-users] string replace collision problem
by FrankVhh
Cautionç This is answered after only a quick look.
You must notify the engie that a change has occured by calling update(plan);
in the RHS. Not calling update will modify the object, but the engine will
not take these changes into account.
Regards,
Frank
fiitkar wrote:
>
> Hello,
>
> I've problem with string replacement.
> See the following example.
> Input string: SF
> I've written two simple rules:
> The first one transforms SF to S
> The second one transforms S to VOL.
> The expected output after the transformation should be S, but I get VOL.
> (as for example for the rules: A->Z, Z->K, input A, output will be Z and
> not K).
> So my question is how to avoid this problem (I suppose the problem is that
> the first transformation returns substring of the input and moreover does
> exist another transformation rule for it).
>
> rule "Rule1 for parameter 1"
> salience 2
> when
> plan : plan( parameter1 matches ".*SF.*" )
> then
> plan.setParameter1(plan.getParameter1().replace("SF","S"));
>
> end
>
>
> rule "Rule2 for parameter 1"
> salience 1
> when
> plan : plan( parameter1 matches ".*S.*" )
> then
> plan.setParameter1(plan.getParameter1().replace("S","VOL"));
> end
>
> Thank you for your response.
> Peter
>
--
View this message in context: http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
loading rules and drools classes via URLClassLoader
by ukriegel
Hi there,
we tried to use drools jars from an url:
1. define an URLClassLoader with all the urls of the necessary drools jars
in the search path.
2. initialize a KnowledgeBaseConfiguration with that class loader
KnowledgeBaseConfiguration knowledgeBaseCfg = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration(null, dcURLClassLoader);
3. initialize a KnowledgeBase with that configuration
KnowledgeBase kbase = KnowledgeBaseFactory
.newKnowledgeBase(knowledgeBaseCfg);
4. initialize a KnowledgeBuilderConfiguration with that class loader
KnowledgeBuilderConfiguration knowledgeBuilderCfg =
KnowledgeBuilderFactory
.newKnowledgeBuilderConfiguration(null, dcURLClassLoader);
5. initalize a knowledge builder
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbase,
knowledgeBuilderCfg);
6. adding a knowledge resource to that builder results in a
org.drools.RuntimeDroolsException "Unable to load dialect
org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java" if the
drools jars are not in the start class path.
Did we something wrong or uses drools while adding ressources a classloader
different from that given in the configuration?.
Thanks in advance
Ulrich
--
View this message in context: http://drools.46999.n3.nabble.com/loading-rules-and-drools-classes-via-UR...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Drools server => get a query result
by jcp
Hi, i'm new to drools so excuse me if i'm asking newbie question.
For a project I insert via rest service a list of object to drools server,
in a stateless session - no need to use a stateful session.
The rules are fired and new objects are inserted.
ex :
rule "1"
when
$c : condition()
then
insert(new FiredRule("my rule 1 fired", $c))
end
I also have a query who gets all the FiredRule
query "get fired rules"
firedRule : FiredRule()
end
My problem is that i can't get results from query when i'm in stateless
mode.
It works in stateful mode, but I need drools to work only with object I send
via rest service at time t. I don't want them store in in the knowledge base
and be reused for a future request.
I'm block here.
I send via json the batch-execution command with "insert-elements" and
"query" => "name":"get fired rules","out-identifier":"rules"
and I have an Exception when I set an out-identifier to "fire-all-rules"
11:26:00,552 ERROR [DefaultErrorHandler] Failed delivery for exchangeId:
949a5873-d146-4ad3-bc9c-d0dd9f7bbc81. Exhausted after delivery attempt: 1
caught: java.lang.NullPointerException
java.lang.NullPointerException
at
org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:110)
at
org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:32)
at
org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
at
org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:265)
at
org.drools.camel.component.DroolsExecuteProducer.process(DroolsExecuteProducer.java:100)
When I test my case with java, I can get my query results, so I am led to
think that it is a problem on server side, maybe jars in the lib???
Or is it impossible to set an out-identifier for fire-all-rules in stateless
mode?.
Another consideration were to dispose each knowledgesession (on stateful
mode) when I send request to drools, but there is no command to do that,
only stop/restart server???
Subsidiary question : is it possible to add a System.out.println() in my
query??If yes, how to do it?
Thank you for your help
JC
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-server-get-a-query-result-tp3512...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
Operation of "otherwise" in Decision Table (Guided editor) of Guvnor
by Manohar Kokkula
Hi All,
I am new to Guvnor,
Please can any one explain me the uses of "otherwise" in Decision
table(Guided editor) with simple example ?
Thanks and regards
Manohar Kokkula
Mailto: manohar.kokkula(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
14 years, 5 months
No rules loaded when reading package from Guvnor
by sgo
Hello all,
I'm a semi-beginner with Drools and am having an issue I haven't found
reported elsewhere.
I have a package defined in Guvnor, with model imported from JAR, one
global, a dozen rules and a couple of test scenarios. The package is loaded
from the binary published by Guvnor via a knowledge agent into my stateless
session (defined in Spring beans), but no rules ever fire. (Note that rules
do fire as expected in my Guvnor test scenarios.) When investigating in
debug mode, I see the package is properly loaded, with imported type
definitions and global, but no rule is in there! The package's rules table
is empty and I really have no clue why (I initially thought my rule
definitions could be the cause and created a minimal test package with just
one simple rule but with no success.)
Could anyone point to possible causes for this?
Many thanks in advance.
Simon
--
View this message in context: http://drools.46999.n3.nabble.com/No-rules-loaded-when-reading-package-fr...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months
How to handle generics in Drools?
by Martin A
Hello,
In my rules file I'd like to set something like this:
rule "mayThrowDice"
when
$user : User($gp : gameplay)
$gameplay(this == $gp)
then
exists List<Boost>() {
..... some business logic
}
end
But it looks like there is no generics support. How can I make sure there is
a List of type Boost inserted into the session?
Thank you,
Martin
14 years, 5 months
drools stateful session, cluster and replication
by Rules
>From the documentation i understand that statefulknowledge session can be
persisted.
Can we also replicate the session/working memory across servers and still be
able to maintain the integrity of facts and rete tree ?
Is there a way i could replicate asserted facts incrementally or do i have
to replicate the entire session each time (i consume events from external
systems that could bring in new facts and alter existing facts) ?
I am considering an app server provided replication that uses multi
casting/uni casting and i will have a lot of data in working memory, around
3 GB. what are my options if i want to replicate it across cluster ?
Appreciate any help...
--
View this message in context: http://drools.46999.n3.nabble.com/drools-stateful-session-cluster-and-rep...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 5 months