Decoupling application from rules (Fact Model question)
by dbrownell83
Hi all,
I am new to drools, and getting Conway's Game of Life into Guvnor, to learn
the system.
I have hit a conceptual block. I want to decouple the application from the
rules. So...
There are 2 methods of adding a model:
1. Upload POJO model jar
2. New Declarative model
I don't want to have to re-sync everytime the jar changes, but I don't
understand how anyone would ever use #2.
One first gets the rules/app running on the local machine, for testing. So
you already have the POJOs (and inherit from it, and use it throughout the
application, as is the case with CellGridImpl).
Then one uploads to Guvnor. And this is where I am stuck.
The object model (rule imports) are: Cell, CellGrid, Neighbor, Phase,
CellState.
These already exist as POJOs (with the exception of CellGrid, which is not a
POJO, but an interface used to initialise the knowledge session). So how
does one upload the model, and not have to keep a jar file in sync?
Is one supposed to re-create the POJOs using the guided editor? (and then
still have to keep your own files in sync with Guvnor's version?)
Regards
Daniel
--
View this message in context: http://old.nabble.com/Decoupling-application-from-rules-%28Fact-Model-que...
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Suppressing reciprocal matches
by D Brock
I have defined the following rule to detect when duplicate objects (in this
example, Widgets) exist. This always produces two matches, and therefore
two messages. I understand why this occurs, but I would like for only one
message to be reported. I cannot retract one of the widgets after a match
b/c all are needed for additional rules matching. Is the a conventional way
for accomplishing the elimination of the reciprocal match?
rule "Do not allow duplicate widgets"
when
$w : Widget( $name : name )
Widget( this != $w, name == $name )
then
System.out.println( "Duplicate widgets found with name = " + $name );
end
--
View this message in context: http://old.nabble.com/Suppressing-reciprocal-matches-tp26230834p26230834....
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Re: [rules-users] some pointers for solution
by Greg Barton
Yep. See attached project. It actually simplifies the java a bit, as now there doesn't need to be any trickery in the contains method for Query. The rule now uses a from clause to get the Criteria directly from the Query:
rule "Match"
when
d : Data()
q : Query( size <= d.size )
$total : Number( intValue == q.size )
from accumulate( Criteria( this memberOf d ) from q, count(1) )
then
System.out.println("Match: " + d + " and " + q) ;
end
Try the other methods, though. (The eval 'hack' I included before, and Wolfgang's method.) All of these approaches should have different performance behavior, and I honestly don't know which one is fastest.
--- On Sun, 11/8/09, Wishing Carebear <wishing.carebear(a)gmail.com> wrote:
> From: Wishing Carebear <wishing.carebear(a)gmail.com>
> Subject: Re: [rules-users] some pointers for solution
> To: "Rules Users List" <rules-users(a)lists.jboss.org>
> Date: Sunday, November 8, 2009, 8:02 PM
> Yes Edson, I tried with count and sum.
> Both seems to be working fine.
>
> But with the test case, the Criteria for query also
> needs to be inserted in addition to the query and data
> objects like shown below:
>
> Query query = new Query(1);
> query.add(new
> Criteria(query, "c2", "bas"));
> ksession.insert(query);
> for(Criteria c :
> query) {
> ksession.insert(c);
> }
>
>
> Is it possible to avoid them.
>
> Thanks,
> cabear
>
>
>
> 2009/11/8 Edson Tirelli <ed.tirelli(a)gmail.com>
>
>
> Why not use count() accumulate function? ;)
>
>
> from accumulate( Criteria( this memberOf d, this memberOf q
> ),
>
> count(1) )
>
> Edson
>
>
>
>
>
> 2009/11/8 Greg Barton <greg_barton(a)yahoo.com>
>
> In this case
> the accumulate clause is maintaining a counter (total)
> that's incremented whenever a Criteria is detected that
> is contained in both the Data and Query object matched in
> the rule. So:
>
>
> # Find Criteria that are contained in both the Data and
> Query
>
> from accumulate( Criteria( this memberOf d, this
> memberOf q ),
> # Initialize the counter to 0
> init( int total = 0; ),
> # Increment when the above condition is matched
> action( total ++; ),
> # Decrement if a matched Criteria now fails to match
>
> reverse( total --; ),
> # return the total when all known Criteria are matched
> result( total ) )
>
>
> --- On Sun, 11/8/09, Wishing Carebear <wishing.carebear(a)gmail.com>
> wrote:
>
> > From: Wishing Carebear <wishing.carebear(a)gmail.com>
>
> > Subject: Re: [rules-users] some pointers for
> solution
> > To: "Rules Users List" <rules-users(a)lists.jboss.org>
> > Date: Sunday, November 8, 2009, 11:39 AM
>
>
>
>
> > Hi Greg:
> > I'm trying to understand your first
> > solution.
> >
> > Ran the project and it works fine. If possible could
> > you explain me little bit on :
> >
> > from accumulate( Criteria( this memberOf d,
>
> > this memberOf q ),
> > init( int total = 0; ),
> > action( total ++; ),
> > reverse( total --; ),
> > result( total ) )
> >
> >
> > Thanks,
> > cabear
> >
> >
> > 2009/11/8 Greg Barton <greg_barton(a)yahoo.com>
>
> >
> > There are a couple of
> > ways to do this. I'm sure there's a bit more
> clean
> > way than the example I'm providing, but this
> should get
> > you in the right direction. It's not 100%
> rules,
>
> > because it involves a bit of java collections
> trickery. (See
> > attached project,
> collection_DroolsCriteriaMatch.tar.gz)
> >
> >
> > The heart of it is a single rule:
> >
> > rule "Match"
>
> > when
> > d : Data()
> > q : Query( size <= d.size )
> > Number( intValue == q.size )
> > from accumulate(
> > Criteria( this memberOf d, this memberOf q ),
> >
> > init( int total = 0; ),
>
> > action( total ++; ),
> > reverse( total --; ),
> > result( total )
> > )
> > then
> > System.out.println("Match: " + d +
> "
> > and " + q) ;
> > end
>
> >
> > The Data object holds data to be queried, Query
> objects are
> > asserted to match the Data, and Criteria objects can
> be
> > contained in either. (With the aforementioned
> collections
> > trickery that if a Criteria is contained in a Query it
> can
>
> > be found in a Data object, but the reverse isn't
> true.
> > See the Query.contains(Object) method for how
> that's
> > implemented.)
> >
> >
> > So the rule above basically says "There's a
> Data
>
> > object, and all of the Query objects Criteria are
> contained
> > in the Data object."
> >
> > There's an alternate way of doing this using eval
> and a
> > bit more java fu. See the
> eval_DroolsCriteriaMatch.tar.gz
>
> > project attached. This one's probably not
> optimal,
> > though, as it's basically a brute force check of
> all
> > Data objects against the asserted Query.
> >
> >
> > I tried for a while to get a solution working with
>
> > different criteria types from both Data and Query
> objects
> > being asserted into working memory, but I couldn't
> get
> > the accumulate syntax right. Anyone know of a way to
> do
> > that? (I figure that would get a "pure
> rules"
>
> > solution.)
> >
> >
> > --- On Sat, 11/7/09, Wishing Carebear <wishing.carebear(a)gmail.com>
> > wrote:
> >
> > > From: Wishing Carebear <wishing.carebear(a)gmail.com>
>
> >
> > > Subject: [rules-users] some pointers for
> solution
> > > To: rules-users(a)lists.jboss.org
> > > Date: Saturday, November 7, 2009, 10:19 PM
>
> >
> >
> >
> > > Hello:
> > > There are n selection criteria from s1 .. sn for
> each
> > > item i1.. in. Each item can have a subset of
> criteria
> > which
> > > applies to them.
>
> > >
> > > The end user, can choose a subset of criteria
> like c1
> >
> > > and c5 and only the item that has c1 and c5
> valid
> > should be
> > > returned. For example: if item i1 and i2 have
>
> > criterias
> > > valid for c1, c2, c5, c6, c8 since the request is
> only
> > for
> > > criteria c1 and c5, i1 and i2 must be returned.
> >
> > >
> > >
> > > Is it possible to write a rule using drools for
> this
>
> > > requirement.
> > >
> > > Thanks for your help and time,
> > > cabear
> > >
> > > -----Inline Attachment Follows-----
> >
> > >
> > > _______________________________________________
>
> > > rules-users mailing list
> > > rules-users(a)lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
>
> >
> > >
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
>
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> >
> >
> >
> > -----Inline Attachment Follows-----
>
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> >
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
15 years
some pointers for solution
by Wishing Carebear
Hello:
There are n selection criteria from s1 .. sn for each item i1.. in. Each
item can have a subset of criteria which applies to them.
The end user, can choose a subset of criteria like c1 and c5 and only the
item that has c1 and c5 valid should be returned. For example: if item i1
and i2 have criterias valid for c1, c2, c5, c6, c8 since the request is only
for criteria c1 and c5, i1 and i2 must be returned.
Is it possible to write a rule using drools for this requirement.
Thanks for your help and time,
cabear
15 years
Maintaining DB/Working Memory Synchronization
by Daniel Miller
So I hope that someone out here, or many of you, can give me some idea
of how you do this.
I have about 20+ entities in my database that I want Drools to know
about. Obviously my hope is to apply CEP, rules and processes to
these items. However, I feel like I'm missing some type of connection
between how Drools recommends keeping my working memory in sync with
my database changes.
Ideally, I'd love to be able to just update my entities as I have been
doing in the database, but have those changes automatically move their
way over into the working memory. How do any of you recommend I
accomplish this?
Thanks in advance for any suggestions.
Dan Miller
15 years
Fwd: Build package 'default' Guvnor
by Eugenio Abello
Dear, I made new tests, and also fails to 'defaultPackage'. This made:
1) Create the files users.properties, roles.properties in \drools-5.1.0.M1-
guvnor-standalone\jboss-4.2.3.GA <http://jboss-4.2.3.ga/>\server\default\conf.
also create the file 'testDS1-ds.xml' in \default\deploy
2) Start the jboss.
3) http://localhost:8080/
<http://localhost:8080/drools-guvnor>drools<http://localhost:8080/drools-guvnor>
- <http://localhost:8080/drools-guvnor><http://localhost:8080/drools-guvnor>
guvnor <http://localhost:8080/drools-guvnor>. when he asks "This looks like
a brand new repository. Would you like to install a sample repository?" I
respond "No thanks"
4) From eclipse add hellow_world.rf to Guvnor to 'defaultPackage' package,
OK
5) Build package 'default' , and delivers the same error:
2009-11-03 12:22:47,765 DEBUG [com.arjuna.ats.jta.logging.loggerI18N]
[com.arjuna.ats.internal.jta.recovery.info.secondpass] Local
XARecoveryModule - second pass
2009-11-03 12:24:05,031 INFO [STDOUT] ERROR 03-11 12:24:05,031
(RepositoryServiceServlet.java:doUnexpectedFailure:76)
java.lang.NullPointerException
2009-11-03 12:24:05,031 ERROR [STDERR]
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public
abstract org.drools.guvnor.client.rpc.BuilderResult[]
org.drools.guvnor.client.rpc.RepositoryService.buildPackage(java.lang.String,java.lang.String,boolean)
throws com.google.gwt.user.client.rpc.SerializableException' threw an
unexpected exception: java.lang.NullPointerException
2009-11-03 12:24:05,031 ERROR [STDERR] at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:360)
2009-11-03 12:24:05,031 ERROR [STDERR] at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:546)
2009-11-03 12:24:05,031 ERROR [STDERR] at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
2009-11-03 12:24:05,031 ERROR [STDERR] at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
2009-11-03 12:24:05,031 ERROR [STDERR] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
2009-11-03 12:24:05,031 ERROR [STDERR] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2009-11-03 12:24:05,031 ERROR [STDERR] at
java.lang.Thread.run(Thread.java:619)
2009-11-03 12:24:05,031 ERROR [STDERR] Caused by:
java.lang.NullPointerException
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.compiler.ProcessBuilder.buildProcess(ProcessBuilder.java:118)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.compiler.ProcessBuilder.addProcessFromFile(ProcessBuilder.java:222)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:468)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.compiler.PackageBuilder.addRuleFlow(PackageBuilder.java:440)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.contenthandler.RuleFlowHandler.compile(RuleFlowHandler.java:167)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.builder.ContentPackageAssembler.buildAsset(ContentPackageAssembler.java:197)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.builder.ContentPackageAssembler.buildPackage(ContentPackageAssembler.java:184)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.builder.ContentPackageAssembler.<init>(ContentPackageAssembler.java:104)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.builder.ContentPackageAssembler.<init>(ContentPackageAssembler.java:117)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.ServiceImplementation.buildPackage(ServiceImplementation.java:1434)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.ServiceImplementation.buildPackage(ServiceImplementation.java:1415)
2009-11-03 12:24:05,031 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2009-11-03 12:24:05,031 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2009-11-03 12:24:05,031 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2009-11-03 12:24:05,031 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:597)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:157)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.ServiceImplementation_$$_javassist_3.buildPackage(ServiceImplementation_$$_javassist_3.java)
2009-11-03 12:24:05,031 ERROR [STDERR] at
org.drools.guvnor.server.RepositoryServiceServlet.buildPackage(RepositoryServiceServlet.java:206)
2009-11-03 12:24:05,031 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2009-11-03 12:24:05,031 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2009-11-03 12:24:05,031 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2009-11-03 12:24:05,031 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:597)
2009-11-03 12:24:05,031 ERROR [STDERR] at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
2009-11-03 12:24:05,031 ERROR [STDERR] ... 27 more
2009-11-03 12:24:47,765 DEBUG [com.arjuna.ats.arjuna.logging.arjLogger]
Periodic recovery - first pass <mar, 3 nov 2009 12:24:47>
Thn
Kris
15 years
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
>
15 years
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.
15 years
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
15 years