Search in sources :

Example 46 with Dataset

use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.

the class IngestRowIdsStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
    Dataset dataset = IngestUtils.getDataset(context, datasetService);
    String stagingTableName = IngestUtils.getStagingTableName(context);
    bigQueryPdao.addRowIdsToStagingTable(dataset, stagingTableName);
    return StepResult.getStepResultSuccess();
}
Also used : Dataset(bio.terra.service.dataset.Dataset)

Example 47 with Dataset

use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.

the class CreateDatasetPrimaryDataStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
    // Note that there can be only one project for a Dataset. This requirement is enforced in DataLocationService,
    // where getOrCreateProject first checks for an existing project before trying to create a new one.
    // The below logic would not work correctly if this one-to-one mapping were ever violated.
    Dataset dataset = getDataset(context);
    dataLocationService.getOrCreateProject(dataset);
    pdao.createDataset(dataset);
    FlightMap map = context.getWorkingMap();
    map.put(JobMapKeys.STATUS_CODE.getKeyName(), HttpStatus.CREATED);
    return StepResult.getStepResultSuccess();
}
Also used : Dataset(bio.terra.service.dataset.Dataset) FlightMap(bio.terra.stairway.FlightMap)

Example 48 with Dataset

use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.

the class DataDeletionStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
    Dataset dataset = getDataset(context, datasetService);
    String suffix = getSuffix(context);
    DataDeletionRequest dataDeletionRequest = getRequest(context);
    List<String> tableNames = dataDeletionRequest.getTables().stream().map(DataDeletionTableModel::getTableName).collect(Collectors.toList());
    bigQueryPdao.validateDeleteRequest(dataset, dataDeletionRequest.getTables(), suffix);
    if (configService.testInsertFault(ConfigEnum.SOFT_DELETE_LOCK_CONFLICT_STOP_FAULT)) {
        logger.info("SOFT_DELETE_LOCK_CONFLICT_STOP_FAULT");
        while (!configService.testInsertFault(ConfigEnum.SOFT_DELETE_LOCK_CONFLICT_CONTINUE_FAULT)) {
            logger.info("Sleeping for CONTINUE FAULT");
            TimeUnit.SECONDS.sleep(5);
        }
        logger.info("SOFT_DELETE_LOCK_CONFLICT_CONTINUE_FAULT");
    }
    bigQueryPdao.applySoftDeletes(dataset, tableNames, suffix);
    // TODO: this can be more informative, something like # rows deleted per table, or mismatched row ids
    DeleteResponseModel deleteResponseModel = new DeleteResponseModel().objectState(DeleteResponseModel.ObjectStateEnum.DELETED);
    FlightUtils.setResponse(context, deleteResponseModel, HttpStatus.OK);
    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) DeleteResponseModel(bio.terra.model.DeleteResponseModel)

Example 49 with Dataset

use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.

the class DeleteDatasetValidateStep method doStep.

@Override
public StepResult doStep(FlightContext context) {
    List<SnapshotSummary> snapshots = snapshotDao.retrieveSnapshotsForDataset(datasetId);
    Dataset dataset = datasetService.retrieve(datasetId);
    if (snapshots.size() != 0) {
        throw new ValidationException("Can not delete a dataset being used by snapshots");
    }
    // if there are no snapshots returned from retrieveSnapshotsForDataset.
    if (dependencyDao.datasetHasSnapshotReference(dataset)) {
        throw new FileSystemCorruptException("File system has snapshot dependencies; metadata does not");
    }
    return StepResult.getStepResultSuccess();
}
Also used : SnapshotSummary(bio.terra.service.snapshot.SnapshotSummary) ValidationException(bio.terra.app.controller.exception.ValidationException) Dataset(bio.terra.service.dataset.Dataset) FileSystemCorruptException(bio.terra.service.filedata.exception.FileSystemCorruptException)

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