Search in sources :

Example 16 with DatasetDataProject

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

the class FireStoreDao method deleteFileMetadata.

public boolean deleteFileMetadata(Dataset dataset, String fileId) {
    DatasetDataProject dataProject = dataLocationService.getProjectOrThrow(dataset);
    Firestore firestore = FireStoreProject.get(dataProject.getGoogleProjectId()).getFirestore();
    String datasetId = dataset.getId().toString();
    return fileDao.deleteFileMetadata(firestore, datasetId, fileId);
}
Also used : Firestore(com.google.cloud.firestore.Firestore) DatasetDataProject(bio.terra.service.dataset.DatasetDataProject)

Example 17 with DatasetDataProject

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

the class FireStoreDao method lookupDirectoryEntry.

public FireStoreDirectoryEntry lookupDirectoryEntry(Dataset dataset, String fileId) {
    DatasetDataProject dataProject = dataLocationService.getProjectOrThrow(dataset);
    Firestore firestore = FireStoreProject.get(dataProject.getGoogleProjectId()).getFirestore();
    String datasetId = dataset.getId().toString();
    return directoryDao.retrieveById(firestore, datasetId, fileId);
}
Also used : Firestore(com.google.cloud.firestore.Firestore) DatasetDataProject(bio.terra.service.dataset.DatasetDataProject)

Example 18 with DatasetDataProject

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

the class FireStoreDependencyDao method fileHasSnapshotReference.

public boolean fileHasSnapshotReference(Dataset dataset, String fileId) throws InterruptedException {
    DatasetDataProject dataProject = dataLocationService.getProjectOrThrow(dataset);
    FireStoreProject fireStoreProject = FireStoreProject.get(dataProject.getGoogleProjectId());
    String dependencyCollectionName = getDatasetDependencyId(dataset.getId().toString());
    CollectionReference depColl = fireStoreProject.getFirestore().collection(dependencyCollectionName);
    Query query = depColl.whereEqualTo("fileId", fileId);
    return hasReference(query);
}
Also used : Query(com.google.cloud.firestore.Query) DatasetDataProject(bio.terra.service.dataset.DatasetDataProject) CollectionReference(com.google.cloud.firestore.CollectionReference)

Example 19 with DatasetDataProject

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

the class FireStoreDependencyDao method getDatasetSnapshotFileIds.

public List<String> getDatasetSnapshotFileIds(Dataset dataset, String snapshotId) throws InterruptedException {
    DatasetDataProject dataProject = dataLocationService.getProjectOrThrow(dataset);
    FireStoreProject fireStoreProject = FireStoreProject.get(dataProject.getGoogleProjectId());
    String dependencyCollectionName = getDatasetDependencyId(dataset.getId().toString());
    CollectionReference depColl = fireStoreProject.getFirestore().collection(dependencyCollectionName);
    Query query = depColl.whereEqualTo("snapshotId", snapshotId);
    ApiFuture<QuerySnapshot> querySnapshot = query.get();
    List<String> fileIds = new ArrayList<>();
    try {
        List<QueryDocumentSnapshot> documents = querySnapshot.get().getDocuments();
        for (DocumentSnapshot docSnap : documents) {
            FireStoreDependency fireStoreDependency = docSnap.toObject(FireStoreDependency.class);
            fileIds.add(fireStoreDependency.getFileId());
        }
        return fileIds;
    } catch (ExecutionException ex) {
        throw new FileSystemExecutionException("get file ids - execution exception", ex);
    }
}
Also used : Query(com.google.cloud.firestore.Query) QueryDocumentSnapshot(com.google.cloud.firestore.QueryDocumentSnapshot) ArrayList(java.util.ArrayList) FileSystemExecutionException(bio.terra.service.filedata.exception.FileSystemExecutionException) DatasetDataProject(bio.terra.service.dataset.DatasetDataProject) CollectionReference(com.google.cloud.firestore.CollectionReference) QuerySnapshot(com.google.cloud.firestore.QuerySnapshot) QueryDocumentSnapshot(com.google.cloud.firestore.QueryDocumentSnapshot) DocumentSnapshot(com.google.cloud.firestore.DocumentSnapshot) FileSystemExecutionException(bio.terra.service.filedata.exception.FileSystemExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 20 with DatasetDataProject

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

the class TestUtils method bigQueryProjectForDatasetName.

public static BigQueryProject bigQueryProjectForDatasetName(DatasetDao datasetDao, DataLocationService dataLocationService, String datasetName) throws InterruptedException {
    Dataset dataset = datasetDao.retrieveByName(datasetName);
    DatasetDataProject dataProject = dataLocationService.getOrCreateProject(dataset);
    return BigQueryProject.get(dataProject.getGoogleProjectId());
}
Also used : Dataset(bio.terra.service.dataset.Dataset) DatasetDataProject(bio.terra.service.dataset.DatasetDataProject)

Aggregations

DatasetDataProject (bio.terra.service.dataset.DatasetDataProject)20 Firestore (com.google.cloud.firestore.Firestore)10 CollectionReference (com.google.cloud.firestore.CollectionReference)6 Query (com.google.cloud.firestore.Query)5 QueryDocumentSnapshot (com.google.cloud.firestore.QueryDocumentSnapshot)4 QuerySnapshot (com.google.cloud.firestore.QuerySnapshot)4 Dataset (bio.terra.service.dataset.Dataset)2 DatasetDataProjectSummary (bio.terra.service.dataset.DatasetDataProjectSummary)2 FileSystemCorruptException (bio.terra.service.filedata.exception.FileSystemCorruptException)2 FileSystemExecutionException (bio.terra.service.filedata.exception.FileSystemExecutionException)2 GoogleProjectResource (bio.terra.service.resourcemanagement.google.GoogleProjectResource)2 DocumentSnapshot (com.google.cloud.firestore.DocumentSnapshot)2 ExecutionException (java.util.concurrent.ExecutionException)2 DataProjectNotFoundException (bio.terra.service.resourcemanagement.exception.DataProjectNotFoundException)1 GoogleResourceNotFoundException (bio.terra.service.resourcemanagement.exception.GoogleResourceNotFoundException)1 GoogleProjectRequest (bio.terra.service.resourcemanagement.google.GoogleProjectRequest)1 SnapshotDataProject (bio.terra.service.snapshot.SnapshotDataProject)1 DocumentReference (com.google.cloud.firestore.DocumentReference)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1