[rules-users] Rule order in DSL file
I used 'salience' key word to control the order of firing in drl file. But it is not working properly when we use both DSL file and DRL file to execute rules. The order of firing is in random manner in DSL file. How to control the order of firing in dsl file? Eg: My requirement consists of 6 [when] [then] conditions in DSL file. If first 3 rules get fired, then only the 4th and 5th rule should fire. Then if 5th rule is fired then 6 rule should execute. How to control this in DSL file? -- View this message in context: http://www.nabble.com/Rule-order-in-DSL-file-tf3876953.html#a10985646 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] Extracting an object in the working memory for multiple times
I asserted 3 object in the working memory and I iterate it to check a value in that object for a condition in the first rule. I need to iterate all the objects in the working memory again for another condition in the second rule. But the objects are not iterating in the second rule. There is any condition that an asserted object can be used only once? -- View this message in context: http://www.nabble.com/Extracting-an-object-in-the-working-memory-for-multiple-times-tf3871503.html#a10968613 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] Use of the same reference in multipe rules
I asserted 3 class (Class1, Class2, Class3) in the working memory. I make an reference for the class (Class1) in the first rule. Is it possible to use the same reference in the 2nd rule? Eg: [when] class : Class1() eval(class.getVarName1() == {value1}); [then] .do something... [when] eval(class.getVarName2() == {value2}); [then] ...do something My requirement is to use the same class (Class1) in all the rules. I don't want to iterate other two classes (Class2 Class3) in rule 2. -- View this message in context: http://www.nabble.com/Use-of-the-same-reference-in-multipe-rules-tf3871632.html#a10968978 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] Use of the same reference in multipe rules
I asserted 3 class (Class1, Class2, Class3) in the working memory. I make an reference for the class (Class1) in the first rule. Is it possible to use the same reference in the 2nd rule? Eg: [when] class : Class1() eval(class.getVarName1() == {value1}); [then] .do something... [when] eval(class.getVarName2() == {value2}); [then] ...do something My requirement is to use the same class (Class1) in all the rules. I don't want to iterate other two classes (Class2 Class3) in rule 2. -- View this message in context: http://www.nabble.com/Use-of-the-same-reference-in-multipe-rules-tf3873426.html#a10974992 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] Extracting an object in the working memory for multiple times
I asserted 3 object in the working memory and I iterate it to check a value in that object for a condition in the first rule. I need to iterate all the objects in the working memory again for another condition in the second rule. But the objects are not iterating in the second rule. There is any condition that an asserted object can be used only once? If yes, then can anyone explain how to assert those objects into working memory for the second time? -- View this message in context: http://www.nabble.com/Extracting-an-object-in-the-working-memory-for-multiple-times-tf3873441.html#a10975027 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] Accessing an object in multiple rule
Hi, I asserted 4 objects of a class with class name “DemoClass” in to working memory. In rule one I am creating a reference for the DemoClass and implementing the logic. In rule2,… I am creating another reference of the DemoClass .so that time it is accessing the next asserted object present in the workingmemory. But my requirement is to access the same object which is accessed in rule 1. I don't need to access other 3 objects in working memory. It is possible to access the same object in rule 2, which I accessed in rule 1? -- View this message in context: http://www.nabble.com/Accessing-an-object-in-multiple-rule-tf3866060.html#a10952423 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] Order of firing rules
Hi, If we wrote 6 [when] [then] rules in an drl file, there is any order in firing the rules or the rules get fired in random? If it is fired in random, there is any method or keywords to control the order of firing the rules? -- View this message in context: http://www.nabble.com/Order-of-firing-rules-tf3866064.html#a10952429 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] Use of Relational operator in Drools
How to check a variable in a class contains any of the four or five value. I tried the below codes, but it throws error. Codes context : Context(state == Context.START_UP) exists Classname(varName : 1 || 2 || 3) context : Context(state == Context.START_UP) exists Classname(varName : 1 || varName : 2 || varName : 3) There is anyother alternate way to check this condition? -- View this message in context: http://www.nabble.com/Use-of-Relational-operator-in-Drools-tf3851675.html#a10910936 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] Use of if else condition in drools
How to use if else conditions in one [when] [then] condition in drools? Eg: if(something){ do 1} else {do 2} I need to use only one [when] [then] condition. The requirement is like that. -- View this message in context: http://www.nabble.com/Use-of-if-else-condition-in-drools-tf3846333.html#a10893107 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] Unexpected Token Exception
I got the following exception when I tried to run the drl file rule. org.drools.rule.InvalidRulePackage: unknown:13:37 mismatched token: [EMAIL PROTECTED],307:308='',55,13:37]; expecting type ')' unknown:13:81 Unexpected token ')' at org.drools.rule.Package.checkValidity(Unknown Source) at org.drools.common.AbstractRuleBase.addPackage(Unknown Source) at com.sample.DroolsTest.main(DroolsTest.java:47) Rule: package com.policy; #expander Ex1.dsl; #list any import classes here. #import java.util.HashMap; import java.util.Iterator; import com.examples.Student; import com.examples.Module; #declare any global variables here global java.util.List errorlist; rule Ex1 when exists( $student : Student() Module( student == $student, score 40 )) then System.out.println(fierd); end Files: Class 1: package com.examples; public class Student { private String name; private Object[] modules; public Object[] getModules() { return modules; } public void setModules(Object[] modules) { this.modules = modules; } public String getName() { return name; } public void setName(String name) { this.name = name; } } class 2: package com.examples; public class Module { private String name; private String studentName; private int score; public Module(String name, int score){ this.setName(name); this.setScore(score); } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public String getStudentName() { return studentName; } public void setStudentName(String studentName) { this.studentName = studentName; } } Anyone have any idea about it -- View this message in context: http://www.nabble.com/Unexpected-Token-Exception-tf3848843.html#a10901896 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] Logic behind the Rule
Following is the Example taken form the following URL: http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.1/html_single/index.html#d0e2144 But this rule is not working for me. If anyone know the logic behind the rule, please explain me. Example: Imagine we have two classes - Student and Module. Module represents each of the courses the Student attended for that semester, referenced by the List collection. At the end of the semester each Module has a score. If the Student has a Module score below 40 then they will fail that semester - the existential quantifier can be used used with the less than 40 open proposition to check for the existence of a Module that is true for the specified criteria. public class Student { private String name; private List modules; ... } public Class Module { private String name; private String studentName; private int score; Java is Turing complete in that you can write code, among other things, to iterate data structures to check for existence. The following should return a List of students who have failed the semester. List failedStudents = new ArrayList(); for ( Iterator studentIter = students.iterator(); studentIter.hasNext() { Student student = ( Student ) studentIter.next(); for ( Iterator it = student.getModules.iterator(); it.hasNext(); ) { Module module = ( Module ) it.next(); if ( module.getScore() 40 ) { failedStudents.add( student ) ; break; } } } Early SQL implementations where not Turing complete as they did not provide quantifiers to asses the structure of data. However modern SQL engines allow nesting of SQL which can be combined with keywords like 'exists' and 'in': The following query would return a set of Students who have failed the semester. select * from Students s where exists ( select * from Modules m where m.student_name = s.name and m.score 40 ) rule when exists( $student : Student() Module( student == $student, score 40 ) ) -- View this message in context: http://www.nabble.com/Logic-behind-the-Rule-tf3848998.html#a10902431 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] Removing Child Class Objects in dsl file level
My Code has the following Hierarchy. I am facing some problem, while I try to remove the Child level class object in .dsl file level. Class1: public class Class1{ private Class2 class2; //getter setters for class2 } Class2: public class Class2{ Private Class3 class3; //getter setters for class3 } Class3: public class Class3{ Object[] class4; //getter setters for class4 } Class4: public class Class4{ private String variable; //getter setters for variable } I will get only the object of Class1 in dsl level. When I try to remove the variable in Class4, I am facing some problem. I need to iterate the variable in Class4 and check weather all the values in the list of variable are same. workingMemory.assertObject(class1); // in test class I was not suppose to assert the object of Class2 or Class3 or Class4. [when]Some English Text = Class1(cl2 : class2) //in .dsl file [then]Log {message}=System.out.println({message}); //in .dsl file I tried the above code. But I can remove only the Class2 from Class1. I can’t remove the Class3 from Class2 Class4 from Class3 for futher iteration. Can some one help me on this issue? Thanks. -- View this message in context: http://www.nabble.com/Removing-Child-Class-Objects-in-dsl-file-level-tf3797470.html#a10741683 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] Extracting an boolean variable
I tried to extract a boolean variable from a class using context. The following is my code in DSL file. context : Context(state == START_UP) Classname(aliasname : booleanVariableName) When I tried to run this statement I got the following error message in DRL file. Error Message: Unable to Create Field Extractor for 'booleanVariableName'. But when I tried to extract a String Variable the Error is cleared. Can Someone explain me about this problem in Drools. Thanks. -- View this message in context: http://www.nabble.com/Extracting-an-boolean-variable-tf3827902.html#a10835911 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