[rules-users] Problem in using genrics with drools4.0.1.
HI ALL, I am using drool 4.0.1 in my project. I am facing problem in using generics feature of jdk1.5. My objective is to perform validation on the basis of data type of variable. for storing values of variable i have one Attribute Class it contains getter setter for values of attribute and attributeId which is a string but value of attribute is of deferent type so i am thinking to use generics here. public class AttributeT { public String qualifiedName; public T newValue; public T oldValue; public String getQualifiedName() { return qualifiedName; } public void setQualifiedName(String qualifiedName) { this.qualifiedName = qualifiedName; } public T getNewValue() { return (T)newValue; } public void setNewValue(T newValue) { this.newValue = newValue; } public T getOldValue() { return oldValue; } public void setOldValue(T oldValue) { this.oldValue = oldValue; } } my rule for date comparison looks like: //Date Comparison. rule W250.1 DateComparison when $dto : DataProvider() Attribute(newValue 29-Oct-2007) from $dto.getValue(W250.1) then System.out.println (Error in Date check \t); end DataProvider class it is responsible to give instance of attribute corresponding to attributeId: public class DataProvider { HashMapString,Attribute fieldMap=new HashMapString, Attribute(); public DataProvider() { populateMap(); } public Attribute getValue(String qualifiedName){ Attribute attribute = fieldMap.get(qualifiedName); return attribute; } public void populateMap(){ AttributeDate attribute = new AttributeDate(); SimpleDateFormat format = new SimpleDateFormat(dd-MMM-); Date date; try { date = format.parse(27-Oct-2007); attribute.setQualifiedName(W250.1); attribute.setOldValue(date); attribute.setNewValue(date); fieldMap.put(attribute.getQualifiedName(),attribute); } catch (ParseException e) { e.printStackTrace(); } } } in this case i am getting exception: Exception in thread main java.lang.ClassCastException: java.lang.String when i am not using generics this rule is working fine. but in this case how should i perform validation depending upon data type of attribute. can you please help me in solving this problem. Thanks, Gaurav Joshi -- View this message in context: http://www.nabble.com/Problem-in-using-genrics-with-drools4.0.1.-tf4586550.html#a13092212 Sent from the drools - user 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] Problem in using or operator with values in map.
Hi All, I am using drool 4.0.1,I am facing some problem in using or operator i am using 2 maps by inserting in to working memory: 1) ErrorMapString,String 2) validationmapString,Object my requirment is to generate error when rule fails for this i am taking following steps: 1) i insert one entry in error map in when part and if that rule is success 2)i remove that entry from map and 3) at the end on the basis of this map i generates validation errors. import java.util.Map; import com.IValidationField; rule ValueAllowed_G10.3 when IValidationField(attributeId ==G10.3) $map : Map( keySet contains ErrorMap ) eval($map.put(G10.3_V,E_V_ALLOWED) == null || true) (or Map( this[G10.2] not in(5)) Map( this[G10.2] in(5))) then map.remove(G10.3_V); System.out.println(comming here-); end this file is giving classcast exception org.drools.RuntimeDroolsException: java.lang.ClassCastException: com.ValidationFieldImpl at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:75) at org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:141) at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(SingleTupleSinkAdapter.java:20) at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:120) but when i replace or with and operator then it is working fine: import java.util.Map; import com.IValidationField; rule ValueAllowed_G10.3 when IValidationField(attributeId ==G10.3) $map : Map( keySet contains ErrorMap ) eval($map.put(G10.3_V,E_V_ALLOWED) == null || true) (and Map( this[G10.2] not in(5)) Map( this[G10.2] in(5))) then map.remove(G10.3_V); System.out.println(comming here-); end -- View this message in context: http://www.nabble.com/Problem-in-using-or-operator-with-values-in-map.-tf4472442.html#a12752031 Sent from the drools - user 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] how to perform some task when rule fails.
Hi All, My requirment is that i want to send corresponding error when any rule fails. for example: rule ValidationRuleExp_G250.4_0 when IValidationField(attributeId ==G250.4) (((Map( this[G250.18] !=4))(Map( this[G250.4]not in(910,990,983,995,996,997||((Map( this[G250.18] ==4))(Map( this[G250.4] in(910,990,983,995,996,997) then System.out.println(comming here---Success--); end In this case i can call some method in success,Is there any way so that i can call some method when any rule fails. the problem is that i am trying to generate rule file and all the validation expressions are already defined. my task is to evaluate these expression and generate corresponding error message when any rule fails can you please suggest me how can i do this using drools. Thanks, Gaurav -- View this message in context: http://www.nabble.com/how-to-perform-some-task-when-rule-fails.-tf4475301.html#a12760314 Sent from the drools - user 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] How to use not operator in drool.
Hi ALL, I am using drool4.0.1 in my application i am able to use IN,OR,AND operator but i am facing problem in using not operator. my requirement of not operator is just like a not gate. the way i am using it is : eval(not((Map( this[city] !=mumbai))||(Map( this[city] ==delhi so can you please help me out to solve this problem: should i use not operator or some thing else in drool. Thanks, -- View this message in context: http://www.nabble.com/How-to-use-not-operator-in-drool.-tf4430240.html#a12638430 Sent from the drools - user 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] probliem in using in and not in operator in drool file.
Hi All, I am using drool4.0.1 in my application, I have one map in global memory this map contains mapping of id and value,i want to validate these values. but when i am using in and not in rule like: eval(validatorMap.get(name) not in(amit,siddhartha)) where validatorMap is a map of id and value inserted in global memory. it is giving following error: org.drools.rule.InvalidRulePackage: Rule Compilation error : [Rule name=Short Name, agendaGroup=MAIN, salience=0, no-loop=false] com/telekurs/nva/mde/fe/ak/validation/Rule_Short_Name_0.java (8:330) : The left-hand side of an assignment must be a variable com/telekurs/nva/mde/fe/ak/validation/Rule_Short_Name_0.java (8:357) : Syntax error on token not, invalid AssignmentOperator please help me how to validate value from a map using in and not in operator of drool. Thanks. -- View this message in context: http://www.nabble.com/probliem-in-using--%22in%22-and-%22not-in%22-operator-in-drool-file.-tf4421498.html#a12611458 Sent from the drools - user 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] Usage of Drools in a RCP project
i am also working in same technology i am not able to use service of one plug-in from another in following cases : 1) export the required package of dependent plug-in, 2) add all the required jars in classpath from runtime tab of mainfest.mf file of your plugin. 3) in run time configuration of application required plug-in is not selected. gurks wrote: I'm working on a RCP project and now want to integrate Drools. There are two plugins: CORE and UI. The initialization of Drools is done in a Manager class in the core plugin. The same plugin also has a class named Service. This class should be imported in a DRL-file. The Manager is first called in the UI plugin but don't think that's the problem. The Drools jars are placed in its own plugin and the other two plugins are augemnted with the dependency needed. When I try to initialize the ruleBase I get the following exception: org.drools.rule.InvalidRulePackage: Unable to resolve ObjectType 'Service' : [Rule name=Your First Rule, agendaGroup=MAIN, salience=0, no-loop=false] Rule Compilation error : [Rule name=Your First Rule, agendaGroup=MAIN, salience=0, no-loop=false] at/mcw/jdent/services/core/persistent/Rule_Your_First_Rule_0.java (2:55) : Only a type can be imported. test.core.persistent.Service resolves to a package at/mcw/jdent/services/core/persistent/Rule_Your_First_Rule_0.java (7:342) : $serviceName cannot be resolved [EMAIL PROTECTED] at org.drools.rule.Package.checkValidity(Package.java:408) at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:288) ... I don't know why Drools does not find my Service class. It's in the same plugin as the manager and should be visible to it. Could anybody give me an advice how I can integrate Drools into my RCP project correctly. Thanx, gurks -- View this message in context: http://www.nabble.com/Usage-of-Drools-in-a-RCP-project-tf4383352.html#a12497050 Sent from the drools - user 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] how to generate rool.drl file from regular expression in excel sheet.
Hi All, I am using drool4.0.1 right now i am writing rool.drl file from the regular expression in excel sheet but now i want to automate this process. can you help me what is the right way to do this automation. Thanks, Gaurav -- View this message in context: http://www.nabble.com/how-to-generate-rool.drl-file-from-regular-expression-in-excel-sheet.-tf4383816.html#a12497180 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users