{"action":"created","comment":{"url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/comments/46574643","id":46574643,"diff_hunk":"@@ -0,0 +1,148 @@\n+package org.sagebionetworks.bridge.dynamodb;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+import static org.sagebionetworks.bridge.util.BridgeCollectors.toImmutableList;\n+\n+import java.util.List;\n+\n+import javax.annotation.Resource;\n+\n+import org.springframework.stereotype.Component;\n+\n+import org.sagebionetworks.bridge.BridgeUtils;\n+import org.sagebionetworks.bridge.dao.SubpopulationDao;\n+import org.sagebionetworks.bridge.exceptions.BadRequestException;\n+import org.sagebionetworks.bridge.exceptions.EntityNotFoundException;\n+import org.sagebionetworks.bridge.models.CriteriaUtils;\n+import org.sagebionetworks.bridge.models.schedules.ScheduleContext;\n+import org.sagebionetworks.bridge.models.studies.Subpopulation;\n+import org.sagebionetworks.bridge.models.studies.StudyIdentifier;\n+import org.sagebionetworks.bridge.models.studies.StudyIdentifierImpl;\n+\n+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;\n+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;\n+import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.FailedBatch;\n+import com.google.common.collect.ImmutableList;\n+import com.google.common.collect.Lists;\n+\n+@Component\n+public class DynamoSubpopulationDao implements SubpopulationDao {\n+    \n+    private DynamoDBMapper mapper;\n+\n+    /** DynamoDB mapper for the HealthDataRecord table. This is configured by Spring. */\n+    @Resource(name = \"subpopulationDdbMapper\")\n+    public final void setMapper(DynamoDBMapper mapper) {\n+        this.mapper = mapper;\n+    }\n+    \n+    @Override\n+    public Subpopulation createSubpopulation(Subpopulation subpop) {\n+        checkNotNull(subpop);\n+        checkNotNull(subpop.getGuid());\n+        checkNotNull(subpop.getStudyIdentifier());\n+\n+        if (subpop.getVersion() != null || subpop.isDeleted() || subpop.isRequired()) {\n+            throw new BadRequestException(\"Subpopulation does not appear to be a new object\");\n+        }\n+        mapper.save(subpop);\n+        return subpop;\n+    }\n+\n+    @Override\n+    public Subpopulation updateSubpopulation(Subpopulation subpop) {\n+        checkNotNull(subpop);\n+        checkNotNull(subpop.getStudyIdentifier());\n+        checkNotNull(subpop.getVersion());\n+        checkNotNull(subpop.getGuid());\n+        \n+        Subpopulation existing = getSubpopulation(new StudyIdentifierImpl(subpop.getStudyIdentifier()), subpop.getGuid());\n+        if (existing.isDeleted()) {\n+            throw new EntityNotFoundException(Subpopulation.class);\n+        }","path":"app/org/sagebionetworks/bridge/dynamodb/DynamoSubpopulationDao.java","position":62,"original_position":62,"commit_id":"7a717dc1b203769d6dac9b625dd12782077a6cc8","original_commit_id":"7a717dc1b203769d6dac9b625dd12782077a6cc8","user":{"login":"alxdarksage","id":5589085,"avatar_url":"https://avatars.githubusercontent.com/u/5589085?v=3","gravatar_id":"","url":"https://api.github.com/users/alxdarksage","html_url":"https://github.com/alxdarksage","followers_url":"https://api.github.com/users/alxdarksage/followers","following_url":"https://api.github.com/users/alxdarksage/following{/other_user}","gists_url":"https://api.github.com/users/alxdarksage/gists{/gist_id}","starred_url":"https://api.github.com/users/alxdarksage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxdarksage/subscriptions","organizations_url":"https://api.github.com/users/alxdarksage/orgs","repos_url":"https://api.github.com/users/alxdarksage/repos","events_url":"https://api.github.com/users/alxdarksage/events{/privacy}","received_events_url":"https://api.github.com/users/alxdarksage/received_events","type":"User","site_admin":false},"body":"Good point, Setting deleted to false before saving (setting it will have no effect for an update).","created_at":"2015-12-03T16:30:35Z","updated_at":"2015-12-03T16:30:35Z","html_url":"https://github.com/Sage-Bionetworks/BridgePF/pull/937#discussion_r46574643","pull_request_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937","_links":{"self":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/comments/46574643"},"html":{"href":"https://github.com/Sage-Bionetworks/BridgePF/pull/937#discussion_r46574643"},"pull_request":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937"}}},"pull_request":{"url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937","id":51847976,"html_url":"https://github.com/Sage-Bionetworks/BridgePF/pull/937","diff_url":"https://github.com/Sage-Bionetworks/BridgePF/pull/937.diff","patch_url":"https://github.com/Sage-Bionetworks/BridgePF/pull/937.patch","issue_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues/937","number":937,"state":"open","locked":false,"title":"Subpopulations","user":{"login":"alxdarksage","id":5589085,"avatar_url":"https://avatars.githubusercontent.com/u/5589085?v=3","gravatar_id":"","url":"https://api.github.com/users/alxdarksage","html_url":"https://github.com/alxdarksage","followers_url":"https://api.github.com/users/alxdarksage/followers","following_url":"https://api.github.com/users/alxdarksage/following{/other_user}","gists_url":"https://api.github.com/users/alxdarksage/gists{/gist_id}","starred_url":"https://api.github.com/users/alxdarksage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxdarksage/subscriptions","organizations_url":"https://api.github.com/users/alxdarksage/orgs","repos_url":"https://api.github.com/users/alxdarksage/repos","events_url":"https://api.github.com/users/alxdarksage/events{/privacy}","received_events_url":"https://api.github.com/users/alxdarksage/received_events","type":"User","site_admin":false},"body":"- basic crud support from the REST API to DynamoDB for subpopulations. They are not connected to anything else right now, this seems like enough to review before proceeding (a good place to break up what will be a large change to the system).","created_at":"2015-11-25T21:27:34Z","updated_at":"2015-12-03T16:30:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d393d5f266ddb30a96e972e20864cb808b7a8449","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937/commits","review_comments_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937/comments","review_comment_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues/937/comments","statuses_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/statuses/7a717dc1b203769d6dac9b625dd12782077a6cc8","head":{"label":"alxdarksage:cohorts","ref":"cohorts","sha":"7a717dc1b203769d6dac9b625dd12782077a6cc8","user":{"login":"alxdarksage","id":5589085,"avatar_url":"https://avatars.githubusercontent.com/u/5589085?v=3","gravatar_id":"","url":"https://api.github.com/users/alxdarksage","html_url":"https://github.com/alxdarksage","followers_url":"https://api.github.com/users/alxdarksage/followers","following_url":"https://api.github.com/users/alxdarksage/following{/other_user}","gists_url":"https://api.github.com/users/alxdarksage/gists{/gist_id}","starred_url":"https://api.github.com/users/alxdarksage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxdarksage/subscriptions","organizations_url":"https://api.github.com/users/alxdarksage/orgs","repos_url":"https://api.github.com/users/alxdarksage/repos","events_url":"https://api.github.com/users/alxdarksage/events{/privacy}","received_events_url":"https://api.github.com/users/alxdarksage/received_events","type":"User","site_admin":false},"repo":{"id":45479946,"name":"BridgePF","full_name":"alxdarksage/BridgePF","owner":{"login":"alxdarksage","id":5589085,"avatar_url":"https://avatars.githubusercontent.com/u/5589085?v=3","gravatar_id":"","url":"https://api.github.com/users/alxdarksage","html_url":"https://github.com/alxdarksage","followers_url":"https://api.github.com/users/alxdarksage/followers","following_url":"https://api.github.com/users/alxdarksage/following{/other_user}","gists_url":"https://api.github.com/users/alxdarksage/gists{/gist_id}","starred_url":"https://api.github.com/users/alxdarksage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxdarksage/subscriptions","organizations_url":"https://api.github.com/users/alxdarksage/orgs","repos_url":"https://api.github.com/users/alxdarksage/repos","events_url":"https://api.github.com/users/alxdarksage/events{/privacy}","received_events_url":"https://api.github.com/users/alxdarksage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alxdarksage/BridgePF","description":"Server software for Bridge-based mobile applications","fork":true,"url":"https://api.github.com/repos/alxdarksage/BridgePF","forks_url":"https://api.github.com/repos/alxdarksage/BridgePF/forks","keys_url":"https://api.github.com/repos/alxdarksage/BridgePF/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alxdarksage/BridgePF/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alxdarksage/BridgePF/teams","hooks_url":"https://api.github.com/repos/alxdarksage/BridgePF/hooks","issue_events_url":"https://api.github.com/repos/alxdarksage/BridgePF/issues/events{/number}","events_url":"https://api.github.com/repos/alxdarksage/BridgePF/events","assignees_url":"https://api.github.com/repos/alxdarksage/BridgePF/assignees{/user}","branches_url":"https://api.github.com/repos/alxdarksage/BridgePF/branches{/branch}","tags_url":"https://api.github.com/repos/alxdarksage/BridgePF/tags","blobs_url":"https://api.github.com/repos/alxdarksage/BridgePF/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alxdarksage/BridgePF/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alxdarksage/BridgePF/git/refs{/sha}","trees_url":"https://api.github.com/repos/alxdarksage/BridgePF/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alxdarksage/BridgePF/statuses/{sha}","languages_url":"https://api.github.com/repos/alxdarksage/BridgePF/languages","stargazers_url":"https://api.github.com/repos/alxdarksage/BridgePF/stargazers","contributors_url":"https://api.github.com/repos/alxdarksage/BridgePF/contributors","subscribers_url":"https://api.github.com/repos/alxdarksage/BridgePF/subscribers","subscription_url":"https://api.github.com/repos/alxdarksage/BridgePF/subscription","commits_url":"https://api.github.com/repos/alxdarksage/BridgePF/commits{/sha}","git_commits_url":"https://api.github.com/repos/alxdarksage/BridgePF/git/commits{/sha}","comments_url":"https://api.github.com/repos/alxdarksage/BridgePF/comments{/number}","issue_comment_url":"https://api.github.com/repos/alxdarksage/BridgePF/issues/comments{/number}","contents_url":"https://api.github.com/repos/alxdarksage/BridgePF/contents/{+path}","compare_url":"https://api.github.com/repos/alxdarksage/BridgePF/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alxdarksage/BridgePF/merges","archive_url":"https://api.github.com/repos/alxdarksage/BridgePF/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alxdarksage/BridgePF/downloads","issues_url":"https://api.github.com/repos/alxdarksage/BridgePF/issues{/number}","pulls_url":"https://api.github.com/repos/alxdarksage/BridgePF/pulls{/number}","milestones_url":"https://api.github.com/repos/alxdarksage/BridgePF/milestones{/number}","notifications_url":"https://api.github.com/repos/alxdarksage/BridgePF/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alxdarksage/BridgePF/labels{/name}","releases_url":"https://api.github.com/repos/alxdarksage/BridgePF/releases{/id}","created_at":"2015-11-03T16:35:11Z","updated_at":"2015-11-03T16:35:16Z","pushed_at":"2015-12-03T01:11:30Z","git_url":"git://github.com/alxdarksage/BridgePF.git","ssh_url":"git@github.com:alxdarksage/BridgePF.git","clone_url":"https://github.com/alxdarksage/BridgePF.git","svn_url":"https://github.com/alxdarksage/BridgePF","homepage":"","size":72393,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"Sage-Bionetworks:develop","ref":"develop","sha":"3d53bc487d42a43cd2678e1df734ccaae825da53","user":{"login":"Sage-Bionetworks","id":1250897,"avatar_url":"https://avatars.githubusercontent.com/u/1250897?v=3","gravatar_id":"","url":"https://api.github.com/users/Sage-Bionetworks","html_url":"https://github.com/Sage-Bionetworks","followers_url":"https://api.github.com/users/Sage-Bionetworks/followers","following_url":"https://api.github.com/users/Sage-Bionetworks/following{/other_user}","gists_url":"https://api.github.com/users/Sage-Bionetworks/gists{/gist_id}","starred_url":"https://api.github.com/users/Sage-Bionetworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sage-Bionetworks/subscriptions","organizations_url":"https://api.github.com/users/Sage-Bionetworks/orgs","repos_url":"https://api.github.com/users/Sage-Bionetworks/repos","events_url":"https://api.github.com/users/Sage-Bionetworks/events{/privacy}","received_events_url":"https://api.github.com/users/Sage-Bionetworks/received_events","type":"Organization","site_admin":false},"repo":{"id":18604783,"name":"BridgePF","full_name":"Sage-Bionetworks/BridgePF","owner":{"login":"Sage-Bionetworks","id":1250897,"avatar_url":"https://avatars.githubusercontent.com/u/1250897?v=3","gravatar_id":"","url":"https://api.github.com/users/Sage-Bionetworks","html_url":"https://github.com/Sage-Bionetworks","followers_url":"https://api.github.com/users/Sage-Bionetworks/followers","following_url":"https://api.github.com/users/Sage-Bionetworks/following{/other_user}","gists_url":"https://api.github.com/users/Sage-Bionetworks/gists{/gist_id}","starred_url":"https://api.github.com/users/Sage-Bionetworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sage-Bionetworks/subscriptions","organizations_url":"https://api.github.com/users/Sage-Bionetworks/orgs","repos_url":"https://api.github.com/users/Sage-Bionetworks/repos","events_url":"https://api.github.com/users/Sage-Bionetworks/events{/privacy}","received_events_url":"https://api.github.com/users/Sage-Bionetworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sage-Bionetworks/BridgePF","description":"Server software for Bridge-based mobile applications","fork":false,"url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF","forks_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/forks","keys_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/teams","hooks_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/hooks","issue_events_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues/events{/number}","events_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/events","assignees_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/assignees{/user}","branches_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/branches{/branch}","tags_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/tags","blobs_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/statuses/{sha}","languages_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/languages","stargazers_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/stargazers","contributors_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/contributors","subscribers_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/subscribers","subscription_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/subscription","commits_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/contents/{+path}","compare_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/merges","archive_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/downloads","issues_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues{/number}","pulls_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls{/number}","milestones_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/milestones{/number}","notifications_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/labels{/name}","releases_url":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/releases{/id}","created_at":"2014-04-09T16:38:46Z","updated_at":"2015-08-30T22:35:59Z","pushed_at":"2015-12-03T01:11:30Z","git_url":"git://github.com/Sage-Bionetworks/BridgePF.git","ssh_url":"git@github.com:Sage-Bionetworks/BridgePF.git","clone_url":"https://github.com/Sage-Bionetworks/BridgePF.git","svn_url":"https://github.com/Sage-Bionetworks/BridgePF","homepage":"","size":73046,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":4,"forks":18,"open_issues":4,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937"},"html":{"href":"https://github.com/Sage-Bionetworks/BridgePF/pull/937"},"issue":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues/937"},"comments":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/issues/937/comments"},"review_comments":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937/comments"},"review_comment":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/pulls/937/commits"},"statuses":{"href":"https://api.github.com/repos/Sage-Bionetworks/BridgePF/statuses/7a717dc1b203769d6dac9b625dd12782077a6cc8"}}}}