- Added method deleteDataset [#26793]

This commit is contained in:
Francesco Mangiacrapa 2024-02-19 15:59:28 +01:00
parent ee82656541
commit ea8bc0c46c
3 changed files with 92 additions and 23 deletions

View File

@ -9,8 +9,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
**Enhancements**
- Added method update item [#26640]
- Added method deleteDataset [#26793]
- Added method getListExtrasAsHashMap - D4Science model compliant
## [v1.3.0] - 2023-02-06
**Enhancements**

View File

@ -332,28 +332,27 @@ public interface DataCatalogue {
String description, String licenseId, List<String> tags, Map<String, List<String>> customFieldsMultiple,
List<ResourceBean> resources, boolean setPublic, boolean setSearchable, boolean socialPost)
throws Exception;
/**
* Update ckan dataset multiple custom fields.
*
* @param username the username
* @param title the title
* @param name the name
* @param organizationName the organization name
* @param author the author
* @param authorMail the author mail
* @param maintainer the maintainer
* @param maintainerMail the maintainer mail
* @param version the version
* @param description the description
* @param licenseId the license id
* @param tags the tags
* @param username the username
* @param title the title
* @param name the name
* @param organizationName the organization name
* @param author the author
* @param authorMail the author mail
* @param maintainer the maintainer
* @param maintainerMail the maintainer mail
* @param version the version
* @param description the description
* @param licenseId the license id
* @param tags the tags
* @param customFieldsMultiple the custom fields multiple
* @param resources the resources
* @param setPublic the set public
* @param setSearchable the set searchable
* @param socialPost the social post
* @param resources the resources
* @param setPublic the set public
* @param setSearchable the set searchable
* @param socialPost the social post
* @return the string
* @throws Exception the exception
*/
@ -374,19 +373,19 @@ public interface DataCatalogue {
* @throws Exception the exception
*/
String addResourceToDataset(ResourceBean resourceBean, String organizationName, String username) throws Exception;
/**
* Adds the resource.
*
* @param resourceBean the resource bean
* @param datasetId the dataset id
* @param resourceBean the resource bean
* @param datasetId the dataset id
* @param organizationName the organization name
* @param username the username
* @param username the username
* @return the ckan resource
* @throws Exception the exception
*/
CkanResource addResource(ResourceBean resourceBean, String datasetId, String organizationName, String username) throws Exception;
CkanResource addResource(ResourceBean resourceBean, String datasetId, String organizationName, String username)
throws Exception;
/**
* Remove the resource with id resourceId from dataset in which it is.
@ -463,6 +462,15 @@ public interface DataCatalogue {
*/
String refreshDataset(String datasetName) throws Exception;
/**
* Delete dataset.
*
* @param datasetName the dataset name
* @return true, if successful
* @throws Exception the exception
*/
boolean deleteDataset(String datasetName) throws Exception;
/**
* Patch a product with product id productId by using the couples in
* customFieldsToChange. NOTE: only the specified custom fields will be changed.

View File

@ -1320,6 +1320,29 @@ public class DataCatalogueImpl implements DataCatalogue {
return null;
}
/**
* Update ckan dataset multiple custom fields.
*
* @param username the username
* @param title the title
* @param name the name
* @param organizationName the organization name
* @param author the author
* @param authorMail the author mail
* @param maintainer the maintainer
* @param maintainerMail the maintainer mail
* @param version the version
* @param description the description
* @param licenseId the license id
* @param tags the tags
* @param customFieldsMultiple the custom fields multiple
* @param resources the resources
* @param setPublic the set public
* @param setSearchable the set searchable
* @param socialPost the social post
* @return the string
* @throws Exception the exception
*/
@Override
public String updateCkanDatasetMultipleCustomFields(String username, String title, String name,
String organizationName, String author, String authorMail, String maintainer, String maintainerMail,
@ -1411,6 +1434,32 @@ public class DataCatalogueImpl implements DataCatalogue {
return null;
}
/**
* Delete dataset.
*
* @param datasetName the dataset name
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean deleteDataset(String datasetName) throws Exception {
LOG.info("Called deleteDataset");
checkNotNull(datasetName);
boolean deleted = false;
try {
gCatCaller.deleteItem(datasetName, true);
deleted = true;
LOG.info("Deleted the dataset: {} ", datasetName);
return deleted;
} catch (Exception e) {
LOG.error("Error on deleting the dataset: ", e);
throw e;
}
}
/**
* Patch fields for dataset.
*
@ -1523,6 +1572,7 @@ public class DataCatalogueImpl implements DataCatalogue {
* Adds the resource to dataset.
*
* @param resourceBean the resource bean
* @param datasetId the dataset id
* @param organizationName the organization name
* @param username the username
* @return the string
@ -1537,6 +1587,15 @@ public class DataCatalogueImpl implements DataCatalogue {
return createResource(resourceBean, organizationName, username);
}
/**
* Creates the resource.
*
* @param resourceBean the resource bean
* @param organizationName the organization name
* @param username the username
* @return the ckan resource
* @throws Exception the exception
*/
private CkanResource createResource(ResourceBean resourceBean, String organizationName, String username)
throws Exception {