use of com.google.cloud.firestore.DocumentSnapshot in project jade-data-repo by DataBiosphere.
the class FireStoreFileDao method lookupByFileId.
private DocumentSnapshot lookupByFileId(Firestore firestore, String collectionId, String fileId, Transaction xn) {
DocumentReference docRef = getFileDocRef(firestore, collectionId, fileId);
ApiFuture<DocumentSnapshot> docSnapFuture = xn.get(docRef);
try {
return docSnapFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("lookupByFileId - execution interrupted", ex);
} catch (ExecutionException ex) {
throw new FileSystemExecutionException("lookupByFileId - execution exception", ex);
}
}
use of com.google.cloud.firestore.DocumentSnapshot in project spring-cloud-gcp by GoogleCloudPlatform.
the class FirestoreSampleApp method readDocumentToMap.
private void readDocumentToMap() throws ExecutionException, InterruptedException {
DocumentReference docRef = this.firestore.document("users/ada");
ApiFuture<DocumentSnapshot> documentSnapshotApiFuture = docRef.get();
DocumentSnapshot document = documentSnapshotApiFuture.get();
System.out.println("read: " + document.getData());
}
use of com.google.cloud.firestore.DocumentSnapshot in project spring-cloud-gcp by GoogleCloudPlatform.
the class FirestoreDefaultClassMapper method documentToEntity.
public <T> T documentToEntity(Document document, Class<T> clazz) {
DocumentSnapshot documentSnapshot = INTERNAL.snapshotFromProto(Timestamp.now(), document);
T entity = documentSnapshot.toObject(clazz);
return setUpdateTime(entity, documentSnapshot.getUpdateTime());
}
use of com.google.cloud.firestore.DocumentSnapshot in project Protego by nickdlc.
the class ProtegoHomeController method getUser.
@GetMapping("/user")
public ProtegoUser getUser(@RequestParam("user") String uid) {
// Get user with id uid
try {
// Temporarily create a new doctor and return that
FirebaseAttributes.firestore.collection("users").document(uid).get();
// Asynchronously retrieve multiple documents
ApiFuture<DocumentSnapshot> future = FirebaseAttributes.firestore.collection("users").document(uid).get();
// future.get() blocks on response
DocumentSnapshot document = future.get();
return document.toObject(ProtegoUser.class);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
use of com.google.cloud.firestore.DocumentSnapshot in project Protego by nickdlc.
the class ProtegoHomeController method getDoctor.
@GetMapping("/doctor")
public Doctor getDoctor(@RequestParam("doctor") String duid) {
// Get doctor with id duid
try {
// Temporarily create a new doctor and return that
FirebaseAttributes.firestore.collection("users").document(duid).get();
// Asynchronously retrieve multiple documents
ApiFuture<DocumentSnapshot> future = FirebaseAttributes.firestore.collection("users").document(duid).get();
// future.get() blocks on response
DocumentSnapshot document = future.get();
return document.toObject(Doctor.class);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
Aggregations