Search in sources :

Example 1 with WithName

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);
        }
    }
}
Also used : WithName(io.syndesis.common.model.WithName) GET(javax.ws.rs.GET) POST(javax.ws.rs.POST)

Aggregations

WithName (io.syndesis.common.model.WithName)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1