// make sure that each instance of the view in the db is reflected in the given view
for (ViewInstanceEntity persistedInstance : persistedView.getInstances()){
String instanceName = persistedInstance.getName();
ViewInstanceEntity instance =
view.getInstanceDefinition(instanceName);
instanceEntityMap.remove(instanceName);
// if the persisted instance is not in the registry ...
if (instance == null) {
// ... create and add it
instance = new ViewInstanceEntity(view, instanceName);
bindViewInstance(view, instance);
instanceDefinitions.add(instance);
}
instance.setViewInstanceId(persistedInstance.getViewInstanceId());
// apply the persisted overrides to the in-memory instance
instance.setLabel(persistedInstance.getLabel());
instance.setDescription(persistedInstance.getDescription());
instance.setVisible(persistedInstance.isVisible());
instance.setData(persistedInstance.getData());
instance.setProperties(persistedInstance.getProperties());
instance.setEntities(persistedInstance.getEntities());
}
// these instances appear in the archive but have been deleted
// from the db... remove them from the registry
for (ViewInstanceEntity instance : instanceEntityMap.values()) {
view.removeInstanceDefinition(instance.getName());
instanceDefinitions.remove(instance);
}
}