use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class CreateDatasetPrimaryDataStep method undoStep.
@Override
public StepResult undoStep(FlightContext context) throws InterruptedException {
Dataset dataset = getDataset(context);
// get the cloud project for the dataset if it exists
Optional<DatasetDataProject> optDataProject = dataLocationService.getProject(dataset);
if (optDataProject.isPresent()) {
// there can only be primary data to delete if a cloud project exists for the dataset
pdao.deleteDataset(dataset);
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class CreateExternalTablesStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
Dataset dataset = getDataset(context, datasetService);
String suffix = getSuffix(context);
DataDeletionRequest dataDeletionRequest = getRequest(context);
validateTablesExistInDataset(dataDeletionRequest, dataset);
for (DataDeletionTableModel table : dataDeletionRequest.getTables()) {
String path = table.getGcsFileSpec().getPath();
// let any exception here trigger an undo, no use trying to continue
bigQueryPdao.createSoftDeleteExternalTable(dataset, path, table.getTableName(), suffix);
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class CreateExternalTablesStep method undoStep.
@Override
public StepResult undoStep(FlightContext context) {
Dataset dataset = getDataset(context, datasetService);
String suffix = getSuffix(context);
for (DataDeletionTableModel table : getRequest(context).getTables()) {
try {
bigQueryPdao.deleteSoftDeleteExternalTable(dataset, table.getTableName(), suffix);
} catch (Exception ex) {
// catch any exception and get it into the log, make a
String msg = String.format("Couldn't clean up external table for %s from dataset %s w/ suffix %s", table.getTableName(), dataset.getName(), suffix);
logger.warn(msg, ex);
}
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class DropExternalTablesStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
Dataset dataset = getDataset(context, datasetService);
String suffix = getSuffix(context);
DataDeletionRequest dataDeletionRequest = getRequest(context);
for (DataDeletionTableModel table : dataDeletionRequest.getTables()) {
bigQueryPdao.deleteSoftDeleteExternalTable(dataset, table.getTableName(), suffix);
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class DeleteDatasetPrimaryDataStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
Dataset dataset = datasetService.retrieve(datasetId);
bigQueryPdao.deleteDataset(dataset);
if (configService.testInsertFault(ConfigEnum.LOAD_SKIP_FILE_LOAD)) {
// If we didn't load files, don't try to delete them
fileDao.deleteFilesFromDataset(dataset, fireStoreFile -> {
});
} else {
fileDao.deleteFilesFromDataset(dataset, fireStoreFile -> gcsPdao.deleteFile(fireStoreFile));
}
// this fault is used by the DatasetConnectedTest > testOverlappingDeletes
if (configService.testInsertFault(ConfigEnum.DATASET_DELETE_LOCK_CONFLICT_STOP_FAULT)) {
logger.info("DATASET_DELETE_LOCK_CONFLICT_STOP_FAULT");
while (!configService.testInsertFault(ConfigEnum.DATASET_DELETE_LOCK_CONFLICT_CONTINUE_FAULT)) {
logger.info("Sleeping for CONTINUE FAULT");
TimeUnit.SECONDS.sleep(5);
}
logger.info("DATASET_DELETE_LOCK_CONFLICT_CONTINUE_FAULT");
}
FlightMap map = context.getWorkingMap();
map.put(JobMapKeys.STATUS_CODE.getKeyName(), HttpStatus.NO_CONTENT);
return StepResult.getStepResultSuccess();
}
Aggregations