RuleTerminalNode ruleTerminalNode = (RuleTerminalNode) leftTuple.getLeftTupleSink();
PropagationContext pc = context.propagationContexts.get( stream.readLong() );
AgendaItem activation;
boolean scheduled = false;
if ( rule.getTimer() != null ) {
activation = new ScheduledAgendaItem( activationNumber,
leftTuple,
(InternalAgenda) wm.getAgenda(),
pc,
ruleTerminalNode );
scheduled = true;
} else {
activation = new AgendaItem( activationNumber,
leftTuple,
salience,
pc,
ruleTerminalNode );
}
leftTuple.setObject( activation );
if ( stream.readBoolean() ) {
String activationGroupName = stream.readUTF();
((DefaultAgenda) wm.getAgenda()).getActivationGroup( activationGroupName ).addActivation( activation );
}
boolean activated = stream.readBoolean();
activation.setActivated( activated );
if ( stream.readBoolean() ) {
InternalFactHandle handle = context.handles.get( stream.readInt() );
activation.setFactHandle( handle );
handle.setObject( activation );
}
InternalAgendaGroup agendaGroup;
if ( rule.getAgendaGroup() == null || rule.getAgendaGroup().equals( "" ) || rule.getAgendaGroup().equals( AgendaGroup.MAIN ) ) {
// Is the Rule AgendaGroup undefined? If it is use MAIN,
// which is added to the Agenda by default
agendaGroup = (InternalAgendaGroup) ((DefaultAgenda) wm.getAgenda()).getAgendaGroup( AgendaGroup.MAIN );
} else {
// AgendaGroup is defined, so try and get the AgendaGroup
// from the Agenda
agendaGroup = (InternalAgendaGroup) ((DefaultAgenda) wm.getAgenda()).getAgendaGroup( rule.getAgendaGroup() );
}
activation.setAgendaGroup( agendaGroup );
if ( !scheduled && activated ) {
if ( rule.getRuleFlowGroup() == null ) {
agendaGroup.add( activation );
} else {