use of io.syndesis.common.model.WithName in project syndesis by syndesisio.
the class IntegrationSupportHandler method importModels.
private <T extends WithId<T> & WithName> void importModels(JsonDbDao<T> export, BiFunction<T, String, T> renameFunc, Map<String, String> renames, Map<String, List<WithResourceId>> result, BiFunction<JsonDbDao<T>, T, Boolean> compareFunc) {
final Set<String> names = getAllPropertyValues(export.getType(), WithName::getName);
for (T item : export.fetchAll().getItems()) {
String id = item.getId().get();
if (compareFunc.apply(export, item)) {
// resolve duplicate names
String name = item.getName();
if (names.contains(name)) {
// rename item
name = getNextAvailableName(name, names);
item = renameFunc.apply(item, name);
names.add(name);
renames.put(id, name);
}
// create new item
dataManager.create(item);
addImportedItemResult(result, item);
}
}
}