use of org.broadinstitute.consent.http.models.DataSetAudit in project consent by DataBiosphere.
the class DatasetService method deleteDataset.
public void deleteDataset(Integer datasetId, Integer userId) throws Exception {
DataSet dataset = datasetDAO.findDataSetById(datasetId);
if (Objects.nonNull(dataset)) {
// Some legacy dataset names can be null
String dsAuditName = Objects.nonNull(dataset.getName()) ? dataset.getName() : dataset.getDatasetIdentifier();
DataSetAudit dsAudit = new DataSetAudit(datasetId, dataset.getObjectId(), dsAuditName, new Date(), dataset.getActive(), userId, AuditActions.DELETE.getValue().toUpperCase());
try {
datasetDAO.useTransaction(h -> {
try {
h.insertDataSetAudit(dsAudit);
h.deleteUserAssociationsByDatasetId(datasetId);
h.deleteDatasetPropertiesByDatasetId(datasetId);
h.deleteConsentAssociationsByDataSetId(datasetId);
h.deleteDatasetById(datasetId);
} catch (Exception e) {
h.rollback();
throw e;
}
});
} catch (Exception e) {
logger.error(e.getMessage());
throw e;
}
}
}
Aggregations