<br> Greg is right if you want to keep it just using expert features. <br> Now if you model your Singleton as an event, you could use the timestamp instead of create a specific attribute for that:<br><br> oldSingleton : Singleton( $id : id )<br>
newSingleton : Singleton( id == $id, this after oldSingleton )<br>
<br> Or, if you have just a few rules that use your Singleton and you activate the STREAM mode, you could simply use a sliding window:<br><br>rule "my rule that uses the singleton"<br>when<br> $singleton : Singleton( ... ) over window:length(1)<br>
// more patterns...<br>then<br> // do something<br>end<br><br> []s<br> Edson<br><br><br><div class="gmail_quote">2009/8/18 Greg Barton <span dir="ltr"><<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">You need some comparable property in the singleton object that's monotonically increasing. Then you can have a rule like the following that must be of higher salience than the rules you want to protect from duplicate singletons. i.e.:<br>
<br>
rule "EnforceOneSingleton"<br>
when<br>
oldSingleton : Singleton( $id : id, $version : version )<br>
newSingleton : Singleton( id == $id, version > $version)<br>
then<br>
System.out.println( "Retracting old Singleton " + oldSingleton.getId() + " version " + oldSingleton.getVersion());<br>
retract( oldSingleton );<br>
end<br>
<br>
--- On Mon, 8/17/09, Justin King <<a href="mailto:justin.matthew.king@gmail.com">justin.matthew.king@gmail.com</a>> wrote:<br>
<br>
> From: Justin King <<a href="mailto:justin.matthew.king@gmail.com">justin.matthew.king@gmail.com</a>><br>
> Subject: [rules-users] Unique events / facts in working memory<br>
> To: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
> Date: Monday, August 17, 2009, 6:20 PM<br>
<div><div></div><div class="h5">> I'm building an application that will<br>
> over time record changes in a certain component (not at any<br>
> set interval, could occur any time). The component can<br>
> possibly be uniquely identified via some kind of id. Is<br>
> there a way that when I insert an event / fact recording a<br>
> change of state in this component I can remove the previous<br>
> one, so as there is only ever one fact / event recording the<br>
> current state of the component. If the previous one existed<br>
> it may cause rules to fire which should not.<br>
><br>
><br>
> Cheers,<br>
><br>
> Justin<br>
><br>
><br>
</div></div>> -----Inline Attachment Follows-----<br>
><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>
><br>
<br>
<br>
<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>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>