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();
}
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();
}
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();
}
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();
}
Aggregations