This is all very well, but why does it have to be so complicated?<br><br>rule createFacts<br>when<br>then<br> for( String s: new String[]{ "one", "two", "three" } ){<br> insert( new Fact( s ) );<br>
}<br>end<br><br>This rule executes once. Presumably you'll use a very high salience. The condition might contain CEs to make this happen depending on whatever.<br><br>It's doable from a spreadsheet, using the "forall" substitution.<br>
<br>-W<br><br><br><div class="gmail_quote">On 9 March 2011 09:41, FrankVhh <span dir="ltr"><<a href="mailto:frank.vanhoenshoven@agserv.eu">frank.vanhoenshoven@agserv.eu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
The way I understand your question, you want to evaluate some string value<br>
to a list of Strings, and insert an "alarm" in the form of a new object to<br>
notify that these values are present.<br>
<br>
This is possible. Insert a String into working memory, then call the<br>
following rule:<br>
<br>
#Testing rule<br>
rule "test"<br>
when<br>
$vals: String(this in ("help","support","assist"))<br>
not Fact(value == $vals )<br>
then<br>
insert ( new Fact ( $vals ) );<br>
System.out.println("This WORKS!");<br>
end<br>
<br>
The rule checks for a String in working memory, and evaluates its contents (<br>
this in ( list ) ) . If a Fact with the corresponding value hasn"t been<br>
inserted yet, it will be inserted at runtime.<br>
<br>
Regards,<br>
Frank<br>
<br>
<br>
groovenarula wrote:<br>
><br>
> Hello all,<br>
><br>
> In one of my use cases, I need to insert a variable collections of facts<br>
> into working memory in order to be able to test for those values later :<br>
><br>
> So I was wondering if there's a way to do something like this<br>
><br>
> when<br>
> $vals : String() from [ "A 12345", "B 45678", "C 8695" ]<br>
> then<br>
> insert ( new Fact ( $vals ) );<br>
><br>
> With the intention that the rule will fire 3 times and insert the 3 new<br>
> facts with the values " A 12345" and "B 45678" and "C 8695".<br>
><br>
> Is this possible using rules or do I have to resort to using functions.<br>
> The problem I'm trying to overcome is to see if there's a way to get the<br>
> "A 12345", "B 45678", "C 8695" from a single cell of a spreadsheet.<br>
><br>
> Thanks in advance,<br>
> G<br>
><br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Is-it-possible-to-Iteriate-over-a-list-of-string-values-tp2654135p2654347.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Is-it-possible-to-Iteriate-over-a-list-of-string-values-tp2654135p2654347.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>