[rules-users] Unique events / facts in working memory
Greg Barton
greg_barton at yahoo.com
Tue Aug 18 00:06:24 EDT 2009
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.:
rule "EnforceOneSingleton"
when
oldSingleton : Singleton( $id : id, $version : version )
newSingleton : Singleton( id == $id, version > $version)
then
System.out.println( "Retracting old Singleton " + oldSingleton.getId() + " version " + oldSingleton.getVersion());
retract( oldSingleton );
end
--- On Mon, 8/17/09, Justin King <justin.matthew.king at gmail.com> wrote:
> From: Justin King <justin.matthew.king at gmail.com>
> Subject: [rules-users] Unique events / facts in working memory
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Date: Monday, August 17, 2009, 6:20 PM
> I'm building an application that will
> over time record changes in a certain component (not at any
> set interval, could occur any time). The component can
> possibly be uniquely identified via some kind of id. Is
> there a way that when I insert an event / fact recording a
> change of state in this component I can remove the previous
> one, so as there is only ever one fact / event recording the
> current state of the component. If the previous one existed
> it may cause rules to fire which should not.
>
>
> Cheers,
>
> Justin
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list