class RenameDataSetsWithFolderPath implements BaseUpgradeTaskTo_1_2_0_PE {

    @Override
    public void run() {

        final Stream<DataSetMetadata> datasets = dataSetMetadataRepository.list();
        datasets.forEach(dataset -> {
            final Folder folder = folderRepository.locateEntry(dataset.getId(), FolderContentType.DATASET);
            // skip home folder
            if (folder != null && !StringUtils.equals("/", folder.getPath())) {
                String newName = dataset.getName() + " - " + StringUtils.strip(folder.getPath(), "/");
                dataset.setName(newName);
                dataSetMetadataRepository.save(dataset);
                LOG.debug("dataset #{} renamed to {}", dataset.getId(), newName);
            } else {
                LOG.debug("dataset #{} not renamed since it's in the user home folder", dataset.getId());
            }
        });
    }

}