Search in sources :

Example 6 with Dataset

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();
}
Also used : Dataset(bio.terra.service.dataset.Dataset) DatasetDataProject(bio.terra.service.dataset.DatasetDataProject)

Example 7 with Dataset

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();
}
Also used : DataDeletionUtils.getDataset(bio.terra.service.dataset.flight.datadelete.DataDeletionUtils.getDataset) Dataset(bio.terra.service.dataset.Dataset) DataDeletionRequest(bio.terra.model.DataDeletionRequest) DataDeletionTableModel(bio.terra.model.DataDeletionTableModel)

Example 8 with Dataset

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();
}
Also used : DataDeletionUtils.getDataset(bio.terra.service.dataset.flight.datadelete.DataDeletionUtils.getDataset) Dataset(bio.terra.service.dataset.Dataset) TableNotFoundException(bio.terra.service.dataset.exception.TableNotFoundException) DataDeletionTableModel(bio.terra.model.DataDeletionTableModel)

Example 9 with Dataset

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();
}
Also used : DataDeletionUtils.getDataset(bio.terra.service.dataset.flight.datadelete.DataDeletionUtils.getDataset) Dataset(bio.terra.service.dataset.Dataset) DataDeletionRequest(bio.terra.model.DataDeletionRequest) DataDeletionTableModel(bio.terra.model.DataDeletionTableModel)

Example 10 with Dataset

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();
}
Also used : Dataset(bio.terra.service.dataset.Dataset) FlightMap(bio.terra.stairway.FlightMap)

Aggregations

Dataset (bio.terra.service.dataset.Dataset)49 AssetSpecification (bio.terra.service.dataset.AssetSpecification)9 Snapshot (bio.terra.service.snapshot.Snapshot)9 FlightMap (bio.terra.stairway.FlightMap)9 UUID (java.util.UUID)9 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)8 DatasetTable (bio.terra.service.dataset.DatasetTable)8 Test (org.junit.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 IngestRequestModel (bio.terra.model.IngestRequestModel)7 SnapshotSource (bio.terra.service.snapshot.SnapshotSource)7 StepResult (bio.terra.stairway.StepResult)5 ArrayList (java.util.ArrayList)5 Column (bio.terra.common.Column)4 Table (bio.terra.common.Table)4 DataDeletionTableModel (bio.terra.model.DataDeletionTableModel)4 SnapshotRequestContentsModel (bio.terra.model.SnapshotRequestContentsModel)4 ValidationException (bio.terra.app.controller.exception.ValidationException)3 PdaoLoadStatistics (bio.terra.common.PdaoLoadStatistics)3 PdaoException (bio.terra.common.exception.PdaoException)3