|
|
@ -54,11 +54,8 @@ public class SimpleConfigurationMetadataRepository implements ConfigurationMetad
|
|
|
|
public void add(Collection<ConfigurationMetadataSource> sources) {
|
|
|
|
public void add(Collection<ConfigurationMetadataSource> sources) {
|
|
|
|
for (ConfigurationMetadataSource source : sources) {
|
|
|
|
for (ConfigurationMetadataSource source : sources) {
|
|
|
|
String groupId = source.getGroupId();
|
|
|
|
String groupId = source.getGroupId();
|
|
|
|
ConfigurationMetadataGroup group = this.allGroups.get(groupId);
|
|
|
|
ConfigurationMetadataGroup group = this.allGroups.computeIfAbsent(groupId,
|
|
|
|
if (group == null) {
|
|
|
|
(key) -> new ConfigurationMetadataGroup(groupId));
|
|
|
|
group = new ConfigurationMetadataGroup(groupId);
|
|
|
|
|
|
|
|
this.allGroups.put(groupId, group);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String sourceType = source.getType();
|
|
|
|
String sourceType = source.getType();
|
|
|
|
if (sourceType != null) {
|
|
|
|
if (sourceType != null) {
|
|
|
|
addOrMergeSource(group.getSources(), sourceType, source);
|
|
|
|
addOrMergeSource(group.getSources(), sourceType, source);
|
|
|
@ -74,9 +71,9 @@ public class SimpleConfigurationMetadataRepository implements ConfigurationMetad
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void add(ConfigurationMetadataProperty property, ConfigurationMetadataSource source) {
|
|
|
|
public void add(ConfigurationMetadataProperty property, ConfigurationMetadataSource source) {
|
|
|
|
if (source != null) {
|
|
|
|
if (source != null) {
|
|
|
|
putIfAbsent(source.getProperties(), property.getId(), property);
|
|
|
|
source.getProperties().putIfAbsent(property.getId(), property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
putIfAbsent(getGroup(source).getProperties(), property.getId(), property);
|
|
|
|
getGroup(source).getProperties().putIfAbsent(property.getId(), property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -91,7 +88,7 @@ public class SimpleConfigurationMetadataRepository implements ConfigurationMetad
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// Merge properties
|
|
|
|
// Merge properties
|
|
|
|
group.getProperties().forEach((name, value) -> putIfAbsent(existingGroup.getProperties(), name, value));
|
|
|
|
group.getProperties().forEach((name, value) -> existingGroup.getProperties().putIfAbsent(name, value));
|
|
|
|
// Merge sources
|
|
|
|
// Merge sources
|
|
|
|
group.getSources().forEach((name, value) -> addOrMergeSource(existingGroup.getSources(), name, value));
|
|
|
|
group.getSources().forEach((name, value) -> addOrMergeSource(existingGroup.getSources(), name, value));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -101,12 +98,7 @@ public class SimpleConfigurationMetadataRepository implements ConfigurationMetad
|
|
|
|
|
|
|
|
|
|
|
|
private ConfigurationMetadataGroup getGroup(ConfigurationMetadataSource source) {
|
|
|
|
private ConfigurationMetadataGroup getGroup(ConfigurationMetadataSource source) {
|
|
|
|
if (source == null) {
|
|
|
|
if (source == null) {
|
|
|
|
ConfigurationMetadataGroup rootGroup = this.allGroups.get(ROOT_GROUP);
|
|
|
|
return this.allGroups.computeIfAbsent(ROOT_GROUP, (key) -> new ConfigurationMetadataGroup(ROOT_GROUP));
|
|
|
|
if (rootGroup == null) {
|
|
|
|
|
|
|
|
rootGroup = new ConfigurationMetadataGroup(ROOT_GROUP);
|
|
|
|
|
|
|
|
this.allGroups.put(ROOT_GROUP, rootGroup);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return rootGroup;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.allGroups.get(source.getGroupId());
|
|
|
|
return this.allGroups.get(source.getGroupId());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -118,13 +110,7 @@ public class SimpleConfigurationMetadataRepository implements ConfigurationMetad
|
|
|
|
sources.put(name, source);
|
|
|
|
sources.put(name, source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
source.getProperties().forEach((k, v) -> putIfAbsent(existingSource.getProperties(), k, v));
|
|
|
|
source.getProperties().forEach((k, v) -> existingSource.getProperties().putIfAbsent(k, v));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private <V> void putIfAbsent(Map<String, V> map, String key, V value) {
|
|
|
|
|
|
|
|
if (!map.containsKey(key)) {
|
|
|
|
|
|
|
|
map.put(key, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|