hello <br>first thank you for your help.<br>But I don't know how declare the wariable.<br>workingMemory.setGlobal("L", new java.util.List());<br>the code used to execute my rule is :<br><br> public List fireRules(List dataObjects, InputStream rules) throws Exception { <br> // obtain the rule service provider<br> RuleServiceProviderManager.registerRuleServiceProvider(<br> "org.drools.jsr94.rules.RuleServiceProviderImpl",<br> org.drools.jsr94.rules.RuleServiceProviderImpl.class);<br> RuleServiceProvider service = <br> RuleServiceProviderManager.getRuleServiceProvider(<br>
"org.drools.jsr94.rules.RuleServiceProviderImpl"); <br> // load the rule adminstrator <br> RuleAdministrator admin = service.getRuleAdministrator(); <br> // load the rules and register them <br> RuleExecutionSet res1 =<br> admin.getLocalRuleExecutionSetProvider( null ).<br> createRuleExecutionSet( rules, null );<br> rules.close(); <br> String bindUri = "res:://sample.drl";<br> admin.registerRuleExecutionSet(bindUri, res1, null); <br> // obtain a rule runtime object from the rule
service provider <br> RuleRuntime runtime = service.getRuleRuntime(); <br> // create a stateless object from the Rule Runtime <br> StatelessRuleSession session = (StatelessRuleSession)<br> runtime.createRuleSession(bindUri, null, RuleRuntime.STATELESS_SESSION_TYPE); <br> List resultRules = session.executeRules(dataObjects);<br> //session.<br> session.release();<br> // workingMemory.setGlobal("L", new java.util.List()); <br> return resultRules; <br> }<br>please help me,<br>best regards
<br>Ismail<br><br><b><i>Scott Reed <sreed@spamcop.net></i></b> a écrit :<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> fakhfakh ismail's message received 5/14/2007 3:48 PM:<br>> Hello,<br>> first sorry for my bad english.<br>> I want to declare a variable of type List<br>> <br>> rule "userrole"<br>> <br>> when<br>> $user1: User (userid1: userId)<br>> $user2: User (userId == userid1)<br>> then<br>> List L = new ArrayList();<br>> if (L.contains($user1.getname())== false)<br>> {<br>> L.add($user1.getname());<br>> System.out.println("hello");<br>> }<br>> end<br>> <br>> the problem is everytime the List don't save all element every execution <br>> the variable list is intialised as empty is there other place to <br>> declare List?<br>> (I try after when but error of
parsing)<br><br>You need to declare the List in your Java code, set it as a Drools global, and declare it in the DRL <br>file:<br><br>In yourjava.java:<br>-----------<br>workingMemory.setGlobal("L", new java.util.List());<br>-----------<br><br>in yourdrl.drl:<br>-----------<br>global java.util.List L;<br><br>rule "userrole"<br><br>when<br> $user1: User (userid1: userId)<br> $user2: User (userId == userid1)<br> then<br> if (L.contains($user1.getname())== false)<br> {<br> L.add($user1.getname());<br> System.out.println("hello");<br> }<br>end<br>-----------<br><br>Wouldn't it be great to have a "static" section in the DRL syntax for temporaries like this?<br>_______________________________________________<br>rules-users mailing list<br>rules-users@lists.jboss.org<br>https://lists.jboss.org/mailman/listinfo/rules-users<br></blockquote><br><p> 
<hr size="1">
Ne gardez plus qu'une seule adresse mail ! <a href="http://www.trueswitch.com/yahoo-fr/">Copiez vos mails</a> vers Yahoo! Mail