use of bio.terra.model.DataDeletionGcsFileModel in project jade-data-repo by DataBiosphere.
the class DataDeletionRequestValidator method validateFileSpec.
private void validateFileSpec(DataDeletionTableModel fileSpec, Errors errors) {
String tableName = fileSpec.getTableName();
if (StringUtils.isEmpty(tableName)) {
errors.rejectValue("tables.tableName", "TableNameMissing", "Requires a table name");
}
DataDeletionGcsFileModel gcsFileSpec = fileSpec.getGcsFileSpec();
if (gcsFileSpec == null) {
errors.rejectValue("tables.gcsFileSpec", "FileSpecMissing", "Requires a file spec");
} else {
try {
IngestUtils.parseBlobUri(gcsFileSpec.getPath());
} catch (InvalidUriException ex) {
errors.rejectValue("tables.gcsFileSpec.path", "InvalidGsUri", ex.getMessage());
}
}
}
use of bio.terra.model.DataDeletionGcsFileModel in project jade-data-repo by DataBiosphere.
the class DatasetConnectedTest method uploadInputFileAndBuildSoftDeleteRequest.
private DataDeletionRequest uploadInputFileAndBuildSoftDeleteRequest(String dirInCloud, String filenameInCloud, String tableName, List<String> softDeleteRowIds) throws Exception {
Storage storage = StorageOptions.getDefaultInstance().getService();
// load a CSV file that contains the table rows to soft delete into the test bucket
StringBuilder csvLines = new StringBuilder();
for (String softDeleteRowId : softDeleteRowIds) {
csvLines.append(softDeleteRowId + "\n");
}
BlobInfo softDeleteBlob = BlobInfo.newBuilder(testConfig.getIngestbucket(), dirInCloud + "/" + filenameInCloud).build();
storage.create(softDeleteBlob, csvLines.toString().getBytes(Charset.forName("UTF-8")));
String softDeleteInputFilePath = "gs://" + testConfig.getIngestbucket() + "/" + dirInCloud + "/" + filenameInCloud;
// make sure the JSON file gets cleaned up on test teardown
connectedOperations.addScratchFile(dirInCloud + "/" + filenameInCloud);
// build the soft delete request with a pointer to a file that contains the row ids to soft delete
DataDeletionGcsFileModel softDeleteGcsFileModel = new DataDeletionGcsFileModel().fileType(DataDeletionGcsFileModel.FileTypeEnum.CSV).path(softDeleteInputFilePath);
DataDeletionTableModel softDeleteTableModel = new DataDeletionTableModel().tableName(tableName).gcsFileSpec(softDeleteGcsFileModel);
DataDeletionRequest softDeleteRequest = new DataDeletionRequest().deleteType(DataDeletionRequest.DeleteTypeEnum.SOFT).specType(DataDeletionRequest.SpecTypeEnum.GCSFILE).tables(Arrays.asList(softDeleteTableModel));
return softDeleteRequest;
}
Aggregations