Identity Mode?
by rjr201
If I have a rule such as:
When
Person()
Person()
Then
System.out.println("There are two people!")
End
I only want this to fire if there are two (or more) Person objects inserted
into the session, however as default drools will fire even when there is
just one Person object inserted (i.e. both Person patterns get matched to
the same fact).
I seem to remember there is a flag I can set that swaps between these two
types of behavior, and seem to remember it's to do with Identity/Equality
mode. However, I can't remember how or where to do this.
Any help on this would be greatly appreciated..
Cheers,
Rich.
P.S I realise that I could add constraints to the patterns to explicitly
check that the facts aren't the same.. however I'd rather not have to do
that as I'm trying to make it as simple as possible for users to create
rules..
--
View this message in context: http://drools.46999.n3.nabble.com/Identity-Mode-tp4024428.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Available rule stores
by Florian Pirchner
Hi,
i know that guvnor can be attached to drools core by KnowledgeAgent.
Is there a way to attach a git repository too? Could see in standalone
jbpm designer that rules and bpms have been loaded by git.
Thanks, Florian
12 years, 10 months
Moving rules from DB to a rules engine
by mohan.radhakrishnan@polarisft.com
Hi,
This is my first post. We have a facility in our Java web
application to upload SQL queries to the Oracle DB. These queries are not
controlled or audited. There are queries the are several pages long. Some
of these queries are configured to fire one after the other to approve our
workflow. When our workflow fires these query rules create an enormous load
on the system.
My concern at this time is that we are using the DB as a primitive and
uncontrolled rules engine. I am interested in using a proper rules engine.
What should my approach be ? Can I look at case studies or just Drools
documentation ?
Thanks.
This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.
Visit us at http://www.polarisFT.com
12 years, 10 months
Possible issue regarding 'accumulate' and 'collect' conditions
by Álvaro Pantoja
Hello
I switched recently from Drools 5.5.0 to Drools 6.0.0.Beta3 and some of
my rule tests failed because Drools started doing weird things.
I've isolated the problem and I figured out that it has to do with the
combination of "accumulate" and "collect" conditions in the same rule.
See this example here:
> import java.util.ArrayList
>
> declare Item
> code: int
> price: int
> present: boolean
> end
>
> rule "Init"
> when
> then
> insert(new Item(1,40,false));
> insert(new Item(2,40,false));
> insert(new Item(3,40,false));
> insert(new Item(4,40,false));
> end
>
> rule "CollectAndAccumulateRule"
> when
> //At least two items that aren't presents
> objList: ArrayList(size>=2) from collect( Item(present==false))
> //Total price bigger than 100
> price: Number(intValue>=100) from accumulate( Item($w:price,
> present==false), sum($w))
> then
>
> System.out.println("Sum: "+price);
> System.out.println("Items size: "+objList.size());
>
> //Look for the minor price item
> Item min = null;
> for(Object obj: objList){
> if (min!=null){
> min = (min.getPrice()>((Item)obj).getPrice())?(Item)obj:min;
> }
> else {
> min = (Item)obj;
> }
> }
>
> //And make it a present
> if (min!=null){
> modify(min){setPresent(true)};
> }
> end
It gets a list of items, and when exist at least two of them and the sum
of its prices is bigger than 100, it makes a present of the cheapest
one. For this, items have a "present" flag that gets activated when it
becomes a present. Also, this flag is part of both "collect" and
"accumulate" conditions, for the rule not to loop over already
"presented" items.
So, having 4 items with price 40 each (rule "Init" insert them),
expected result is to have 2 presents of price 40. Rule
"CollectAndAccumulateRule" gets executed two times and loop stops when
there are just two remaining items, with sum 80 (<100). Expected output
would be:
Sum: 160.0
Items size: 4
Sum: 120.0
Items size: 3
This works fine in Drools 5.5.0, but not in 6.0.0.Beta3. In the latter
rule "CollectAndAccumulateRule" gets called 3 times, and output is like
this:
Sum: 160.0
Items size: 4
Sum: 120.0
Items size: 4
Sum: 120.0
Items size: 3
Is there some overall change in 6.0.0.Beta3 that affects this kind of
rules or conditions? Or could this be an issue?
Furthermore, including this kind of rules in a package along with other
no-conflictive rules, it makes the hole package start behaving
unexpectedly. I guess it has to do with the way of the Rete tree is
bulided when this kind of rules are present.
Note: I know there are alternatives and workwarounds to the scenario
shown here (like merging both conditions into a single "accumulate").
Nevertheless the aim of this post is just to try to determinate wheter
this must be considered an issue or not
Regards,
--
Alvaro
12 years, 11 months
How to display Knowledge base / DRL
by dfreeman@gio.com.au
Hi, I'm fairly new to Drools and am loading an Excel spreadsheet decision
table into a Knowledge base. This works but I have problems when I fire the
rules. Under the older Rulebase model it seemed fairly simple to display the
generated DRL. I am having problems with my current task and feel it would
be helpful if I could see the generated rules. I'm assuming this is the best
approach. Any help would be appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-display-Knowledge-base-DRL-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
MultiValueRestriction
by droolster
Hello,
I saw the following in the "Design Patterns for PRS system" pdf and could
not understand the difference between the two statements (they look the same
to me). Please can the community clarify what the difference is:
A multiple choice could be written using the same syntactic form, e.g.,
Type( strField == "Huey" || == "Dewey" || == "Louie" )
but if you are testing for equality, the MultiValueRestriction is to be
preferred, so that the preceding
pattern is better written as
Type( strField in ( "Huey", "Dewey", "Louie" ) )
Thank you,
Iftikhar
--
View this message in context: http://drools.46999.n3.nabble.com/MultiValueRestriction-tp4024384.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
Is "modify" available from the Java API?
by Thomas Grayson
In the RHS of a rule one can use either an "update" or "modify" block to notify Drools that a fact has changed. In the Java API for 5.5.0 Final, I can call StatefulKnowledgeSession.update(factHandle, object) to update a fact handle with an object. However, there's no complementary StatefulKnowledgeSession.modify method. Is there a way to get modify's property-reactive functionality through the API? That is, can Java code update fact objects and then inform Drools that only certain properties have been changed? This capability would allow just the rules that reference those properties to be reevaluated, unlike update, which causes all the rules that reference the Java class to be reevaluated.
There is a CommandFactory.newModify method, but the JavaDoc<http://docs.jboss.org/drools/release/5.5.0.Final/knowledge-api-javadoc/or...> has no explanatory text. I explored the source to understand how this is used, and it appears that it is meant to be passed a list of Setter objects that contain literal bean property names and string values which are then dynamically interpreted by MVEL. It might be possible to use this in a pinch, but it seems a rather roundabout way to update an object that the code can access directly.
Thanks,
Tom
12 years, 11 months
Using GetObjects command with ObjectFilter attribute in Drools-Server
by le_zurdo
In the Drools Integration User Guide there is an example to create XML
commands which can be used with Drools Server.
The documentation of the GetObjectsCommand specifies that you can set an
ObjectFilter to filter the objects returned:
GetObjectsCommand
<http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-integration-d...>
However, the documentation does not specify the format that must be used to
include the ObjectFilter.
I have tried creating an XML directly from a GetObjectsCommand object using
Xstream which results in the following XML command:
*<org.drools.command.runtime.rule.GetObjectsCommand>
<filter class="org.drools.runtime.ClassObjectFilter">
<clazz>com.sample.models.EstadoInformacional</clazz>
</filter>
</org.drools.command.runtime.rule.GetObjectsCommand>
*
Which is different from the xml format used in the User Guide. The command
works well with Drools Server, but it doesn't filter objects:
*<?xml version='1.0' encoding='UTF-8'?><execution-results><result
identifier="objects"><list><com.sample.models.Rol><rol>rol1</rol></com.sample.models.Rol><com.sample.models.EstadoInformacional><id>id1</id></com.sample.models.EstadoInformacional></list></result></execution-results>
*
I have also tried to modify the command used in the Drools User Guide
without success:
*<batch-execution lookup="ksession1">
<get-objects out-identifier="objects">
<org.drools.runtime.ClassObjectFilter>
<clazz>com.sample.models.EstadoInformacional</clazz>
</org.drools.runtime.ClassObjectFilter>
</get-objects>
</batch-execution>*
So my question is: What is the format to use an ObjectFilter with the
GetObjectsCommand?
--
View this message in context: http://drools.46999.n3.nabble.com/Using-GetObjects-command-with-ObjectFil...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 11 months
Rule Templates - Conditionally Generate Rule based on Values in Data
by Jason Allen
All,
I saw this question was asked a couple of months ago with no reply, but thought I would try again.
In using a Rule Template, I'm trying to determine a way to dynamically generate rules based on a value in the data.
There is a data set, that has various pieces data, depending on a column value, the rule that is generated is relatively different. Different enough that I wouldn't want the generated a rule for each row of data, because many of the rules generated would never fire.
In the drools expert docs, it lists under 6.1.7 Rule Templates the ability to "conditionally generate rules based on the values in the data", but I can't seem to find the syntax for how to do that.
Does anyone know the answer to this?
I would picture it looking something like this
if ("@{RevenueCode}" == "NR")
rule "RevenueMapperRule_1"
when
claim1 : ClaimFact (ProgramType in ("FC", "FCP", "FALSE", "FALSE"),
ProcedureCode == "NR",
(serviceBegin >= "01-Oct-2003" && serviceBegin <= "31-Dec-2030"),
modifier1 in ("U"),
typeofBill == "3");
then
claim1.setResultSPCCode("507.11");
list.add(claim1);
end
end if
Essentially, the only time this rule would be generated is if RevenueCode in the Rules Spreadsheet had a value of "NR".
If this is not possible, how should I be thinking about this problem? Feels weird to generate a bunch of rules that will never fire, simply because there is no way to conditionally generate a rule. Maybe the answer is to create separate rule files and template definitions? That also feels like an over complication.
Thoughts?
Thanks in advance!
12 years, 11 months