private List<DefaultValueConfiguration> getConfigurations(IModel<LayerInfo> layerModel,
IModel<DefaultValueConfigurations> configModel) {
ArrayList<DefaultValueConfiguration> result = new ArrayList<DefaultValueConfiguration>();
// see if we have configs already
DefaultValueConfigurations configs = configModel.getObject();
if (configs != null) {
result.addAll(configs.getConfigurations());
} else {
configs = new DefaultValueConfigurations(new ArrayList<DefaultValueConfiguration>());
}
// add missing dimension configs
Set<String> dimensionNames = getEnabledDimensionNames(layerModel.getObject());
for (String dimensionName : dimensionNames) {
addIfMissing(dimensionName, result);
}
// remove unknown ones
for (Iterator it = result.iterator(); it.hasNext();) {
DefaultValueConfiguration config = (DefaultValueConfiguration) it.next();
if (!dimensionNames.contains(config.getDimension())) {
it.remove();
}
}
configs.getConfigurations().clear();
configs.getConfigurations().addAll(result);
return result;
}