Thank you that worked out nicely =)<br><br>//Johan<br><br><div class="gmail_quote">2012/3/12 Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You can save the FactHandle returned from the insert() and retract that.<br>
<br>
Or you can retrieve the FactHandle via the WorkingMemorEntryPoint<br>
method getFactHandle( Object obj ).<br>
<div class="im HOEnZb"><br>
-W<br>
<br>
<br>
<br>
On 12/03/2012, Spade87 &lt;<a href="mailto:johan.spade@gmail.com">johan.spade@gmail.com</a>&gt; wrote:<br>
</div><div class="HOEnZb"><div class="h5">&gt; Using that rule worked, sort of... It correctly removes all of the objects<br>
&gt; in<br>
&gt; the working memory. The problem is that it clears everything... If you use<br>
&gt; mule together with drools the drools module will send back whatever you sen<br>
&gt; to it to mule when there are no more rules fireing. If I delete everything<br>
&gt; as a last step then I wont get my modified data back. Right now i have one<br>
&gt; method that takes a WorkingMemory and a collection and inserts everything<br>
&gt; from the collection in the working memory.<br>
&gt;<br>
&gt; *Rule*<br>
&gt; rule &#39;addAllFromCollection&#39;<br>
&gt; when<br>
&gt;       c : MyCollection ( newCollection == true )<br>
&gt; then<br>
&gt;       DroolsUtil.insertCollection(drools.workingMemory, c )<br>
&gt; end<br>
&gt;<br>
&gt; *JavaCode*<br>
&gt; public static void insertCollection(WorkingMemory workingMemory, Collection<br>
&gt; collection) {<br>
&gt;       Iterator iterator = collection.iterator();<br>
&gt;       while (iterator.hasNext()) {<br>
&gt;               workingMemory.insert(iterator.next());<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt; Basically what i want to do is write a corresponding function to retract<br>
&gt; everything that is old<br>
&gt;<br>
&gt; *Rule*<br>
&gt; rule &#39;retractAllFromCollection&#39;<br>
&gt; when<br>
&gt;       c : MyCollection ( newCollection == false )<br>
&gt; then<br>
&gt;       DroolsUtil.retractCollection(drools.workingMemory, c )<br>
&gt; end<br>
&gt;<br>
&gt; *JavaCode*<br>
&gt; public static void retractCollection(WorkingMemory workingMemory, Collection<br>
&gt; collection) {<br>
&gt;       Iterator iterator = collection.iterator();<br>
&gt;       while (iterator.hasNext()) {<br>
&gt;               workingMemory.retract(iterator.next());<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt; The problem is that the method workingMemory.retract() doesn&#39;t take a<br>
&gt; argument but a FactHandle as an argument but if i try something like<br>
&gt;<br>
&gt; *JavaCode*<br>
&gt; public static void retractCollection(WorkingMemory workingMemory) {<br>
&gt;       Collection collection = workingMemory.getFactHandles();<br>
&gt;       Iterator iterator = collection.iterator();<br>
&gt;       while (iterator.hasNext()) {<br>
&gt;               workingMemory.retract(iterator.next());<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt; I get a rather strange exception<br>
&gt; java.lang.UnsupportedOperationException: this is implementedby<br>
&gt; StatefulKnowledgeImpl<br>
&gt;       at<br>
&gt; org.drools.reteoo.ReteooWorkingMemory.getFactHandles(ReteooWorkingMemory.java:363)<br>
&gt;       at<br>
&gt; se.sunstone.ebs.mama.oneqc.drools.DroolsUtil.insertCollection(DroolsUtil.java:21)<br>
&gt;       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
&gt;<br>
&gt; Any thoughts?<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context:<br>
&gt; <a href="http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3819245.html" target="_blank">http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3819245.html</a><br>
&gt; Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>RF kap. 2 §6 Varje medborgare är gentemot det allmänna skyddad mot påtvingat kroppsligt ingrepp även i annat fall än som avses i 4 och 5 §§. Han är därjämte skyddad mot kroppsvisitation, husrannsakan och liknande intrång samt mot undersökning av brev eller annan förtrolig försändelse och mot hemlig avlyssning eller upptagning av telefonsamtal eller annat förtroligt meddelande. Lag (1976:871).<br>
<br>