// the first container in each file should belong to the ModelManager
if (ppcModel.getPluginName().equals("de.hpi.eworld.core")) {
final Collection<Object> items = ppcModel.getItems();
modelManager.setChanged();
modelManager.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
modelManager.clearChanged();
for (final Object obj : items) {
final ModelElement me = (ModelElement) obj;
modelManager.addModelElement(me);
}
modelManager.setSimulationStartTime(ppcModel.getSimulationStartTime());
modelManager.setSimulationEndTime(ppcModel.getSimulationEndTime());
// first values prevents the network view from filter duplicate
// edges
modelManager.setChanged();
modelManager.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, false, false));
modelManager.clearChanged();
} else {
// do panic
in.close();
throw new Exception("First Container does not belong to the ModelManager");
}
// clean up as much as possible
ppcModel = null;
System.gc();
while (true) {
PluginPersistenceContainer ppc = null;
try {
ppc = (PluginPersistenceContainer) in.readObject();
} catch (final EOFException xcp) {
// everything's fine
// this exception is thrown if the end of the stream is reached
// its escalation is stopped here
// just close the stream and return
in.close();
return;
}
if (plugins.keySet().contains(ppc.getPluginName())) {
final PersistenceProviderInterface accordingPlugin = plugins.get(ppc.getPluginName());
setChanged();
notifyObservers(new ObserverNotification(NotificationType.loadFromFile, accordingPlugin, ppc.getItems()));
clearChanged();
}
}
}