[rules-users] Using object.getter in Decision table
Hi, I have a scenario, where for decision table I will inject one object which holds all facts. Using those facts the decision table has rules. How to retrieve the child fact from parent in decision table. sample for this is as follows Java Code snippet: DataObject dataObj = new DataObject(); Fact1 fact1 = new Fact1(); Fact2 fact2 = new Fact2(); dataObj.setFact1(fact1); dataObj.setFact2(fact2); statelessKnowledgeSession.execute(dataObj); In decision table: --- CONDITION fact1 : DataObject().getFact1(); fact1.getData1().equalsIgnoreCase($param) Hello Here I am getting error. Please suggest me how to access the child fact from parent fact in decision table. -- View this message in context: http://drools.46999.n3.nabble.com/Using-object-getter-in-Decision-table-tp3392337p3392337.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] Using object.getter in Decision table
Why are you using an extra data object -its far easier if your facts are actually facts in the working memory. What you have written as your rules is totally incorrect - you seem to be trying to write java method calls not rule statements. My advice is to a) try writing the same rule as a drl first before trying to represent it in a spreadsheet b) look at the intermediate drl that the spreadsheet compiler produces to get a better understanding of the output that the spreadsheet produces. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of jilani Sent: 04 October 2011 07:43 To: rules-users@lists.jboss.org Subject: [rules-users] Using object.getter in Decision table Hi, I have a scenario, where for decision table I will inject one object which holds all facts. Using those facts the decision table has rules. How to retrieve the child fact from parent in decision table. sample for this is as follows Java Code snippet: DataObject dataObj = new DataObject(); Fact1 fact1 = new Fact1(); Fact2 fact2 = new Fact2(); dataObj.setFact1(fact1); dataObj.setFact2(fact2); statelessKnowledgeSession.execute(dataObj); In decision table: --- CONDITION fact1 : DataObject().getFact1(); fact1.getData1().equalsIgnoreCase($param) Hello Here I am getting error. Please suggest me how to access the child fact from parent fact in decision table. -- View this message in context: http://drools.46999.n3.nabble.com/Using- object-getter-in-Decision-table-tp3392337p3392337.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 ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using object.getter in Decision table
Thank You for your reply. I am trying to access all the facts through one fact, actually the scenario is we have multiple screens in our application and each screen will have multiple fields where we want to show/hide the screen/field based on data provided in screens. So Instead of sending each screen data separate, We thought of sending the parent object and inside the rules(i.e decision table) we want to access the data of specific screen. As mentioned by you, I am using the intermediate DRL output using below code SpreadsheetCompiler sc = new SpreadsheetCompiler(); String drlstr = null; try { drlstr = sc.compile(ResourceFactory.newClassPathResource(decisionTableSheet, this.getClass()).getInputStream(), InputType.XLS); } Here it is giving the rule parse exception and returning the package as null. Coming to DRL, I am facing difficulty in defining rules like scenarios as below - null check - need to use java String methods like equals() and length() - setting data in HashMap, ArrayList Actually I tried the above using a rule definition in Guvnor. It would be helpful If you can provide me the URL or some information to write rules using DRL. My Development environment: Drools 5.2 Eclipse with JBoss tools -- View this message in context: http://drools.46999.n3.nabble.com/Using-object-getter-in-Decision-table-tp3392337p3392506.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] Using object.getter in Decision table
The best place to start is the drools documentation http://www.jboss.org/drools/documentation particularly the expert guide. This shows both drl and spreadsheet syntax and examples. You are getting the exception because the first line of the condition should just be an object restriction eg fact1 : DataObject() Your second line is then a restriction on that data object. What you send from your screen and what you insert into the working memory doesn't have to be identical. Your screen may use a single object to relay the object but that doesn't mean you can't explode it into separate facts as you insert it into your working memory, but it depends on what you are trying to achieve - are these just validation rules or are you going to be modifying the objects? Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of jilani Sent: 04 October 2011 09:43 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Using object.getter in Decision table Thank You for your reply. I am trying to access all the facts through one fact, actually the scenario is we have multiple screens in our application and each screen will have multiple fields where we want to show/hide the screen/field based on data provided in screens. So Instead of sending each screen data separate, We thought of sending the parent object and inside the rules(i.e decision table) we want to access the data of specific screen. As mentioned by you, I am using the intermediate DRL output using below code SpreadsheetCompiler sc = new SpreadsheetCompiler(); String drlstr = null; try { drlstr = sc.compile(ResourceFactory.newClassPathResource(decisionTableSheet, this.getClass()).getInputStream(), InputType.XLS); } Here it is giving the rule parse exception and returning the package as null. Coming to DRL, I am facing difficulty in defining rules like scenarios as below - null check - need to use java String methods like equals() and length() - setting data in HashMap, ArrayList Actually I tried the above using a rule definition in Guvnor. It would be helpful If you can provide me the URL or some information to write rules using DRL. My Development environment: Drools 5.2 Eclipse with JBoss tools ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using object.getter in Decision table
Thomas, The best place to start is the drools documentation http://www.jboss.org/drools/documentation particularly the expert guide. This shows both drl and spreadsheet syntax and examples. - Yes. I have downloaded all the drools info from here. then I got one expert pdf document in reference folder of final distribution. I think it is the same in above URL. Here as mentioned in the document I have defined rules in repository using Guvnor and then tried to access the knowledgebase using knowledgeAgent, which I failed to access from web application where as from console application it is working. You are getting the exception because the first line of the condition should just be an object restriction eg fact1 : DataObject() Your second line is then a restriction on that data object. - that means I can not get the child fact from a parent object as I tried. As of now the only way is I need to insert the facts as and when rule needs it and then retract that. Please correct me If I am missing anything in my understanding. What you send from your screen and what you insert into the working memory doesn't have to be identical. Your screen may use a single object to relay the object but that doesn't mean you can't explode it into separate facts as you insert it into your working memory, but it depends on what you are trying to achieve - are these just validation rules or are you going to be modifying the objects? I am modifying the object, so that based on that object state some functionality has to be done in next layer. what I am trying to achieve is generic rule util methods for my application to use these methods across different method calls. Thank You Jilani -- View this message in context: http://drools.46999.n3.nabble.com/Using-object-getter-in-Decision-table-tp3392337p3392738.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