Re: [rules-users] Apply role to whole class hierarchy
Vincent, this issue seems to be fixed as per https://issues.jboss.org/browse/JBRULES-3587 Thanks Joerg Henne 2012/8/6 Vincent LEGENDRE > I had the same strange problem some time ago (last winter), but I never > managed to reproduce a small sample > I checked, and my problematic class hierarchy also lived in different > packages (and never tried that that for my smaller samples). > > -- > *De: *"Joerg Henne" > *À: *rules-users@lists.jboss.org > *Envoyé: *Lundi 30 Juillet 2012 16:04:50 > *Objet: *Re: [rules-users] Apply role to whole class hierarchy > > After some debugging I was able to shed some light on what causes the > problem, even if I don't fully understand it. The problem is produced by > the > event base class, which is declared with @role(event), i.e. (VSCPEvent) > living in a different package than the ButtonEvent. If I move then into the > same package, everything works just fine. > The two package instances are merged in PackageBuilder.mergePackage(...), > but the RuleBuilder still seems to operate on two separate instances, one > with the declarations and Package.isEvent(...) returning true for the > ButtonEvent and the other without them. Unfortunately, as I know too little > about the workings of the various builders, I can't provide you with a > ready-made idea of how to fix the problem. > > See https://issues.jboss.org/browse/JBRULES-3587 > > Thanks > Joerg > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018963.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Apply role to whole class hierarchy
I had the same strange problem some time ago (last winter), but I never managed to reproduce a small sample I checked, and my problematic class hierarchy also lived in different packages (and never tried that that for my smaller samples) . - Mail original - De: "Joerg Henne" À: rules-users@lists.jboss.org Envoyé: Lundi 30 Juillet 2012 16:04:50 Objet: Re: [rules-users] Apply role to whole class hierarchy After some debugging I was able to shed some light on what causes the problem, even if I don't fully understand it. The problem is produced by the event base class, which is declared with @role(event), i.e. (VSCPEvent) living in a different package than the ButtonEvent. If I move then into the same package, everything works just fine. The two package instances are merged in PackageBuilder.mergePackage(...), but the RuleBuilder still seems to operate on two separate instances, one with the declarations and Package.isEvent(...) returning true for the ButtonEvent and the other without them. Unfortunately, as I know too little about the workings of the various builders, I can't provide you with a ready-made idea of how to fix the problem. See https://issues.jboss.org/browse/JBRULES-3587 Thanks Joerg -- View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018963.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Apply role to whole class hierarchy
After some debugging I was able to shed some light on what causes the problem, even if I don't fully understand it. The problem is produced by the event base class, which is declared with @role(event), i.e. (VSCPEvent) living in a different package than the ButtonEvent. If I move then into the same package, everything works just fine. The two package instances are merged in PackageBuilder.mergePackage(...), but the RuleBuilder still seems to operate on two separate instances, one with the declarations and Package.isEvent(...) returning true for the ButtonEvent and the other without them. Unfortunately, as I know too little about the workings of the various builders, I can't provide you with a ready-made idea of how to fix the problem. See https://issues.jboss.org/browse/JBRULES-3587 Thanks Joerg -- View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018963.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Apply role to whole class hierarchy
Looks like a bug. :( The code to inherit @role event is there, but apparently there is something else going on: https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/rule/Package.java#L485 Please open a JIRA with the information bellow. Edson On Fri, Jul 27, 2012 at 3:01 AM, Joerg Henne wrote: > Thanks for your help, Edson! > > We are using drools 5.4.0.Final via maven. > > Maybe I am missing something, so here's a quick overview of what we do. We > have a model class ButtonEvent which is derived like this: > ButtonEvent -> ZonedEvent -> VSCPEvent > > Then there's a rulebase with something like this: > > import test.vscp.VSCPEvent; > import test.vscp.information.ButtonEvent; > > declare VSCPEvent > @role( event ) > @timestamp( timestamp ) > @expires( 1h ) > end > declare ButtonEvent > @role( event ) > @timestamp( timestamp ) > @expires( 1h ) > end > > rule "Button long pressed" > when > b : ButtonEvent( action == Action.PRESSED ) > not( ButtonEvent( action == Action.RELEASED, this after[0s,1s] b ) > ) > then > ... > end > > What I would have expected is that the second 'declare' statement to be > unnecessary. However, if I take it away, this is what I get: > > java.lang.ClassCastException: org.drools.common.DefaultFactHandle > at > > org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:316) > at > > org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80) > at > > org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:139) > at org.drools.reteoo.NotNode.assertObject(NotNode.java:133) > at > > org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59) > at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141) > at > > org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497) > at > > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382) > at > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235) > at > org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240) > at > org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337) > at > org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298) > at > > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888) > at > > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847) > at > > org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269) > ... > > Thanks > Joerg > > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018942.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Apply role to whole class hierarchy
Thanks for your help, Edson! We are using drools 5.4.0.Final via maven. Maybe I am missing something, so here's a quick overview of what we do. We have a model class ButtonEvent which is derived like this: ButtonEvent -> ZonedEvent -> VSCPEvent Then there's a rulebase with something like this: import test.vscp.VSCPEvent; import test.vscp.information.ButtonEvent; declare VSCPEvent @role( event ) @timestamp( timestamp ) @expires( 1h ) end declare ButtonEvent @role( event ) @timestamp( timestamp ) @expires( 1h ) end rule "Button long pressed" when b : ButtonEvent( action == Action.PRESSED ) not( ButtonEvent( action == Action.RELEASED, this after[0s,1s] b ) ) then ... end What I would have expected is that the second 'declare' statement to be unnecessary. However, if I take it away, this is what I get: java.lang.ClassCastException: org.drools.common.DefaultFactHandle at org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:316) at org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80) at org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:139) at org.drools.reteoo.NotNode.assertObject(NotNode.java:133) at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847) at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269) ... Thanks Joerg -- View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018942.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Apply role to whole class hierarchy
Derived classes should inherit the @role of parent classes... which version of Drools are you using? Edson On Thu, Jul 26, 2012 at 12:48 PM, Joerg Henne wrote: > Hi all, > > we are processing events through a Fusion rule base. To be recognized as > such, model classes must be declared as @role(event). We are using a rather > extensive hierarchy of events, all derived from a single abstract class. > Unfortunately, it doesn't seem to be possible to declare just this base > class as an event and have the 'event' role for the others derived from > that. > Is there a way around having to declare each and every single event class > separately? > > Thanks > Joerg > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Apply role to whole class hierarchy
Hi all, we are processing events through a Fusion rule base. To be recognized as such, model classes must be declared as @role(event). We are using a rather extensive hierarchy of events, all derived from a single abstract class. Unfortunately, it doesn't seem to be possible to declare just this base class as an event and have the 'event' role for the others derived from that. Is there a way around having to declare each and every single event class separately? Thanks Joerg -- View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users