final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();
final Duration dur = this.rule.getDuration();
if ( dur != null && dur.getDuration( tuple ) > 0 ) {
final ScheduledAgendaItem item = new ScheduledAgendaItem( context.getPropagationNumber(),
cloned,
agenda,
context,
this.rule,
this.subrule );
final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
agenda.scheduleItem( item );
tuple.setActivation( item );
if ( this.tupleMemoryEnabled ) {
memory.getTupleMemory().add( tuple );
}
item.setActivated( true );
((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCreated( item,
workingMemory );
} else {
// -----------------
// Lazy instantiation and addition to the Agenda of AgendGroup
// implementations
// ----------------
final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
final AgendaItem item = new AgendaItem( context.getPropagationNumber(),
cloned,
rule.getSalience().getValue( tuple,
workingMemory ),
context,
this.rule,
this.subrule );
item.setSequenence( this.sequence );
tuple.setActivation( item );
memory.getTupleMemory().add( tuple );
boolean added = agenda.addActivation( item );
item.setActivated( added );
// We only want to fire an event on a truly new Activation and not on an Activation as a result of a modify
if ( added && fireActivationCreated ) {
((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCreated( item,
workingMemory );