Re: [rules-users] Decision table call external method
In Guvnor, or just using drools-decisiontables? On 10 May 2012 13:05, SuperGG wrote: > Hi, > > I'm being stuck this past days with a little problem that I hope you will > be > able to help me out. > I'm trying to call a non static method from a class in the action part. > > I have tried to import it, to put it as a variable or to insert it into the > ksession but I wasn't able to make it work. > > Someone can explain me how I should proceed ? > > Thanks in adance. > > Bye > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
I did a drools project on eclipse, so I guess it's just drools-decisiontables. -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979352.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
According to your post, I guess that your problem is not really for editing the table, but at runtime the table does not behave like expected, yes ? Could you post your table and the resulting DRL, and explain a bit more what you have tried to do ? - Mail original - De: "SuperGG" À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 10:47:01 Objet: Re: [rules-users] Decision table call external method I did a drools project on eclipse, so I guess it's just drools-decisiontables. -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979352.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
http://drools.46999.n3.nabble.com/file/n3979822/Sans_titre.jpg I have this decision table. I have a Class XMLTool which contains static fields as SICF and some methods (non static) as addNodes(String str); I don't find the way to use the method addNodes in my decision table. (I import all the good classes) I tried several stuff but no success. I'm sure there is one good way to do it. Thx -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979822.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
In ACTION, you can use : - static methods - non-static method on a previous matched objects using "addNode(...)" like this is nonsense, even in plain java If your addNode method applies to your matched Service object (which you binded to variable "s"), use "s.addNode(...)" Otherwise, you have to get the object in which this method is defined in order to call it - Mail original - De: "SuperGG" À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 14:43:06 Objet: Re: [rules-users] Decision table call external method http://drools.46999.n3.nabble.com/file/n3979822/Sans_titre.jpg I have this decision table. I have a Class XMLTool which contains static fields as SICF and some methods (non static) as addNodes(String str); I don't find the way to use the method addNodes in my decision table. (I import all the good classes) I tried several stuff but no success. I'm sure there is one good way to do it. Thx -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979822.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
Sorry, I read too fast ... You have addNode(...) on XMLTool ? So you have to get a XMLTool somewhere in CONDITION or make it a global variable, or a java singleton, or link it with your service. If you can't do all previous, then you will have to find a trick to match it in your conditions, but it will be a trick ... - Mail original - De: "Vincent LEGENDRE" À: "Rules Users List" Envoyé: Vendredi 11 Mai 2012 15:06:35 Objet: Re: [rules-users] Decision table call external method In ACTION, you can use : - static methods - non-static method on a previous matched objects using "addNode(...)" like this is nonsense, even in plain java If your addNode method applies to your matched Service object (which you binded to variable "s"), use "s.addNode(...)" Otherwise, you have to get the object in which this method is defined in order to call it - Mail original - De: "SuperGG" À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 14:43:06 Objet: Re: [rules-users] Decision table call external method http://drools.46999.n3.nabble.com/file/n3979822/Sans_titre.jpg I have this decision table. I have a Class XMLTool which contains static fields as SICF and some methods (non static) as addNodes(String str); I don't find the way to use the method addNodes in my decision table. (I import all the good classes) I tried several stuff but no success. I'm sure there is one good way to do it. Thx -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979822.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
Thanks for your answer, the only way that worked for me is to get XMLTool in the condition but I have to add a test condition to make it work. Otherwise the object XMLTool is not reconize. Seems weird ... Is it normal ? I'm using drools5.1.1 -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3987610.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
If there is just one object of class XMLTool and all addNode() calls should refer to this single object, you should do what Vincent suggested by making this single object accessible via a DRL global variable, or by using the singleton design pattern (as in Java). Adding this object as a fact and using (by applying tricks) it in the condition isn't the way this is supposed to be done (as you have rightly noticed). -W -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3987626.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
I agree with you but I didn't succeed to do it. Am i using the good syntax : Variables myPackage.XMLTool xmlTool And after in the action I can use xmlTool.addNodes() right ? I don't need to insert the fact in the ksession with this method ? -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3987699.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
On 15/05/2012, SuperGG wrote: > I agree with you but I didn't succeed to do it. > Am i using the good syntax : > > Variables myPackage.XMLTool xmlTool > > And after in the action I can use xmlTool.addNodes() right ? > I don't need to insert the fact in the ksession with this method ? No, but in the Java code where you create the session, you have to create the object and assign it to the DRL variable. See API: setGlobal(...) and the example in the Expert manual. -W > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3987699.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
Ok I will take a look ! Thanks a lot for you help guys. -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3987757.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users