use of bio.terra.service.snapshot.SnapshotDataProject in project jade-data-repo by DataBiosphere.
the class DataLocationService method getOrCreateProject.
/**
* Fetch existing SnapshotDataProject for the Snapshot.
* Create a new one if none exists already.
* @param snapshot
* @return a populated and valid SnapshotDataProject
*/
public SnapshotDataProject getOrCreateProject(Snapshot snapshot) throws InterruptedException {
// check if for an existing SnapshotDataProject first, and return here if found one
Optional<SnapshotDataProject> existingDataProject = getProject(snapshot);
if (existingDataProject.isPresent()) {
return existingDataProject.get();
}
// if we've made it here, then we need to create a new cloud resource and SnapshotDataProject
GoogleProjectRequest googleProjectRequest = new GoogleProjectRequest().projectId(dataLocationSelector.projectIdForSnapshot(snapshot)).profileId(snapshot.getProfileId()).serviceIds(DATA_PROJECT_SERVICE_IDS);
GoogleProjectResource googleProjectResource = resourceService.getOrCreateProject(googleProjectRequest);
// create the SnapshotDataProjectSummary object first, which just holds all the IDs
SnapshotDataProjectSummary snapshotDataProjectSummary = new SnapshotDataProjectSummary().projectResourceId(googleProjectResource.getRepositoryId()).snapshotId(snapshot.getId());
UUID snapshotDataProjectId = dataProjectDao.createSnapshotDataProject(snapshotDataProjectSummary);
snapshotDataProjectSummary.id(snapshotDataProjectId);
// then create the SnapshotDataProject object from the summary
return new SnapshotDataProject(snapshotDataProjectSummary).googleProjectResource(googleProjectResource);
}
use of bio.terra.service.snapshot.SnapshotDataProject in project jade-data-repo by DataBiosphere.
the class FireStoreDao method deleteFilesFromSnapshot.
public void deleteFilesFromSnapshot(Snapshot snapshot) {
SnapshotDataProject dataProject = dataLocationService.getProjectOrThrow(snapshot);
Firestore firestore = FireStoreProject.get(dataProject.getGoogleProjectId()).getFirestore();
String snapshotId = snapshot.getId().toString();
directoryDao.deleteDirectoryEntriesFromCollection(firestore, snapshotId);
}
Aggregations