}
public static Activation readActivation( MarshallerReaderContext context ) throws IOException {
ObjectInputStream stream = context.stream;
InternalRuleBase ruleBase = context.ruleBase;
InternalWorkingMemory wm = context.wm;
long activationNumber = stream.readLong();
int pos = stream.readInt();
LeftTuple leftTuple = context.terminalTupleMap.get( pos );
int salience = stream.readInt();
String pkgName = stream.readUTF();
String ruleName = stream.readUTF();
Package pkg = ruleBase.getPackage( pkgName );
Rule rule = pkg.getRule( ruleName );
RuleTerminalNode ruleTerminalNode = (RuleTerminalNode) leftTuple.getLeftTupleSink();
PropagationContext pc = context.propagationContexts.get( stream.readLong() );
AgendaItem 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() );
}
InternalRuleFlowGroup rfg = (InternalRuleFlowGroup) ( (DefaultAgenda) wm.getAgenda() ).getRuleFlowGroup( rule.getRuleFlowGroup() );
boolean scheduled = false;
RuleTerminalNodeLeftTuple rtnLeftTuple = ( RuleTerminalNodeLeftTuple ) leftTuple;
rtnLeftTuple.init(activationNumber, salience, pc, null, agendaGroup);
activation = rtnLeftTuple;
if (rule.getTimer() != null) {
activation = new ScheduledAgendaItem( rtnLeftTuple,
(InternalAgenda) wm.getAgenda() );
scheduled = true;
} else {
}
leftTuple.setObject( activation );
if (stream.readBoolean()) {
String activationGroupName = stream.readUTF();
( (DefaultAgenda) wm.getAgenda() ).getActivationGroup( activationGroupName ).addActivation( activation );
}
boolean activated = stream.readBoolean();
activation.setQueued(activated);