Re: [rules-users] Help needed - Problems with forall operator
by Tom.E.Murphy@wellsfargo.com
Thanks, everyone, for your insightful responses. You've made my day...
Tom Murphy
Business Process Consultant
Wells Fargo HCFG - CORE Deal Decisioning Platform
800 S. Jordan Creek Parkway | West Des Moines, IA 50266
MAC: X2301-01B
Office: 515 324 4853 | Mobile: 941 320 8014
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
----------------------------------------------------------------------
Message: 1
Date: Sat, 7 Nov 2009 09:55:37 +0100
From: Wolfgang Laun <wolfgang.laun(a)gmail.com>
Subject: Re: [rules-users] Help needed - Problems with forall operator
To: Rules Users List <rules-users(a)lists.jboss.org>,
ed.tirelli(a)gmail.com
Message-ID:
<17de7ee80911070055k2469051agfebf3a5be24c7165(a)mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Here's the explanation why Tom's version does not work. The first pattern of
a "forall" defines the domain, which is: all CreditReport facts; for each
object in this domain, the remaining patterns must match; since the FICO
pattern merely ascertains the existence of a single FICO chained to a parent
CreditReport with validScoreIndicator false, it fires as soon as there is
one for each of the existing CreditReports.
Jared's solution has the CreditReport CE in front of the forall, unadorned
with any quantifier, and the innate behavior of Drools makes sure that the
hole thing will be tried, once, for any existing CreditReport anyway. Then,
the forall domain is now FICOs with that CR's id and valid == false - but
what is the CE? I guess that Drool's behavior is somewhat off the
definition, using just FICO() - i.e., all existing FICO objects - as the
domain. (However, I think that Edson changed this recently for 5.1.0.) Thus,
Jared's rule indeed fires only when all FICOs are linked to the CreditReport
are false, but it fails to do so as soon as there is at least one other FICO
with either a different parent, or valid.
Therefore, to be on the safe side with multiple CreditReport facts and
assorted FICO's being in WM at the same time, I propose this rule:
rule "somerule2"
when
report: CreditReport( $parentCreditReport_1_Id : myId)
forall ( $f : FICO( parentId == $parentCreditReport_1_Id )
FICO( this == $f, validScoreIndicator == false) )
then
System.out.println("somerule2 fired on " + $parentCreditReport_1_Id );
end
Here, the domain is explicitly given as all FICOs of the current CR; and for
all of them valid must be false.
Still, this solution is not perfect: It would also fire in the absence of
any FICO for some CR. To fix this, add a guard against there being no FICOs
for the current CR:
report: CreditReport( $parentCreditReport_1_Id : myId)
exists FICO( parentId == $parentCreditReport_1_Id )
forall ( $f : FICO( parentId == $parentCreditReport_1_Id )
FICO( this == $f, validScoreIndicator == false) )
To complete the picture, one might equally well use the negation of forall,
which would have to be propagated into the predicate (read '|' as "so
that"):
forall x in D | P(x) => not existst x in D | not P(x)
Now the condition delimiting the domain and the negated predicate can be
merged again into one CE:
rule "somerule3"
when
report: CreditReport( $parentCreditReport_1_Id : myId)
exists FiCo( parentId == $parentCreditReport_1_Id )
not ( exists FiCo( parentId == $parentCreditReport_1_Id, validScore ==
true) )
then
System.out.println("somerule3 fired on " + $parentCreditReport_1_Id );
end
-W
On Fri, Nov 6, 2009 at 9:45 PM, Jared Davis <sunray(a)davisprogramming.com>wrote:
> I think this usage may work for your case.
>
> rule "somerule"
> when
> report: CreditReport( $parentCreditReport_1_Id : myId)
> forall (
> FICO( parentId == $parentCreditReport_1_Id, validScoreIndicator ==
> false)
> )
> then
> System.out.print("Fired on " + $parentCreditReport_1_Id );
> end
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
16 years, 6 months
Help needed - Problems with forall operator
by Tom.E.Murphy@wellsfargo.com
I have the following rule:
rule "somerule"
when
forall
(
CreditReport( $parentCreditReport_1_Id : myId)
FICO( parentId == $parentCreditReport_1_Id, validScoreIndicator == false)
)
then
System.out.print("Fired");
end
The meaning of the rule is that if all the FICO scores on the credit report are invalid, then fire the rule.
My data at run time has three FICO objects related to one CreditReport, two of which have validScoreIndicator set to false, and one of which has it set to true.
The rule fires, and I don't understand why.
Can anyone enlighten me?
Tom Murphy
Business Process Consultant
Wells Fargo HCFG - CORE Deal Decisioning Platform
800 S. Jordan Creek Parkway | West Des Moines, IA 50266
MAC: X2301-01B
Office: 515 324 4853 | Mobile: 941 320 8014
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.
16 years, 6 months
Design Question
by Daniel Miller
Hey everyone,
So I'm faced with a slight dilemma here. I have a slew of database
entities managed by Hibernate. I also have remote object layer, which
I use for the UI, which are basic clones of the database entities. I
did this to prevent the UI from experiencing
LazyInitializationException's.
I was trying to use my remote layer in Drools, pushing all my remote
objects into the Working Memory, but I get LazyInit Exceptions when
trying to convert back into a db object (in a WorkItemHandler instance).
Is there anyway that I can tell Spring, or Drools, that the working
memory is transactional? I suspect that my work item handler, though
wired in Spring with the appropriate service classes, loses it's
transactional state when it gets pushed into the working memory. Is
that a true assumption? And if so, is there a way that I can keep
that transactional state in the WorkItemHandler instance?
I've seen the examples where people will push a hibernateSession in as
a global, but I would like to avoid pushing my Dao classes in like
this. I'd prefer to either push my service layer in as globals (since
they use the daos) or somehow the working memory in so it has a
session in Spring.
Hope this all makes sense.
Dan Miller
16 years, 6 months
Generate PNG from .rf file
by Alan.Gairey@tessella.com
Is there a simple way, using the Drools API, to generate a PNG of a rule
flow, given a .rf file?
Thanks,
Alan
16 years, 6 months
Delivery reports about your e-mail
by Post Office
The message was not delivered due to the following reason(s):
Your message could not be delivered because the destination server was
unreachable within the allowed queue period. The amount of time
a message is queued before it is returned depends on local configura-
tion parameters.
Most likely there is a network problem that prevented delivery, but
it is also possible that the computer is turned off, or does not
have a mail system running right now.
Your message could not be delivered within 4 days:
Server 66.193.71.75 is not responding.
The following recipients could not receive this message:
<rules-users(a)lists.jboss.org>
Please reply to postmaster(a)lists.jboss.org
if you feel this message to be in error.
16 years, 6 months
Java interfaces and Buvnor jar model
by Libor Nenadál
Hello,
I failed to find some more in-depth documentation for objects that are
supported in Guvnor jar model but it seems that only instantiable beans are
supported now. It would be more practical to support also interfaces.
Here is the example I am trying to resolve:
For database access I use JPA annotated class. I want to work with it in the
Guvnor but also do not want to include JPA classes that the annotated class
imports. So I thought of declaring an interface that is uploaded to Guvnor
and JPA class would implement it. That it unfortunately not possible.
I can only create model bean that is uploaded to Guvnor and the JPA class
that extends the model bean. Is there any other elegant solution to this?
Thank you!
Libor Nenadál
--
View this message in context: http://old.nabble.com/Java-interfaces-and-Buvnor-jar-model-tp26215739p262...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 6 months
Implementation of Rule Flow
by Dylan Rafael Rex DSouza
Hi all,
I am taking in details of a customer and determining the total income in one rule flow group. Also I have taken in details of the loan taken by the customer to determine the monthly repayment. This monthly repayment is taken in another ruleflowgroup to determine the total expenses per month. Then the total income from the first rule flow group and the total expenses is taken as input in another rule flow group using 'join'. These parameters then determine the rating of the customer.
However the rating shows as 0. and the only output that shows is the total income. kindly help.
I am attaching the src code along the repository_export.
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
16 years, 6 months
Mvel and multithreading problem.
by Grigoriev, Grigoriy
Hello,
I have a project, that uses Drools 5.0.1. I have a class, called RuleFlowProcessor, that's used to apply some of my rules to the objects.
The instances of RuleFlowProcessor with the identical configuration should be used by different threads, and i use following mechanism:
I initialize one instance of RuleFlowProcessor, and the threads take copy of this instance, calling the 'clone()' method, which is not synchronized, and in which I just create new instance of
RuleFlowProcessor and init it, using the same data.
And therefore I get an exception:
Exception in thread "Thread-91" [Error: incomplete statement: (possible use of reserved keyword as identifier: )]
[Near : {... globals != empt ....}]
^
[Line: 0, Column: 0]
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:153)
at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:44)
at org.mvel2.MVEL.eval(MVEL.java:514)
although, all the resources (.drl and .rf files) are parsed perfectly, when I use just one thread.
In actions of my ruleflow, the dialect: 'mvel' was set by default, if I set dialect to 'java' without modifying any code, the error doesn't occur.
The full stacktrace is in attach. I can send the project, that reproduces the problem, if needed.
Best regards,
Grigoriy Grigoriev.
16 years, 6 months
Test for Empty String?
by Jason Davidson
Hello,
Is there an easy way to test if a String value is empty? I've been doing
this (Drools 4.0.7):
when CitationDTO
(
charge != null &&
charge.drivingIncidentLegalSpeedRate != null &&
charge.drivingIncidentLegalSpeedRate != ""
)
then ......
It seems like there has to be a better method.
Thanks,
Jason
16 years, 6 months
Hierarchical rules and rules selection
by D Brock
I need my end user to be able to specify a set of hierchical rules. As a
contrived example, conceptually we would define rule files called
"Common.drl", "Truck.,drl", "Car.drl", "4-wheel drive.drl",
"Sports-Car.drl".
"4-wheel drive.drl" should include rules from "Truck.drl", which in turn
should rules from "Common.drl".
"Sports-Car.drl" should include rules from "Car.drl", which in turn should
rules from "Common.drl".
Now when a Vehicle object is inserted into memory, based on "class" property
= "4-wheel drive" it would execute against the rules of "4-wheel drive.drl"
and all of it's hierarchically included rules.
Similarly when a Vehicle object is inserted into memory, based on "class"
property = "Sports-Car" it would execute against the rules of
"Sports-Car.drl" and all of it's hierarchically included rules.
Is this possible, and if so how would it be best implemented? It seems like
there should be an "include" keyword in the DRL language that would include
contents from another DRL file. But even with this there would be the issue
if selected which rules should be used.
Would appreciate any help you can give....Thanks
--
View this message in context: http://old.nabble.com/Hierarchical-rules-and-rules-selection-tp26201268p2...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 6 months