class DataSetNameInjection {

    public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) {
        String dataSetName = preparation.getDataSetName();
        if (dataSetName == null) {
            try {
                final String tenantId = security.getTenantId();
                final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache);
                assert tenantCache != null; // initTenant() cannot return a null value
                String dataSetId = preparation.getDataSetId();
                dataSetName = tenantCache.get(dataSetId, this::getDatasetLabel);
                if (dataSetName != null) {
                    preparation.setDataSetName(dataSetName);
                    preparationRepository.add(preparation);
                }
            } catch (Exception e) {
                throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
            }
        }
        return preparation;
    }

}