YOu can use collect function. Please refer http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
On 8/26/09, [email protected] < [email protected]> wrote: > > Send rules-users mailing list submissions to > [email protected] > > 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 > [email protected] > > You can reach the person managing the list at > [email protected] > > 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 <[email protected]> > Subject: [rules-users] Rule for Collection > To: Rules Users List <[email protected]> > Message-ID: > <[email protected]> > 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/f74f64ca/attachment-0001.html > > ------------------------------ > > Message: 2 > Date: Wed, 26 Aug 2009 09:34:33 -0700 (PDT) > From: nestabur <[email protected]> > Subject: [rules-users] Using KnowledgeAgent with Stateful session > To: [email protected] > Message-ID: <[email protected]> > 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-tp25151447p25151447.html > 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 <[email protected]> > Subject: Re: [rules-users] Cannot view Process Definitions in > gwt-console > To: [email protected] > Message-ID: <[email protected]> > 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 <[email protected]>: > > > >> > >> 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/defaultPackage/LATEST > '] > >> 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.dialectruntimeregis...@198046 > >> name = defaultPackage > >> imports = > >> {defaultpackage.*=org.drools.rule.importdeclarat...@d75e0360} > >> staticImports = [] > >> functions = {} > >> factTemplates = {} > >> ruleFlows = {} > >> globals = {} > >> valid = true > >> rules = {} > >> classFieldAccessorStore = > >> org.drools.base.classfieldaccessorst...@34b350 > >> //org.drools.rule.Package.readExternal - End > >> -- > >> View this message in context: > >> > > > http://www.nabble.com/Cannot-view-Process-Definitions-in-gwt-console-tp25056005p25056005.html > >> Sent from the drools - user mailing list archive at Nabble.com. > >> > >> _______________________________________________ > >> rules-users mailing list > >> [email protected] > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > > > > > > > > > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > > _______________________________________________ > > rules-users mailing list > > [email protected] > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > -- > View this message in context: > http://www.nabble.com/Cannot-view-Process-Definitions-in-gwt-console-tp25056005p25152800.html > 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 <[email protected]> > Subject: Re: [rules-users] Using KnowledgeAgent with Stateful session > To: Rules Users List <[email protected]> > Message-ID: <[email protected]> > 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-tp25151447p25151447.html > > Sent from the drools - user mailing list archive at Nabble.com. > > > > _______________________________________________ > > rules-users mailing list > > [email protected] > > 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/f3daf7ee/attachment.html > > ------------------------------ > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > > End of rules-users Digest, Vol 33, Issue 81 > ******************************************* >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
