Ordered lists in drl
by LCode
I am trying to write a rule via the guided rule editor and (again!!) I am
really struggling.
The following is a simplified explanation of my scenario:
I have a model where there is one 'Supermarket' object which has a list of
integers 'locationID'. Elsewhere I have another list of 'Place' objects,
each of which has an integer locationReference.
Something like this....
<Supermarket name = 'asda'>
<LocationID>21</LocationID>
<LocationID>18</LocationID>
<LocationID>19</LocationID>
</Supermarket>
<Places>
<Place>
<LocationReference>21</LocationReference>
</Place>
<Place>
<LocationReference>18</LocationReference>
</Place>
<Place>
<LocationReference>19</LocationReference>
</Place>
</Places>
I need to write a rule that fires when the *order* of locationIDs does not
match the order of the locationReferences. So the above example would be
fine but the model below would not...
<Supermarket name = 'asda'>
<LocationID>18</LocationID>
<LocationID>21</LocationID>
<LocationID>19</LocationID>
</Supermarket>
<Places>
<Place>
<LocationReference>21</LocationReference>
</Place>
<Place>
<LocationReference>18</LocationReference>
</Place>
<Place>
<LocationReference>19</LocationReference>
</Place>
</Places>
I know that drools does not consider the order of facts in the model,
however since both facts are java.util.Lists I wonder if it possible to
compare the elements at position 0, 1, 2 etc. I am afraid my drl skills are
really not up to scratch.
Any thoughts?
--
View this message in context: http://drools.46999.n3.nabble.com/Ordered-lists-in-drl-tp3519453p3519453....
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Knowledge Base Agent : getLastModified
by Vishwanath Dubey
Hi,
It seems Rule Agent does not check does not provide credential to get last
modified time for a snpashot of a package and also on Guvnor side no
security check is provided when last modified time is retreived for the
snapshot of respective package.
Relevant security check is only provided when agent downloads the snapshot.
I do not know why it is so, but security check is provided for any request
of resource to the server.
Thanks,
V
13 years, 1 month
Can't open bpmn from Visual Editor in Process Editor
by ANJALI
I hope to fill in the properties not yet handled in the Visual Editor with
the Process Editor.
A workflow created with the Visual Editor that contains Rule Tasks throws an
exception when opened in the Process Editor "An exception occurred while
reading in the RuleFlow XML: No messages found See the error log for more
details". Where is the error log and how do I fix the xml in a text editor?
Another error when opening with the Process Editor is a Gateway direction is
unspecified. I set Gateway directions in the Visual Editor to Diverging and
Converging, save the file, but the properties view shows it goes back to
Unspecified.
Could any one help me??
Thanks in advance,
Anjali
--
View this message in context: http://drools.46999.n3.nabble.com/Can-t-open-bpmn-from-Visual-Editor-in-P...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Exclude certain rules
by icechunk
I am trying to validate an incoming set of application forms. Each form has
a number of validations that apply. But there could be special cases where
certain rules need to be excluded. The exclusions are based on certain
conditions that will vary at runtime and will need to be stored in the
database (if from type x and user is y then exclude rule z).
Is there a graceful way of handling this? I am thinking of inserting a
Metadata fact into the session that has the rules that need to be excluded.
Rules will then check if they are to be excluded in LHS. Would this work?
--
View this message in context: http://drools.46999.n3.nabble.com/Exclude-certain-rules-tp3517185p3517185...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
Inadvertant type conversion while using keyword "in"
by TroyL
We ran into an issue when evaluating string values against a list of values
while using the keyword "in".
We find that when there is a decimal place in the string value and either
the fact inserted into the session or the string values in the list end with
a zero, the string will be truncated, as if it were being type converted
from a string to an int.
As as example: Fact type "Test"
package com.sample;
public class Test {
private String code;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
Sample DRL:
package com.sample
//Test code value == "1.5"
rule "Incorrect Execution"
when
Test($code : code in ("1.50"))
then
System.out.println("Unexpected execution: 1.50, 2.50 - actual code
value: 1.5");
end
//Test code Value == "1.5"
rule "Correct Execution"
when
Test(code == "1.5")
then
System.out.println("Expected execution - Code compared values: 1.5,
2.5 - actual code value: 1.5");
end
We insert a "Test" fact into the session with a code value of 1.5. The
output is as follows:
Unexpected execution: 1.50, 2.50 - actual code value: 1.5
correct execution - Code compared values: 1.5, 2.5 - actual code value: 1.5
Drools Expert documentation states:
Type coercion is always attempted if the field and the value are of
different types; exceptions will be thrown if a bad coercion is attempted.
For instance, if "ten" is provided as a string in a numeric evaluator, an
exception is thrown, whereas "10" would coerce to a numeric 10. Coercion is
always in favor of the field type and not the value type:
Both evaluators are actually syntactic sugar, internally rewritten as a list
of multiple restrictions using the operators != and ==.
Is there some way to disable the auto-conversion feature?
--
View this message in context: http://drools.46999.n3.nabble.com/Inadvertant-type-conversion-while-using...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 1 month
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.
13 years, 1 month
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.
13 years, 1 month
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.
13 years, 2 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
13 years, 2 months