}
for (String name : toRemove) {
log.debug("Removing template [" + name + "]");
ConfigurationTemplate template = existingTemplates.remove(name);
entityManager.remove(template);
}
for (String name : templatesToUpdate) {
log.debug("Updating template [" + name + "]");
updateTemplate(existingDefinition.getTemplate(name), newTemplates.get(name));
}
for (String name : newTemplates.keySet()) {
// add completely new templates
if (!existingTemplates.containsKey(name)) {
log.debug("Adding template [" + name + "]");
ConfigurationTemplate newTemplate = newTemplates.get(name);
// we need to set a valid configurationDefinition, where we will live on.
newTemplate.setConfigurationDefinition(existingDefinition);
entityManager.persist(newTemplate);
existingTemplates.put(name, newTemplate);
}
}