[jboss-jira] [JBoss JIRA] (DROOLS-460) Eval does not behave as intended

Fabian Meyer (JIRA) issues at jboss.org
Tue Apr 1 02:35:13 EDT 2014


     [ https://issues.jboss.org/browse/DROOLS-460?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fabian Meyer updated DROOLS-460:
--------------------------------

    Steps to Reproduce: 
package org.example;

import java.util.Date;

declare Thing

end

declare IDProperty
  subject : Thing
  object : int
end

declare StatusEvent
  @role(event)
  @timestamp(timestamp)
  thingId : int
  timestamp : Date 
end

rule init
  when
  then
    Thing t = new Thing();
    insert (t);
    insert (new IDProperty(t, 1));
    
    insert (new StatusEvent(1, new Date(0)));
    insert (new StatusEvent(1, new Date(1)));
end

rule notLast1
  when
    $t : Thing()
    IDProperty(subject == $t, $id : object)
    
    // Constraint
    $ev : StatusEvent(thingId == $id)
    
    exists(
      // Constraint
      StatusEvent(this after $ev, $id == thingId)
    )
  then
    System.out.println("(1) not last " + $ev);
end


rule notLast2
  when
    $t : Thing()
    IDProperty(subject == $t, $id : object)
    
    // Constraint
    $ev : StatusEvent(thingId == $id)
    
    exists(
      // Eval
      StatusEvent(this after $ev, $evId : thingId)
      and 
      eval($evId == $id)
    )
  then
    System.out.println("(2) not last " + $ev);
end

rule notLast3
  when
    $t : Thing()
    IDProperty(subject == $t, $id : object)
    
    // Eval
    $ev : StatusEvent()
    eval($ev.getThingId() == $id)
    
    exists(
      // Constraint
      StatusEvent(this after $ev, $id == thingId)
    )
  then
    System.out.println("(3) not last " + $ev);
end


rule notLast4
  when
    
    $t : Thing()
    IDProperty(subject == $t, $id : object)
    
    // Eval
    $ev : StatusEvent()
    eval($ev.getThingId() == $id)
    
    exists(
      // Eval
      StatusEvent(this after $ev, $evId : thingId)
      and 
      eval($evId == $id)
    )
  then
    System.out.println("(4) not last " + $ev);
end



Output: 

(1) not last StatusEvent( thingId=1, timestamp=Thu Jan 01 01:00:00 CET 1970 ) 
(2) not last StatusEvent( thingId=1, timestamp=Thu Jan 01 01:00:00 CET 1970 ) 
(3) not last StatusEvent( thingId=1, timestamp=Thu Jan 01 01:00:00 CET 1970 ) 

Rule "notLast4" doesn't fire

  was:
package org.example;

import java.util.Date;

declare Thing

end

declare IDProperty
	subject : Thing
	object : int
end

declare StatusEvent
	@role(event)
	@timestamp(timestamp)
	thingId : int
	timestamp : Date 
end

rule init
	when
	then
		Thing t = new Thing();
		insert (t);
		insert (new IDProperty(t, 1));
		
		insert (new StatusEvent(1, new Date(0)));
		insert (new StatusEvent(1, new Date(1)));
end

rule notLast1
	when
		$t : Thing()
		IDProperty(subject == $t, $id : object)
		
		// Constraint
		$ev : StatusEvent(thingId == $id)
		
		exists(
			// Constraint
			StatusEvent(this after $ev, $id == thingId)
		)
	then
		System.out.println("(1) not last " + $ev);
end


rule notLast2
	when
		$t : Thing()
		IDProperty(subject == $t, $id : object)
		
		// Constraint
		$ev : StatusEvent(thingId == $id)
		
		exists(
			// Eval
			StatusEvent(this after $ev, $evId : thingId)
			and 
			eval($evId == $id)
		)
	then
		System.out.println("(2) not last " + $ev);
end

rule notLast3
	when
		$t : Thing()
		IDProperty(subject == $t, $id : object)
		
		// Eval
		$ev : StatusEvent()
		eval($ev.getThingId() == $id)
		
		exists(
			// Constraint
			StatusEvent(this after $ev, $id == thingId)
		)
	then
		System.out.println("(3) not last " + $ev);
end


rule notLast4
	when
		
		$t : Thing()
		IDProperty(subject == $t, $id : object)
		
		// Eval
		$ev : StatusEvent()
		eval($ev.getThingId() == $id)
		
		exists(
			// Eval
			StatusEvent(this after $ev, $evId : thingId)
			and 
			eval($evId == $id)
		)
	then
		System.out.println("(4) not last " + $ev);
end



Output: 

(1) not last StatusEvent( thingId=1, timestamp=Thu Jan 01 01:00:00 CET 1970 ) 
(2) not last StatusEvent( thingId=1, timestamp=Thu Jan 01 01:00:00 CET 1970 ) 
(3) not last StatusEvent( thingId=1, timestamp=Thu Jan 01 01:00:00 CET 1970 ) 

Rule "notLast4" doesn't fire


    
> Eval does not behave as intended
> --------------------------------
>
>                 Key: DROOLS-460
>                 URL: https://issues.jboss.org/browse/DROOLS-460
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 6.1.0.Final
>            Reporter: Fabian Meyer
>            Assignee: Mark Proctor
>
> Under certain conditions, eval does not behave as intended, when nested in a sub-network.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list