Why might "collect from" not work?
by KDR
Based on the examples in the Drools Expert documentation, I have a rule like
this (simplified version here):
when
Search($t : town)
$results : ArrayList()
from collect ( Person (town == $t) )
# $p: Person(town == $t) # this works
then
System.out.println("Matches for " + $t);
System.out.println($results.size()); # this produces 0!
# System.out.println($p.getName()); # this works
end
When I use instead the commented out lines in the "when" and "then", it
prints out a list of names of matching people.
However when I tried to collect the matching people into an ArrayList for
use in the "then", I got nothing, so I tried to test it by printing out the
size of the list as shown above, and I found that the size was 0, so it's
clearly not collecting matching people into the list even though it works
fine individually.
Can anyone suggest what might be going wrong please?
Thanks in advance for any help.
Cheers.
--
View this message in context: http://www.nabble.com/Why-might-%22collect-from%22-not-work--tp25167528p2...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 4 months
Rule for Collection (Ashish Soni)
by Vishwanath Dubey
YOu can use collect function. Please refer
http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
On 8/26/09, rules-users-request(a)lists.jboss.org <
rules-users-request(a)lists.jboss.org> wrote:
>
> Send rules-users mailing list submissions to
> rules-users(a)lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.jboss.org/mailman/listinfo/rules-users
> or, via email, send a message with subject or body 'help' to
> rules-users-request(a)lists.jboss.org
>
> You can reach the person managing the list at
> rules-users-owner(a)lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of rules-users digest..."
>
>
> Today's Topics:
>
> 1. Rule for Collection (Ashish Soni)
> 2. Using KnowledgeAgent with Stateful session (nestabur)
> 3. Re: Cannot view Process Definitions in gwt-console (rbms)
> 4. Re: Using KnowledgeAgent with Stateful session (James Owen)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 26 Aug 2009 12:22:55 -0400
> From: Ashish Soni <learnspring(a)gmail.com>
> Subject: [rules-users] Rule for Collection
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Message-ID:
> <cf7a8a020908260922je3d0f9cie85eada146f594e9(a)mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi All ,
>
> Can someone please help how can i write a rule for below condition -
>
> I have Student object which contains List of Courses
>
> public Class Person
> {
> private List<Course> courseList;
> }
>
> public Class Course
> {
> private String name;
> private int duration;
> }
>
> Now lets say the list of course inside person object contains 10 course
> objects and if one of the course object contain name =="XYZ" and another
> contain a duration = 20 hours then how i can write a rule for this.
>
>
> Thanks.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/rules-users/attachments/20090826/f74f64c...
>
> ------------------------------
>
> Message: 2
> Date: Wed, 26 Aug 2009 09:34:33 -0700 (PDT)
> From: nestabur <nestabur(a)gmail.com>
> Subject: [rules-users] Using KnowledgeAgent with Stateful session
> To: rules-users(a)lists.jboss.org
> Message-ID: <25151447.post(a)talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
>
> Does anyone tried to use the knowledgeAgent with statefulSessions?
>
> I've tried to configure my rule engine obtaining unexpected behaviour.
>
> I configure my statefulSession as follows:
>
> wm = (ReteooStatefulSession) ((KnowledgeBaseImpl) kagent
>
> .getKnowledgeBase()).ruleBase.newStatefulSession(
> (SessionConfiguration) sessionConf, env);
> ksession = new StatefulKnowledgeSessionImpl(wm, kagent.getKnowledgeBase());
>
> And after updating the KnowledgeBase in the agent I update my ksession:
>
> wm.setRuleBase((InternalRuleBase) ((KnowledgeBaseImpl) kagent
>
> .getKnowledgeBase()).ruleBase);
> ksession = new StatefulKnowledgeSessionImpl(wm, kagent.getKnowledgeBase());
>
> Without using entry-points this approach works as expected, but using them
> it fails after the first update throwing the error:
>
> Exception while processing message: java.lang.NullPointerException
> java.lang.NullPointerException
> at
>
> org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:54)
> at
>
> org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:79)
> at
>
> org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:66)
> at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:109)
> at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
> at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
>
> Browsing the drools core code I found the line that was throwing the
> exception and tried to get the same result by implementing:
>
> if (!((InternalRuleBase) ((KnowledgeBaseImpl)
> ksession.getKnowledgeBase()).ruleBase)
> .getTypeDeclaration(fact.getClass()) ==
> null)
> log.info (((InternalRuleBase) ((KnowledgeBaseImpl)
> ksession.getKnowledgeBase()).ruleBase)
>
> .getTypeDeclaration(fact.getClass()).getTimestampExtractor().toString());
>
> after updating my ksession. The result was the same, again the same
> exception thrown but my logger wrote:
> 18:01:50,232 INFO [ClassFieldExtractor class=MyPackage.MyFact
> field=myTimestampField]
>
> So I dont know why the core is throwing that exception, is that
> implementation correct?, any ideas?
>
>
> Thanks,
>
> Nestor
>
> --
> View this message in context:
> http://www.nabble.com/Using-KnowledgeAgent-with-Stateful-session-tp251514...
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 26 Aug 2009 11:37:55 -0700 (PDT)
> From: rbms <rbms(a)hotmail.com>
> Subject: Re: [rules-users] Cannot view Process Definitions in
> gwt-console
> To: rules-users(a)lists.jboss.org
> Message-ID: <25152800.post(a)talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> Thanks for the reply Kris,
>
> I finally found the issue. When file is uploaded from guvnor, looks like
> the
> compile package bytes property is not set in the repo.
>
> So I had to invoke rebuildPackages function from
> org.drools.guvnor.server.ServiceImplementation.loadRuleAsset function
>
> thanks
> -Ramesh
>
>
> Kris Verlaenen wrote:
> >
> > Because the gwt-console does not allow you to specify which knowledge
> > package should be loaded (yet), it currently uses the "default" package.
> > Putting your rule flow in a package called "default" (and then building
> > that package in Guvnor) should solve your issue I think. You could also
> > change the name of the package to load in the changeset.xml file in
> > drools-gwt-console.
> >
> > Kris
> >
> > Quoting rbms <rbms(a)hotmail.com>:
> >
> >>
> >> I am trying to deploy drools-guvnor, gwt-console in Tomcat.
> >> I am using mysql for persistence.
> >> I uploaded the process definitions in drools-guvnor.(I can see them
> >> Packages
> >> --> defaultPackage --> RuleFlows)
> >> However when I try to view them in Processes --> Process Definitions
> >> -->
> >> Definition List, I cannot see them.
> >>
> >> Following is from tomcat server log.(with debugging statements that
> >> I
> >> added.)
> >>
> >> I placed debug statements in
> >> org.drools.guvnor.server.files.PackageDeploymentServlet.doGet method.
> >> This
> >> method calls
> >> org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage
> >> method.
> >>
> >> //Following is the debug statement that I placed in
> >> org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage
> >> method.
> >> public String loadBinaryPackage(String packageName,
> >> String packageVersion,
> >> boolean isLatest,
> >> OutputStream out) throws
> >> IOException {
> >> PackageItem item = null;
> >> if ( isLatest ) {
> >> item = repository.loadPackage( packageName );
> >> System.out.println("FileManagerUtils.loadBinaryPackage() ...");
> >> AssetItemIterator ai = item.queryAssets("drools:format='rf'",
> >> false);
> >> for (;ai.hasNext();) {
> >> Object o = ai.next();
> >> System.out.println("FileManagerUtils.loadBinaryPackage
> item = "
> >> +
> >> o.getClass() +":"+o);
> >>
> >>
> >
> System.out.println("*************************************************************************");
> >> }
> >>
> >> As you can see the servlet returns the rule flow.
> >>
> >> I also placed some debug statements in
> >> org.drools.rule.Package.readExternal
> >> method. As you can see when it comes to this method rule flow is
> >> empty.
> >>
> >> Because of this
> >> org.drools.integration.console.DroolsFlowCommandDelegate.getProcesses()
> >> function returns 0 process definitions.
> >>
> >> Can somebody help?
> >>
> >> ********************************************************
> >> [2009:08:231 22:08:625:debug] KnowledgeAgent rebuilding KnowledgeBase
> >> using
> >> ChangeSet
> >> [2009:08:231 22:08:625:debug] KnowledgeAgent building
> >> resource=[UrlResource
> >>
> > path='
> http://localhost:8081/drools-guvnor/org.drools.guvnor.Guvnor/package/defa...
> ']
> >> PackageName: defaultPackage
> >> //org.drools.guvnor.server.files.PackageDeploymentServlet.doGet -
> >> Begin
> >> PackageVersion: LATEST
> >> PackageIsLatest: true
> >> PackageIsSource: false
> >> requestURI:
> >> /drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST
> >> test:
> >> /drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST
> >> //org.drools.guvnor.server.files.PackageDeploymentServlet.doGet -
> >> End
> >> FileManagerUtils.loadBinaryPackage() ... //
> >> org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage -
> >> Begin
> >> FileManagerUtils.loadBinaryPackage item = class
> >> org.drools.repository.AssetItem:Content of rule item named 'testRF':
> >> Content: <?xml version="1.0" encoding="UTF-8"?>
> >> <process xmlns="http://drools.org/drools-5.0/process"
> >> xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
> >> xs:schemaLocation="http://drools.org/drools-5.0/process
> >> drools-processes-5.0.xsd"
> >> type="RuleFlow" name="ProjectApprovalProcess"
> >> id="ProjectApprovalProcess" package-name="defaultPackage" >
> >>
> >> <header>
> >> <variables>
> >> <variable name="project" >
> >> <type
> >> name="org.drools.process.core.datatype.impl.type.ObjectDataType"
> >> className="com.yesVin.workflow.project.Project" />
> >> </variable>
> >> <variable name="status" >
> >> <type
> >> name="org.drools.process.core.datatype.impl.type.StringDataType" />
> >> </variable>
> >> </variables>
> >> </header>
> >>
> >> <nodes>
> >> <start id="1" name="Start" x="15" y="11" width="80" height="40"
> >> />
> >> <end id="2" name="End" x="206" y="442" width="80" height="40" />
> >> <humanTask id="3" name="Review Project" x="126" y="12"
> >> width="80"
> >> height="40" >
> >> ..
> >> ...
> >> .....
> >> ......
> >> //org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage
> >> -
> >> End
> >> Package.readExternal isDroolsStream = true //
> >> org.drools.rule.Package.readExternal - Begin
> >> Package.readExternal pkg = null
> >> dialectRuntimeRegistry =
> >> org.drools.rule.DialectRuntimeRegistry@198046
> >> name = defaultPackage
> >> imports =
> >> {defaultPackage.*=org.drools.rule.ImportDeclaration@d75e0360}
> >> staticImports = []
> >> functions = {}
> >> factTemplates = {}
> >> ruleFlows = {}
> >> globals = {}
> >> valid = true
> >> rules = {}
> >> classFieldAccessorStore =
> >> org.drools.base.ClassFieldAccessorStore@34b350
> >> //org.drools.rule.Package.readExternal - End
> >> --
> >> View this message in context:
> >>
> >
> http://www.nabble.com/Cannot-view-Process-Definitions-in-gwt-console-tp25...
> >> Sent from the drools - user mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users(a)lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
> >
> >
> >
> > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Cannot-view-Process-Definitions-in-gwt-console-tp25...
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 26 Aug 2009 16:31:04 -0500
> From: James Owen <jco2009(a)att.net>
> Subject: Re: [rules-users] Using KnowledgeAgent with Stateful session
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Message-ID: <7DCB55B5-8A89-481A-BCDC-77E4A2C5F0B6(a)att.net>
> Content-Type: text/plain; charset="us-ascii"
>
> Greetings:
>
> Nobody seems to be replying and I'm not really "qualified" to reply
> but I might be able to point you in the right direction. Long, long
> ago in a land far, far away we did a really cool project using
> Intelligent Agents and employed most of the technology from FIPA, The
> Foundation for Intelligent Physical Agents; see http://www.fipa.org/
> for more information.
>
> SDG
> James Owen
> Founder October Rules Fest
> Senior Consultant / Architect KBSC
> http://www.kbsc.com
> http://www.OctoberRulesFest.org
> Twitter: OctRulesFest
> Blogs:
> http://JavaRules.blogspot.com [Rulebased Systems Blog]
> http://ORF2009.blogspot.com [October Rules Fest Blog]
> http://exscg.blogspot.com/ [Expert Systems Consulting Group Blog]
>
> "If I have seen a little further it is by standing on the shoulders of
> giants."
> Sir Isaac Newton in a letter to Robert Hooke, 5 Feb 1676
>
> Come to October Rules Fest and stand on the shoulders of the Giants of
> the industry; if only for a week.
>
>
>
> On Aug 26, 2009, at 11:34 AM, nestabur wrote:
>
> >
> >
> > Does anyone tried to use the knowledgeAgent with statefulSessions?
> >
> > I've tried to configure my rule engine obtaining unexpected behaviour.
> >
> > I configure my statefulSession as follows:
> >
> > wm = (ReteooStatefulSession) ((KnowledgeBaseImpl) kagent
> >
> .getKnowledgeBase()).ruleBase.newStatefulSession(
> > (SessionConfiguration) sessionConf, env);
> > ksession = new StatefulKnowledgeSessionImpl(wm,
> > kagent.getKnowledgeBase());
> >
> > And after updating the KnowledgeBase in the agent I update my
> > ksession:
> >
> > wm.setRuleBase((InternalRuleBase) ((KnowledgeBaseImpl) kagent
> >
> .getKnowledgeBase()).ruleBase);
> > ksession = new StatefulKnowledgeSessionImpl(wm,
> > kagent.getKnowledgeBase());
> >
> > Without using entry-points this approach works as expected, but
> > using them
> > it fails after the first update throwing the error:
> >
> > Exception while processing message: java.lang.NullPointerException
> > java.lang.NullPointerException
> > at
> > org
> > .drools
> > .reteoo
> > .ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:
> > 54)
> > at
> > org
> > .drools
> > .common
> > .AbstractFactHandleFactory
> > .newFactHandle(AbstractFactHandleFactory.java:79)
> > at
> > org
> > .drools
> > .common
> > .AbstractFactHandleFactory
> > .newFactHandle(AbstractFactHandleFactory.java:66)
> > at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:109)
> > at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
> > at
> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
> >
> > Browsing the drools core code I found the line that was throwing the
> > exception and tried to get the same result by implementing:
> >
> > if (!((InternalRuleBase) ((KnowledgeBaseImpl)
> > ksession.getKnowledgeBase()).ruleBase)
> > .getTypeDeclaration(fact.getClass()) ==
> null)
> > log.info (((InternalRuleBase) ((KnowledgeBaseImpl)
> > ksession.getKnowledgeBase()).ruleBase)
> >
> > .getTypeDeclaration
> > (fact.getClass()).getTimestampExtractor().toString());
> >
> > after updating my ksession. The result was the same, again the same
> > exception thrown but my logger wrote:
> > 18:01:50,232 INFO [ClassFieldExtractor class=MyPackage.MyFact
> > field=myTimestampField]
> >
> > So I dont know why the core is throwing that exception, is that
> > implementation correct?, any ideas?
> >
> >
> > Thanks,
> >
> > Nestor
> >
> > --
> > View this message in context:
> http://www.nabble.com/Using-KnowledgeAgent-with-Stateful-session-tp251514...
> > Sent from the drools - user mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/rules-users/attachments/20090826/f3daf7e...
>
> ------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> End of rules-users Digest, Vol 33, Issue 81
> *******************************************
>
15 years, 4 months
Adding rules at runtime
by Justin King
Hi Everyone,
I found an old example that shows how to add a rule at runtime:
function void addRule(String pkgName, String rule, RuleBase ruleBase ) {
PackageBuilder builder = new PackageBuilder();
builder.addPackgeFromDrl( new StringReader( rule ) );
ruleBase.addPackage ( builder.addPackage() );
}
I'm trying to do a similar thing with Drools 5 but things seem to have
changed. What I want is to add a rule (just as a string) to an already
existing set of rules I've loaded from a drl file (the new rule does not
have to be saved to the actual file though). I see KnowledgeBase has a
remove rule method but no add rule.
I should also note that the set of rules I wish to add to is already
executing (as in I've called *fireUntilHalt()*) I hope this wont make a
difference.
Thanks in advance for any help, this mailing list saves me every time!
Cheers,
Justin
15 years, 4 months
Fusion and the guided rule editor
by Justin King
Hi everyone,
I'm trying out the guided rule editor in the eclipse plug in but it does not
seem to allow for the use of fusions temporal operators and event meta-data.
Am I missing something here or is the guided editor a bit of a relic from
version 4 that has not been updated?
Cheers,
Justin
15 years, 4 months
Cannot view Process Definitions in gwt-console
by rbms
I am trying to deploy drools-guvnor, gwt-console in Tomcat.
I am using mysql for persistence.
I uploaded the process definitions in drools-guvnor.(I can see them Packages
--> defaultPackage --> RuleFlows)
However when I try to view them in Processes --> Process Definitions -->
Definition List, I cannot see them.
Following is from tomcat server log.(with debugging statements that I
added.)
I placed debug statements in
org.drools.guvnor.server.files.PackageDeploymentServlet.doGet method. This
method calls
org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage method.
//Following is the debug statement that I placed in
org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage method.
public String loadBinaryPackage(String packageName,
String packageVersion,
boolean isLatest,
OutputStream out) throws IOException {
PackageItem item = null;
if ( isLatest ) {
item = repository.loadPackage( packageName );
System.out.println("FileManagerUtils.loadBinaryPackage() ...");
AssetItemIterator ai = item.queryAssets("drools:format='rf'", false);
for (;ai.hasNext();) {
Object o = ai.next();
System.out.println("FileManagerUtils.loadBinaryPackage item = " +
o.getClass() +":"+o);
System.out.println("*************************************************************************");
}
As you can see the servlet returns the rule flow.
I also placed some debug statements in org.drools.rule.Package.readExternal
method. As you can see when it comes to this method rule flow is empty.
Because of this
org.drools.integration.console.DroolsFlowCommandDelegate.getProcesses()
function returns 0 process definitions.
Can somebody help?
********************************************************
[2009:08:231 22:08:625:debug] KnowledgeAgent rebuilding KnowledgeBase using
ChangeSet
[2009:08:231 22:08:625:debug] KnowledgeAgent building resource=[UrlResource
path='http://localhost:8081/drools-guvnor/org.drools.guvnor.Guvnor/package/defa...']
PackageName: defaultPackage
//org.drools.guvnor.server.files.PackageDeploymentServlet.doGet - Begin
PackageVersion: LATEST
PackageIsLatest: true
PackageIsSource: false
requestURI:
/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST
test: /drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST
//org.drools.guvnor.server.files.PackageDeploymentServlet.doGet - End
FileManagerUtils.loadBinaryPackage() ... //
org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage - Begin
FileManagerUtils.loadBinaryPackage item = class
org.drools.repository.AssetItem:Content of rule item named 'testRF':
Content: <?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process
drools-processes-5.0.xsd"
type="RuleFlow" name="ProjectApprovalProcess"
id="ProjectApprovalProcess" package-name="defaultPackage" >
<header>
<variables>
<variable name="project" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="com.yesVin.workflow.project.Project" />
</variable>
<variable name="status" >
<type
name="org.drools.process.core.datatype.impl.type.StringDataType" />
</variable>
</variables>
</header>
<nodes>
<start id="1" name="Start" x="15" y="11" width="80" height="40" />
<end id="2" name="End" x="206" y="442" width="80" height="40" />
<humanTask id="3" name="Review Project" x="126" y="12" width="80"
height="40" >
..
...
.....
...... //org.drools.guvnor.server.files.FileManagerUtils.loadBinaryPackage -
End
Package.readExternal isDroolsStream = true //
org.drools.rule.Package.readExternal - Begin
Package.readExternal pkg = null
dialectRuntimeRegistry = org.drools.rule.DialectRuntimeRegistry@198046
name = defaultPackage
imports = {defaultPackage.*=org.drools.rule.ImportDeclaration@d75e0360}
staticImports = []
functions = {}
factTemplates = {}
ruleFlows = {}
globals = {}
valid = true
rules = {}
classFieldAccessorStore = org.drools.base.ClassFieldAccessorStore@34b350
//org.drools.rule.Package.readExternal - End
--
View this message in context: http://www.nabble.com/Cannot-view-Process-Definitions-in-gwt-console-tp25...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 4 months
Rule for Collection
by Ashish Soni
Hi All ,
Can someone please help how can i write a rule for below condition -
I have Student object which contains List of Courses
public Class Person
{
private List<Course> courseList;
}
public Class Course
{
private String name;
private int duration;
}
Now lets say the list of course inside person object contains 10 course
objects and if one of the course object contain name =="XYZ" and another
contain a duration = 20 hours then how i can write a rule for this.
Thanks.
15 years, 4 months
New Operators
by Ahmed Hafsi
Hi Guys ,
I am using the latest version of drools fusion .
Is it possible to create new operators ? For example I want to make the
logic rule OR
i.e :
a :- b;c.
I know I can make a rule for it like this ::
rule _Rule
when
$a Event()
$b Event(this after $a || this before $a)
then
//..
end
can I embed this rule to make more complex logical rules ? say for example I
want to represent the following rule :
Exp :- (a AND b AND c) OR (d AND e)
One more question ::
how can I represent the not operator ? i.e :
a :- b AND (NOT(b))
Thanks,
Khalil Hafsi
15 years, 4 months
java.lang.IllegalArgumentException: Could not parse knowledge.
by Lindy hagan
Getting below error for each and every rule in Vote.drl . Using Drools 5 and
eclipse 3.4.
Trying this example
http://www.developer.com/java/ent/article.php/10933_3821101_3
Rule Compilation error : [Rule name='VeryGoodValue – between 6-9']
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (3:79) : Syntax error
on tokens, delete these tokens
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (3:92) : The public
type Rule_VeryGoodValue_ must be defined in its own file
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (3:127) : Syntax
error, insert "}" to complete Block
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (4:134) : Syntax error
on tokens, delete these tokens
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:202) : Syntax error
on token "void", @ expected
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:234) : Syntax error
on token "KnowledgeHelper", ( expected after this token
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:284) : Syntax error
on token "m", delete this token
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:287) : Syntax error
on token(s), misplaced construct(s)
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:309) : Syntax
error, insert ")" to complete MethodInvocation
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:309) : Syntax
error, insert ")" to complete SingleMemberAnnotation
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:309) : Syntax
error, insert "enum Identifier" to complete EnumHeaderName
com/examples/Rule_VeryGoodValue_–_between_6_9_0.java (6:309) : Syntax
error, insert "EnumBody" to complete EnumDeclaration
*Vote.drl*
package com.examples
import com.examples.drools.Vote;
rule "WrongValue – less than 0"
when
m : Vote( average < 0.0, vote : vote )
then
m.setAverage(0.0f);
update( m );
end
rule "WrongValue – bigger than 10"
when
m : Vote( average > 10.0, vote : vote )
then
m.setAverage(10.0f);
update( m );
end
rule "BadValue – between 0-3"
when
m : Vote( average >= 0.0 && average <=3.0, vote : vote )
then
m.setVote("Bad!");
System.out.println( m.getVote() );
end
rule "GoodValue – between 3-6"
when
m : Vote( average >3.0 && average <=6.0, vote : vote )
then
m.setVote("Good!");
System.out.println( m.getVote() );
end
rule "VeryGoodValue – between 6-9"
when
m : Vote( average >6.0 && average <=9.0, vote : vote )
then
m.setVote("Very Good!");
System.out.println( m.getVote() );
end
rule "ExcellentValue – between 9-10"
when
m : Vote( average >9.0 && average <=10.0, vote : vote )
then
m.setVote("Excellent!");
System.out.println( m.getVote() );
end
*
*
15 years, 4 months
Doubt regarding the Email WorkItem in Drool Flow
by Pardeep.Ruhil@lntinfotech.com
Hi,
I have a question regarding the email workItem that is present in the
Drool Flow.
I want to know, does Drool Flow support for sending the emails or we have
to externally provide
the functionality for sending the emails in the WorkItemHandler for email.
If Drool provides the in-built functionality of email sending through the
Email workitem, so where
I have to provide the configuration for SMTP server for sending of Emails
and
other related setting that are required for using the Drools in-built
email functionality.
Thanks & Regards
Pardeep Ruhil
______________________________________________________________________
15 years, 4 months