Using collect to group by
by Heyns, Juan
Hello,
I am trying to achieve something like a SQL statement equivalent of:
SELECT r.property1 AS p1, r.property2 AS p2,
SOME_CALCULATION(r.property3) AS p3
FROM right AS r
GROUP BY p2, p3
I am not sure if this is valid SQL since I am grouping by a calculated
value, but that aside.
I am asserting the Rights objects into the working memory and then would
like to execute a rule on the objects based
on a grouping of objects. The first property is directly accessible from
the object right.getProperty2() but the
second property is only accessible through a lookup
MyClass.staticMethod(right.getProperty3()).
As far as I have it the rule should make use of something like collect
or accumulate but I do not know how to
achieve this without also asserting the properties objects into the
memory as well. And even if I assert the properties
objects into the working memory I do not know how to group by the second
property.
rule "Calculate something"
no-loop
when
$rights: ArrayList( )
from collect( Right( ) );
then
// execute rule
end
Could you please give me some assistance?
Regards
Juan
"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee shall
not be legally binding on Lonplats and Lonplats shall incur no liability of
any nature whatsoever, directly or indirectly, arising from such act on the
part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"
17 years, 4 months
If one exists check all
by Brian Enderle
I have a test case that says that if any one field is present then all must be
present and then verified. The items in question are for an Insurance object
and are Name, Street, City, County, State, Country and Zip. If one of the
these 7 fields is present (not null/blank) then it and all the other fields
need to be verified. This needs to be done on a per object basis as not all
InsuranceCarrier objects will have these fields filled in.
Just to clarify I need rules for each field similar to the following:
rule "Name cannot be blank"
when
$i : Insurance( name == null, street != null || city != null ||
county != null || state != null || country != null ||
zip != null)
then
<Report error>
end
Ithere a simple way to check all the values and then execute all the rules for
that object?
THanks in advance,
Brian Enderle
17 years, 4 months
Existensial not question
by wasabifan
I have several rules I am working on that I am having problems implementing.
Most of our tests are composed of at least one "pass" and one "fail" rule.
Basically, there are some tests where exceptions need to be thrown based on
a date or number being inside a range where these exceptions occur (causing
a possible failure).
The problem is that we are testing several objects, so using the existensial
not, is problematic.
For example, in the pass, if we write:
rule "pass example"
when
Fact1($number : number)
not ExceptionRange(startRange <= $number, stopRange >= $number)
then
System.out.println("Pass" + $number);
end
For the fail, it would be like:
rule "fail example"
when
Fact1($number : number)
ExceptionRange(startRange <= $number, stopRange >= $number)
then
System.out.println("Fail" + $number);
end
Is there a way to rewrite the pass rule, so that it checks the existence of
a range satisfying each number from Fact1? If I understand not correctly,
it will either pass once, and only once if ANY range matches at least one
number from Fact1. Or it would pass for all Fact1's if any Fact1's match
any exception range.
A little clarification here would be appreciated, and if you know of a
workaround to actually test for getting exactly one and only one pass or
fail (exclusively) for each Fact1 asserted.
Thanks,
Bryan Rickman
--
View this message in context: http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 4 months
Arbitrary problem using OR?
by wasabifan
In getting our business rules written, we used a lot of domain experts to
help write our rules. I now have the exciting job of verifying and fixing
these rules as needed. When possible, I had asked that they use OR
statements in a single rule, as opposed to breaking them out into multiple
rules for brefity and ease of maintenance.
However, in trying to get these rules to function, I find myself time and
time again having to break OR logic into multiple rules to get it to work
(the || internal to objects seems to work okay). I have tried both prefix
and infix OR. Is there some limit to the complexity of when OR will or will
not work? I have tried using parenthesis to make the logic very explicit,
but often breaking it into multiple rules seems to be the only remedy.
Is there some principle to go by, or is this a matter of trial and error
when rules must be broken into multiple rules in the DRL? My understanding
was that the OR CE basically would be broken into multiple rules
automagically, which is what I end up doing manually in the DRL. Have you
heard of any problems with this functionality?
--
View this message in context: http://www.nabble.com/Arbitrary-problem-using-OR--tf4481210.html#a12778131
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 4 months
Problem with memberOf and/or eval used in collect statement
by Chris West
All,
I'm having a problem using memberOf combined with a collect statement. My
test includes 3 rules each written to output the same results (I think), but
I get different results (depending on which version of Drools I use).
The rules are:
rule "TestMemberOf"
salience 10
when
$messages: ArrayList() from collect (Message(status == 100))
$wrappers: ArrayList() from collect (Wrapper(message memberOf
$messages))
then
System.out.println("TestMemberOf: " + $wrappers.size());
end
rule "TestEval1"
salience 9
when
$messages: ArrayList() from collect (Message(status == 100))
$wrappers: ArrayList() from collect (Wrapper($message: message,
eval($messages.contains($message))))
then
System.out.println("TestEval1: " + $wrappers.size());
end
rule "TestEval2"
salience 8
when
$wrappers: ArrayList() from collect (Wrapper($message: message,
eval($message.getStatus() == 100)))
then
System.out.println("TestEval2: " + $wrappers.size());
end
The output is (by version):
4.0.0
TestMemberOf: 0
TestEval1: 0
TestEval2: 2
4.0.1
TestMemberOf: 0
TestEval1: 2
TestEval2: 2
4.0.2.SNAPSHOT (taken 9/18/07)
TestMemberOf: 0
TestEval1: 2
TestEval2: 2
The correct output should be:
TestMemberOf: 2
TestEval1: 2
TestEval2: 2
Am I using memberOf correctly? Is there some issue using an eval to test
conditions on a list created by a collect?
Any help would be appreciated.
Attached is the full example.
Thanks,
-Chris West
17 years, 4 months
Rule Inheritance support
by Kunal Shah
Hello list. I needed some expert advice related to implementing Rule
inheritance in Drools. I will still consider myself new to Drools and
trying to go through all the source code currently.
The requirement for rule inheritance that I have is as follows:
A set of rules are defined/implemented on an entity acting as a template
for other entities. Any entity created using template entity will
inherit rules defined in template. There may be hundreds of child
entities created from parent template entity. Inheritance here supports
the following:
1. All enabled rules from template are also enabled on child entity.
2. Child entity can over-ride one or more of the rules defined in
template. Child entity may also change rule settings/disable them.
3. Child entity can also extend rule-base by adding its own rules which
are not defined in template.
I know there has been mentioned in the list of not having support for
rule inheritance in Drools yet, but no discussion of how to achieve it.
So any insights will be greatly appreciated.
Also one of the design questions here is should we use separate
rule-base for each child entity as well as template entity (there can be
potentially hundreds of child entities for a given template) or should
we try to use only one rule-base and provide support for inheritance
using only custom agenda filtering. Usage of custom agenda filter may
help with performance as it won't require hundreds of rule-bases but may
not be even feasible to what we are trying to accomplish here. Also it
may result in other short-comings but I can't visualize it just yet.
Thanks
Kunal Shah
Development
www.sensorlogic.com
17 years, 4 months
Exception executing predicate
by Krishnan
Hi all,
When exceptions occur during runtime of drools, is there a list of things to
see to understand what may be causing
this to happen ? I know it is a very generic question. I want to see if
there is a methodical way to understand what
to look for ?.
org.drools.RuntimeDroolsException: Exception executing predicate
com.makesys.fs.is.dnpiac.vendorBehaviour.snmp.Rule_Cisco_Systems_0ReturnValue0Invoker@39d31fda
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:197)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:122)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(
CompositeObjectSinkAdapter.java:317)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(
SingleObjectSinkAdapter.java:20)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
INFO | jvm 1 | 2007/09/14 16:46:33 | at org.drools.reteoo.Rete.assertObject(
Rete.java:168)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java
:848)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java
:822)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java
:60)
INFO | jvm 1 | 2007/09/14 16:46:33 | at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java
:54)
Any help is appreciated ?
thanks,
Krishnan.
--
Sivaramakrishna Iyer Krishnan (Anand)
Never assume the obvious is true.
- William Safire
17 years, 4 months
RE: [rules-users] Can't upload model in BRMS
by Drouin.Mathieu
Ok, found out the download didn't work because I was using IE 6...so I
tried in firefox and it works...
The upload still doesn't work though...getting the following
exception...
ERROR 18-09 13:01:48,014 (ApplicationContext.java:log:675) Exception
while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException:
java.lang.ClassNotFoundException: org.drools.brms.client.rpc.RuleAsset
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.dese
rialize(ServerSerializationStreamReader.java:156)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.re
adObject(AbstractSerializationStreamReader.java:61)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.dese
rializeValue(ServerSerializationStreamReader.java:70)
at
org.jboss.seam.remoting.gwt.GWTRemoteServiceServlet.processCall(GWTRemot
eServiceServlet.java:285)
at
org.jboss.seam.remoting.gwt.GWTRemoteServiceServlet.doPost(GWTRemoteServ
iceServlet.java:181)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:173)
at
org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:56)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:107)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541
)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
48)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
9)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.proc
essConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollow
erWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException:
org.drools.brms.client.rpc.RuleAsset
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.dese
rialize(ServerSerializationStreamReader.java:135)
... 24 more
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Drouin.Mathieu
Sent: September 18, 2007 1:00 PM
To: Rules Users List
Subject: RE: [rules-users] Can't upload model in BRMS
Has anyone managed to download the model from the insurance example in
the BRMS?
I'm using the standalone version on tomcat 5.5.20.
Thanks,
Mat
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Drouin.Mathieu
Sent: September 11, 2007 11:52 AM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Can't upload model in BRMS
I can't seem to upload a model into the BRMS. I also tried downloading
and uploading the model in the insurance example and it failed. (I tried
both the .war on tomcat 6.0.13 and the standalone version on tomcat
5.5.20).
Can somebody help?
Thanks,
Mat
_______________________________________________
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
17 years, 4 months
RE: [rules-users] Can't upload model in BRMS
by Drouin.Mathieu
Has anyone managed to download the model from the insurance example in
the BRMS?
I'm using the standalone version on tomcat 5.5.20.
Thanks,
Mat
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Drouin.Mathieu
Sent: September 11, 2007 11:52 AM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Can't upload model in BRMS
I can't seem to upload a model into the BRMS. I also tried downloading
and uploading the model in the insurance example and it failed. (I tried
both the .war on tomcat 6.0.13 and the standalone version on tomcat
5.5.20).
Can somebody help?
Thanks,
Mat
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
17 years, 4 months