use of com.amazonaws.services.personalize.model.ListDatasetsResult in project knime-cloud by knime.
the class AbstractAmazonPersonalizeDataUploadNodeModel method checkAlreadyExistingDataset.
private void checkAlreadyExistingDataset(final AmazonPersonalize personalizeClient, final String datasetGroupArn, final ExecutionContext exec) throws InterruptedException {
exec.setMessage("Checking already existing datasets");
final ListDatasetsResult listDatasets = personalizeClient.listDatasets(new ListDatasetsRequest().withDatasetGroupArn(datasetGroupArn));
final Optional<DatasetSummary> dataset = listDatasets.getDatasets().stream().filter(e -> e.getDatasetType().equals(m_datasetType)).findFirst();
if (dataset.isPresent()) {
if (m_settings.getOverwriteDatasetPolicy().equals(OverwritePolicy.ABORT.toString())) {
// Abort if dataset already exists
throw new IllegalStateException("A dataset of type '" + getDatasetType() + "' already exists. Either choose a different dataset group or select to overwrite the existing " + "dataset.");
} else {
// Delete the existing dataset
exec.setMessage("Deleting existing dataset");
deleteDataset(personalizeClient, datasetGroupArn, dataset.get().getDatasetArn());
}
}
exec.setProgress(1);
}
Aggregations