use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class SnapshotService method getAssetSpecificationFromRequest.
private AssetSpecification getAssetSpecificationFromRequest(SnapshotRequestContentsModel requestContents) {
SnapshotRequestAssetModel requestAssetModel = requestContents.getAssetSpec();
Dataset dataset = datasetService.retrieveByName(requestContents.getDatasetName());
Optional<AssetSpecification> optAsset = dataset.getAssetSpecificationByName(requestAssetModel.getAssetName());
if (!optAsset.isPresent()) {
throw new AssetNotFoundException("Asset specification not found: " + requestAssetModel.getAssetName());
}
// the map construction will go here. For MVM, we generate the mapping data directly from the asset spec.
return optAsset.get();
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class SnapshotService method makeSourceModelFromSource.
private SnapshotSourceModel makeSourceModelFromSource(SnapshotSource source) {
// TODO: when source summary methods are available, use those. Here I roll my own
Dataset dataset = source.getDataset();
DatasetSummaryModel summaryModel = new DatasetSummaryModel().id(dataset.getId().toString()).name(dataset.getName()).description(dataset.getDescription()).defaultProfileId(dataset.getDefaultProfileId().toString()).createdDate(dataset.getCreatedDate().toString());
SnapshotSourceModel sourceModel = new SnapshotSourceModel().dataset(summaryModel);
AssetSpecification assetSpec = source.getAssetSpecification();
if (assetSpec != null) {
sourceModel.asset(assetSpec.getName());
}
return sourceModel;
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class SnapshotService method undoCreateSnapshot.
public void undoCreateSnapshot(String snapshotName) throws InterruptedException {
// Remove any file dependencies created
Snapshot snapshot = snapshotDao.retrieveSnapshotByName(snapshotName);
for (SnapshotSource snapshotSource : snapshot.getSnapshotSources()) {
Dataset dataset = datasetService.retrieve(snapshotSource.getDataset().getId());
dependencyDao.deleteSnapshotFileDependencies(dataset, snapshot.getId().toString());
}
bigQueryPdao.deleteSnapshot(snapshot);
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class CreateSnapshotFireStoreDataStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
// We need a complete snapshot; use the snapshotService to get one.
Snapshot snapshot = snapshotService.retrieveByName(snapshotReq.getName());
// bounds the intermediate size in a way.
for (SnapshotSource snapshotSource : snapshot.getSnapshotSources()) {
for (SnapshotMapTable mapTable : snapshotSource.getSnapshotMapTables()) {
for (SnapshotMapColumn mapColumn : mapTable.getSnapshotMapColumns()) {
String fromDatatype = mapColumn.getFromColumn().getType();
if (StringUtils.equalsIgnoreCase(fromDatatype, "FILEREF") || StringUtils.equalsIgnoreCase(fromDatatype, "DIRREF")) {
List<String> refIds = bigQueryPdao.getSnapshotRefIds(snapshotSource.getDataset(), snapshot.getName(), mapTable.getFromTable().getName(), mapTable.getFromTable().getId().toString(), mapColumn.getFromColumn());
Dataset dataset = datasetService.retrieve(snapshotSource.getDataset().getId());
fileDao.addFilesToSnapshot(dataset, snapshot, refIds);
dependencyDao.storeSnapshotFileDependencies(dataset, snapshot.getId().toString(), refIds);
}
}
}
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.service.dataset.Dataset in project jade-data-repo by DataBiosphere.
the class SnapshotDao method retrieveSnapshotSources.
private List<SnapshotSource> retrieveSnapshotSources(Snapshot snapshot) {
// query might work, it makes debugging errors more difficult.
class RawSourceData {
private UUID id;
private UUID datasetId;
private UUID assetId;
}
String sql = "SELECT id, dataset_id, asset_id FROM snapshot_source WHERE snapshot_id = :snapshot_id";
List<RawSourceData> rawList = jdbcTemplate.query(sql, new MapSqlParameterSource().addValue("snapshot_id", snapshot.getId()), (rs, rowNum) -> {
RawSourceData raw = new RawSourceData();
raw.id = UUID.fromString(rs.getString("id"));
raw.datasetId = rs.getObject("dataset_id", UUID.class);
raw.assetId = rs.getObject("asset_id", UUID.class);
return raw;
});
List<SnapshotSource> snapshotSources = new ArrayList<>();
for (RawSourceData raw : rawList) {
Dataset dataset = datasetDao.retrieve(raw.datasetId);
SnapshotSource snapshotSource = new SnapshotSource().id(raw.id).snapshot(snapshot).dataset(dataset);
if (raw.assetId != null) {
// if there is no assetId, then dont check for a spec
// Find the matching asset in the dataset
Optional<AssetSpecification> assetSpecification = dataset.getAssetSpecificationById(raw.assetId);
if (!assetSpecification.isPresent()) {
throw new CorruptMetadataException("Asset referenced by snapshot source was not found!");
}
snapshotSource.assetSpecification(assetSpecification.get());
}
// Now that we have access to all of the parts, build the map structure
snapshotSource.snapshotMapTables(snapshotMapTableDao.retrieveMapTables(snapshot, snapshotSource));
snapshotSources.add(snapshotSource);
}
return snapshotSources;
}
Aggregations