{"action":"created","comment":{"url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/comments/297214489","pull_request_review_id":254040148,"id":297214489,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI5NzIxNDQ4OQ==","diff_hunk":"@@ -0,0 +1,187 @@\n+package uk.gov.ons.ctp.integration.rhsvc.cloud;\n+\n+import com.godaddy.logging.Logger;\n+import com.godaddy.logging.LoggerFactory;\n+import com.google.api.core.ApiFuture;\n+import com.google.cloud.firestore.DocumentReference;\n+import com.google.cloud.firestore.FieldPath;\n+import com.google.cloud.firestore.Firestore;\n+import com.google.cloud.firestore.QueryDocumentSnapshot;\n+import com.google.cloud.firestore.QuerySnapshot;\n+import com.google.cloud.firestore.WriteResult;\n+import java.util.List;\n+import java.util.Optional;\n+import java.util.stream.Collectors;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.stereotype.Service;\n+import uk.gov.ons.ctp.common.error.CTPException;\n+import uk.gov.ons.ctp.common.error.CTPException.Fault;\n+\n+@Service\n+public class FirestoreDataStore implements CloudDataStore {\n+  private static final Logger log = LoggerFactory.getLogger(FirestoreDataStore.class);\n+\n+  // Names of environment variables which firestore uses for connection information\n+  public static final String FIRESTORE_PROJECT_ENV_NAME = \"GOOGLE_CLOUD_PROJECT\";\n+\n+  @Autowired private Firestore firestore;\n+\n+  /**\n+   * Write object to Firestore collection. If the object already exists then it will be overwritten.\n+   *\n+   * @param schema - holds the name of the collection that the object will be added to.\n+   * @param key - identifies the object within the collection.\n+   * @param value - is the object to be written to Firestore. It must provide get methods that allow\n+   *     access to its contents.\n+   * @throws CTPException if any failure was detected interacting with Firestore.\n+   */\n+  @Override\n+  public void storeObject(final String schema, final String key, final Object value)\n+      throws CTPException {\n+    log.debug(\"Saving object to Firestore. Schema '{}' with key '{}'\", schema, key);\n+\n+    // Store the object\n+    ApiFuture<WriteResult> result = firestore.collection(schema).document(key).set(value);\n+\n+    // Wait for Firestore to complete\n+    try {\n+      result.get();\n+      log.debug(\"Firstore save completed. Schema '{}' with key '{}'\", schema, key);","path":"src/main/java/uk/gov/ons/ctp/integration/rhsvc/cloud/FirestoreDataStore.java","position":49,"original_position":49,"commit_id":"3a2b233f9f9dfb817a8f665faf72aeac4dba79cd","original_commit_id":"3a2b233f9f9dfb817a8f665faf72aeac4dba79cd","user":{"login":"philwhiles","id":5368272,"node_id":"MDQ6VXNlcjUzNjgyNzI=","avatar_url":"https://avatars0.githubusercontent.com/u/5368272?v=4","gravatar_id":"","url":"https://api.github.com/users/philwhiles","html_url":"https://github.com/philwhiles","followers_url":"https://api.github.com/users/philwhiles/followers","following_url":"https://api.github.com/users/philwhiles/following{/other_user}","gists_url":"https://api.github.com/users/philwhiles/gists{/gist_id}","starred_url":"https://api.github.com/users/philwhiles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwhiles/subscriptions","organizations_url":"https://api.github.com/users/philwhiles/orgs","repos_url":"https://api.github.com/users/philwhiles/repos","events_url":"https://api.github.com/users/philwhiles/events{/privacy}","received_events_url":"https://api.github.com/users/philwhiles/received_events","type":"User","site_admin":false},"body":"A Firstore is a seasonal shop, often a garage forecourt, selling a specific type of tree","created_at":"2019-06-25T14:21:59Z","updated_at":"2019-06-25T14:21:59Z","html_url":"https://github.com/ONSdigital/census-rh-service/pull/24#discussion_r297214489","pull_request_url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/comments/297214489"},"html":{"href":"https://github.com/ONSdigital/census-rh-service/pull/24#discussion_r297214489"},"pull_request":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24"}},"in_reply_to_id":297214051},"pull_request":{"url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24","id":291450395,"node_id":"MDExOlB1bGxSZXF1ZXN0MjkxNDUwMzk1","html_url":"https://github.com/ONSdigital/census-rh-service/pull/24","diff_url":"https://github.com/ONSdigital/census-rh-service/pull/24.diff","patch_url":"https://github.com/ONSdigital/census-rh-service/pull/24.patch","issue_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/24","number":24,"state":"open","locked":false,"title":"Cr263 switch gcs datastore to firestore","user":{"login":"PeterBochel","id":47984593,"node_id":"MDQ6VXNlcjQ3OTg0NTkz","avatar_url":"https://avatars3.githubusercontent.com/u/47984593?v=4","gravatar_id":"","url":"https://api.github.com/users/PeterBochel","html_url":"https://github.com/PeterBochel","followers_url":"https://api.github.com/users/PeterBochel/followers","following_url":"https://api.github.com/users/PeterBochel/following{/other_user}","gists_url":"https://api.github.com/users/PeterBochel/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterBochel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterBochel/subscriptions","organizations_url":"https://api.github.com/users/PeterBochel/orgs","repos_url":"https://api.github.com/users/PeterBochel/repos","events_url":"https://api.github.com/users/PeterBochel/events{/privacy}","received_events_url":"https://api.github.com/users/PeterBochel/received_events","type":"User","site_admin":false},"body":"# Motivation and Context\r\nThere are 2 main reasons to switch to Firestore from GCS (Google Cloud Storage):\r\n1. Allow retrieval of cases by UPRN.\r\n2. Performance.\r\n\r\n# What has changed\r\nThe most significant change has been that GCSDataStore.java has been replaced with FirestoreDataStore.java. \r\n\r\nThis switch to Firestore has caused relatively minor changes to ripple up to the CloudDataStore interface.\r\n\r\nTest cases have been updated to test FirestoreDataStore. \r\n\r\nI've also added a component level integration test, Firestore_IT.java, which does testing of FirestoreDataStore with no mocking. So data is held by your Firestore datastore. These tests are currently marked as '@Ignore' as you really need to manually set things up to run this test.\r\n\r\n# How to test?\r\n1. Run all unit tests. \r\n2. Re-enable the tests in Firestore_IT and run that.\r\n3. Manually run in UAC and CASE data. The steps to run a manual test have been added to the top level Readme.md file in the RH project.\r\n\r\n# Links\r\nSee: https://collaborate2.ons.gov.uk/jira/browse/CR-263","created_at":"2019-06-25T08:48:49Z","updated_at":"2019-06-25T14:21:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64e9c0da7750b9cc62ce63e622daa18af24030fe","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24/commits","review_comments_url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24/comments","review_comment_url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/24/comments","statuses_url":"https://api.github.com/repos/ONSdigital/census-rh-service/statuses/3a2b233f9f9dfb817a8f665faf72aeac4dba79cd","head":{"label":"ONSdigital:CR263_SwitchGCSDatastoreToFirestore","ref":"CR263_SwitchGCSDatastoreToFirestore","sha":"3a2b233f9f9dfb817a8f665faf72aeac4dba79cd","user":{"login":"ONSdigital","id":6865137,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NjUxMzc=","avatar_url":"https://avatars0.githubusercontent.com/u/6865137?v=4","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"repo":{"id":166391677,"node_id":"MDEwOlJlcG9zaXRvcnkxNjYzOTE2Nzc=","name":"census-rh-service","full_name":"ONSdigital/census-rh-service","private":false,"owner":{"login":"ONSdigital","id":6865137,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NjUxMzc=","avatar_url":"https://avatars0.githubusercontent.com/u/6865137?v=4","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ONSdigital/census-rh-service","description":"Microservice to support the Census Respondent Home UI","fork":false,"url":"https://api.github.com/repos/ONSdigital/census-rh-service","forks_url":"https://api.github.com/repos/ONSdigital/census-rh-service/forks","keys_url":"https://api.github.com/repos/ONSdigital/census-rh-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/census-rh-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/census-rh-service/teams","hooks_url":"https://api.github.com/repos/ONSdigital/census-rh-service/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/census-rh-service/events","assignees_url":"https://api.github.com/repos/ONSdigital/census-rh-service/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/census-rh-service/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/census-rh-service/tags","blobs_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/census-rh-service/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/census-rh-service/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/census-rh-service/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/census-rh-service/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/census-rh-service/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/census-rh-service/subscription","commits_url":"https://api.github.com/repos/ONSdigital/census-rh-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/census-rh-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/census-rh-service/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/census-rh-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/census-rh-service/merges","archive_url":"https://api.github.com/repos/ONSdigital/census-rh-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/census-rh-service/downloads","issues_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/census-rh-service/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/census-rh-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/census-rh-service/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/census-rh-service/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/census-rh-service/deployments","created_at":"2019-01-18T11:01:29Z","updated_at":"2019-06-21T12:26:44Z","pushed_at":"2019-06-25T12:18:22Z","git_url":"git://github.com/ONSdigital/census-rh-service.git","ssh_url":"git@github.com:ONSdigital/census-rh-service.git","clone_url":"https://github.com/ONSdigital/census-rh-service.git","svn_url":"https://github.com/ONSdigital/census-rh-service","homepage":"","size":583,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"ONSdigital:master","ref":"master","sha":"9d57f63eeed2aeedb5381d429ec3899ec7aeaa04","user":{"login":"ONSdigital","id":6865137,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NjUxMzc=","avatar_url":"https://avatars0.githubusercontent.com/u/6865137?v=4","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"repo":{"id":166391677,"node_id":"MDEwOlJlcG9zaXRvcnkxNjYzOTE2Nzc=","name":"census-rh-service","full_name":"ONSdigital/census-rh-service","private":false,"owner":{"login":"ONSdigital","id":6865137,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NjUxMzc=","avatar_url":"https://avatars0.githubusercontent.com/u/6865137?v=4","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ONSdigital/census-rh-service","description":"Microservice to support the Census Respondent Home UI","fork":false,"url":"https://api.github.com/repos/ONSdigital/census-rh-service","forks_url":"https://api.github.com/repos/ONSdigital/census-rh-service/forks","keys_url":"https://api.github.com/repos/ONSdigital/census-rh-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/census-rh-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/census-rh-service/teams","hooks_url":"https://api.github.com/repos/ONSdigital/census-rh-service/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/census-rh-service/events","assignees_url":"https://api.github.com/repos/ONSdigital/census-rh-service/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/census-rh-service/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/census-rh-service/tags","blobs_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/census-rh-service/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/census-rh-service/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/census-rh-service/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/census-rh-service/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/census-rh-service/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/census-rh-service/subscription","commits_url":"https://api.github.com/repos/ONSdigital/census-rh-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/census-rh-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/census-rh-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/census-rh-service/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/census-rh-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/census-rh-service/merges","archive_url":"https://api.github.com/repos/ONSdigital/census-rh-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/census-rh-service/downloads","issues_url":"https://api.github.com/repos/ONSdigital/census-rh-service/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/census-rh-service/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/census-rh-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/census-rh-service/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/census-rh-service/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/census-rh-service/deployments","created_at":"2019-01-18T11:01:29Z","updated_at":"2019-06-21T12:26:44Z","pushed_at":"2019-06-25T12:18:22Z","git_url":"git://github.com/ONSdigital/census-rh-service.git","ssh_url":"git@github.com:ONSdigital/census-rh-service.git","clone_url":"https://github.com/ONSdigital/census-rh-service.git","svn_url":"https://github.com/ONSdigital/census-rh-service","homepage":"","size":583,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24"},"html":{"href":"https://github.com/ONSdigital/census-rh-service/pull/24"},"issue":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/24"},"comments":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/ONSdigital/census-rh-service/statuses/3a2b233f9f9dfb817a8f665faf72aeac4dba79cd"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"philwhiles"}}