{"action":"created","comment":{"url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/comments/93398741","pull_request_review_id":13923871,"id":93398741,"diff_hunk":"@@ -0,0 +1,84 @@\n+/*\n+ * Copyright 2014 Click Travel Ltd\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ *\n+ */\n+package com.clicktravel.infrastructure.persistence.aws.dynamodb;\n+\n+import java.util.Set;\n+\n+import com.amazonaws.services.dynamodbv2.document.RangeKeyCondition;\n+import com.amazonaws.services.dynamodbv2.document.spec.QuerySpec;\n+import com.clicktravel.cheddar.infrastructure.persistence.database.Item;\n+import com.clicktravel.cheddar.infrastructure.persistence.database.query.AttributeQuery;\n+import com.clicktravel.cheddar.infrastructure.persistence.database.query.CompoundAttributeQuery;\n+import com.clicktravel.cheddar.infrastructure.persistence.database.query.Operators;\n+import com.clicktravel.cheddar.infrastructure.persistence.exception.PersistenceResourceFailureException;\n+\n+public class QuerySpecBuilder {\n+\n+    public static <T extends Item> QuerySpec build(final AttributeQuery attributeQuery, final Class<T> itemClass) {\n+        if (CompoundAttributeQuery.class.isAssignableFrom(attributeQuery.getClass())) {\n+            final CompoundAttributeQuery compoundAttributeQuery = (CompoundAttributeQuery) attributeQuery;\n+            return buildWithHashAndRangeKey(compoundAttributeQuery, itemClass);\n+        }\n+\n+        return buildWithHashKey(attributeQuery);\n+    }\n+\n+    private static QuerySpec buildWithHashKey(final AttributeQuery attributeQuery) {\n+        return new QuerySpec().withHashKey(attributeQuery.getAttributeName(),\n+                attributeQuery.getCondition().getValues().iterator().next());\n+    }\n+\n+    private static <T extends Item> QuerySpec buildWithHashAndRangeKey(\n+            final CompoundAttributeQuery compoundAttributeQuery, final Class<T> itemClass) {\n+        final Set<String> supportingConditionValues = compoundAttributeQuery.getSupportingCondition().getValues();\n+        validateSupportingConditionValues(supportingConditionValues);\n+\n+        final QuerySpec querySpec = buildWithHashKey(compoundAttributeQuery);\n+        addRangeKeyConditionToQuerySpec(querySpec, compoundAttributeQuery, itemClass);\n+\n+        return querySpec;\n+    }\n+\n+    private static <T extends Item> void addRangeKeyConditionToQuerySpec(final QuerySpec querySpec,\n+            final CompoundAttributeQuery compoundAttributeQuery, final Class<T> itemClass) {\n+        final String supportingConditionValue = compoundAttributeQuery.getSupportingCondition().getValues().iterator()","path":"cheddar/cheddar-integration-aws/src/main/java/com/clicktravel/infrastructure/persistence/aws/dynamodb/QuerySpecBuilder.java","position":58,"original_position":58,"commit_id":"c18a83fb176b891b5a19cc611ee30083bca75e40","original_commit_id":"c18a83fb176b891b5a19cc611ee30083bca75e40","user":{"login":"clicktravel-basharat","id":4687263,"avatar_url":"https://avatars.githubusercontent.com/u/4687263?v=3","gravatar_id":"","url":"https://api.github.com/users/clicktravel-basharat","html_url":"https://github.com/clicktravel-basharat","followers_url":"https://api.github.com/users/clicktravel-basharat/followers","following_url":"https://api.github.com/users/clicktravel-basharat/following{/other_user}","gists_url":"https://api.github.com/users/clicktravel-basharat/gists{/gist_id}","starred_url":"https://api.github.com/users/clicktravel-basharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clicktravel-basharat/subscriptions","organizations_url":"https://api.github.com/users/clicktravel-basharat/orgs","repos_url":"https://api.github.com/users/clicktravel-basharat/repos","events_url":"https://api.github.com/users/clicktravel-basharat/events{/privacy}","received_events_url":"https://api.github.com/users/clicktravel-basharat/received_events","type":"User","site_admin":false},"body":"supportingConditionValue -> supportingConditionStringValue","created_at":"2016-12-21T09:04:30Z","updated_at":"2016-12-21T09:05:00Z","html_url":"https://github.com/travel-cloud/Cheddar/pull/193#discussion_r93398741","pull_request_url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193","_links":{"self":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/comments/93398741"},"html":{"href":"https://github.com/travel-cloud/Cheddar/pull/193#discussion_r93398741"},"pull_request":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193"}}},"pull_request":{"url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193","id":98738864,"html_url":"https://github.com/travel-cloud/Cheddar/pull/193","diff_url":"https://github.com/travel-cloud/Cheddar/pull/193.diff","patch_url":"https://github.com/travel-cloud/Cheddar/pull/193.patch","issue_url":"https://api.github.com/repos/travel-cloud/Cheddar/issues/193","number":193,"state":"open","locked":false,"title":"[IAM-1273] - Add support for querying DynamoDB GSIs which consist of a partition key and sort key","user":{"login":"clicktravel-chrishern","id":19385072,"avatar_url":"https://avatars.githubusercontent.com/u/19385072?v=3","gravatar_id":"","url":"https://api.github.com/users/clicktravel-chrishern","html_url":"https://github.com/clicktravel-chrishern","followers_url":"https://api.github.com/users/clicktravel-chrishern/followers","following_url":"https://api.github.com/users/clicktravel-chrishern/following{/other_user}","gists_url":"https://api.github.com/users/clicktravel-chrishern/gists{/gist_id}","starred_url":"https://api.github.com/users/clicktravel-chrishern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clicktravel-chrishern/subscriptions","organizations_url":"https://api.github.com/users/clicktravel-chrishern/orgs","repos_url":"https://api.github.com/users/clicktravel-chrishern/repos","events_url":"https://api.github.com/users/clicktravel-chrishern/events{/privacy}","received_events_url":"https://api.github.com/users/clicktravel-chrishern/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-20T12:22:43Z","updated_at":"2016-12-21T09:08:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9efc2507f152494436e53c4d962a47dc2c265bc4","assignee":{"login":"clicktravel-basharat","id":4687263,"avatar_url":"https://avatars.githubusercontent.com/u/4687263?v=3","gravatar_id":"","url":"https://api.github.com/users/clicktravel-basharat","html_url":"https://github.com/clicktravel-basharat","followers_url":"https://api.github.com/users/clicktravel-basharat/followers","following_url":"https://api.github.com/users/clicktravel-basharat/following{/other_user}","gists_url":"https://api.github.com/users/clicktravel-basharat/gists{/gist_id}","starred_url":"https://api.github.com/users/clicktravel-basharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clicktravel-basharat/subscriptions","organizations_url":"https://api.github.com/users/clicktravel-basharat/orgs","repos_url":"https://api.github.com/users/clicktravel-basharat/repos","events_url":"https://api.github.com/users/clicktravel-basharat/events{/privacy}","received_events_url":"https://api.github.com/users/clicktravel-basharat/received_events","type":"User","site_admin":false},"assignees":[{"login":"clicktravel-basharat","id":4687263,"avatar_url":"https://avatars.githubusercontent.com/u/4687263?v=3","gravatar_id":"","url":"https://api.github.com/users/clicktravel-basharat","html_url":"https://github.com/clicktravel-basharat","followers_url":"https://api.github.com/users/clicktravel-basharat/followers","following_url":"https://api.github.com/users/clicktravel-basharat/following{/other_user}","gists_url":"https://api.github.com/users/clicktravel-basharat/gists{/gist_id}","starred_url":"https://api.github.com/users/clicktravel-basharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clicktravel-basharat/subscriptions","organizations_url":"https://api.github.com/users/clicktravel-basharat/orgs","repos_url":"https://api.github.com/users/clicktravel-basharat/repos","events_url":"https://api.github.com/users/clicktravel-basharat/events{/privacy}","received_events_url":"https://api.github.com/users/clicktravel-basharat/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193/commits","review_comments_url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193/comments","review_comment_url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/travel-cloud/Cheddar/issues/193/comments","statuses_url":"https://api.github.com/repos/travel-cloud/Cheddar/statuses/c18a83fb176b891b5a19cc611ee30083bca75e40","head":{"label":"clicktravel-chrishern:master","ref":"master","sha":"c18a83fb176b891b5a19cc611ee30083bca75e40","user":{"login":"clicktravel-chrishern","id":19385072,"avatar_url":"https://avatars.githubusercontent.com/u/19385072?v=3","gravatar_id":"","url":"https://api.github.com/users/clicktravel-chrishern","html_url":"https://github.com/clicktravel-chrishern","followers_url":"https://api.github.com/users/clicktravel-chrishern/followers","following_url":"https://api.github.com/users/clicktravel-chrishern/following{/other_user}","gists_url":"https://api.github.com/users/clicktravel-chrishern/gists{/gist_id}","starred_url":"https://api.github.com/users/clicktravel-chrishern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clicktravel-chrishern/subscriptions","organizations_url":"https://api.github.com/users/clicktravel-chrishern/orgs","repos_url":"https://api.github.com/users/clicktravel-chrishern/repos","events_url":"https://api.github.com/users/clicktravel-chrishern/events{/privacy}","received_events_url":"https://api.github.com/users/clicktravel-chrishern/received_events","type":"User","site_admin":false},"repo":{"id":58928159,"name":"Cheddar","full_name":"clicktravel-chrishern/Cheddar","owner":{"login":"clicktravel-chrishern","id":19385072,"avatar_url":"https://avatars.githubusercontent.com/u/19385072?v=3","gravatar_id":"","url":"https://api.github.com/users/clicktravel-chrishern","html_url":"https://github.com/clicktravel-chrishern","followers_url":"https://api.github.com/users/clicktravel-chrishern/followers","following_url":"https://api.github.com/users/clicktravel-chrishern/following{/other_user}","gists_url":"https://api.github.com/users/clicktravel-chrishern/gists{/gist_id}","starred_url":"https://api.github.com/users/clicktravel-chrishern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clicktravel-chrishern/subscriptions","organizations_url":"https://api.github.com/users/clicktravel-chrishern/orgs","repos_url":"https://api.github.com/users/clicktravel-chrishern/repos","events_url":"https://api.github.com/users/clicktravel-chrishern/events{/privacy}","received_events_url":"https://api.github.com/users/clicktravel-chrishern/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/clicktravel-chrishern/Cheddar","description":"Click's Hexagonal Domain Driven Architecture","fork":true,"url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar","forks_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/forks","keys_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/teams","hooks_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/hooks","issue_events_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/issues/events{/number}","events_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/events","assignees_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/assignees{/user}","branches_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/branches{/branch}","tags_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/tags","blobs_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/git/refs{/sha}","trees_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/statuses/{sha}","languages_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/languages","stargazers_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/stargazers","contributors_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/contributors","subscribers_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/subscribers","subscription_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/subscription","commits_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/commits{/sha}","git_commits_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/git/commits{/sha}","comments_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/comments{/number}","issue_comment_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/issues/comments{/number}","contents_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/contents/{+path}","compare_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/merges","archive_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/downloads","issues_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/issues{/number}","pulls_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/pulls{/number}","milestones_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/milestones{/number}","notifications_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/labels{/name}","releases_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/releases{/id}","deployments_url":"https://api.github.com/repos/clicktravel-chrishern/Cheddar/deployments","created_at":"2016-05-16T11:42:19Z","updated_at":"2016-05-16T11:42:21Z","pushed_at":"2016-12-21T08:34:41Z","git_url":"git://github.com/clicktravel-chrishern/Cheddar.git","ssh_url":"git@github.com:clicktravel-chrishern/Cheddar.git","clone_url":"https://github.com/clicktravel-chrishern/Cheddar.git","svn_url":"https://github.com/clicktravel-chrishern/Cheddar","homepage":null,"size":1509,"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":"master"}},"base":{"label":"travel-cloud:master","ref":"master","sha":"355d9811b6b659a6530cfcf40d20fc252cb1209d","user":{"login":"travel-cloud","id":885969,"avatar_url":"https://avatars.githubusercontent.com/u/885969?v=3","gravatar_id":"","url":"https://api.github.com/users/travel-cloud","html_url":"https://github.com/travel-cloud","followers_url":"https://api.github.com/users/travel-cloud/followers","following_url":"https://api.github.com/users/travel-cloud/following{/other_user}","gists_url":"https://api.github.com/users/travel-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/travel-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travel-cloud/subscriptions","organizations_url":"https://api.github.com/users/travel-cloud/orgs","repos_url":"https://api.github.com/users/travel-cloud/repos","events_url":"https://api.github.com/users/travel-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/travel-cloud/received_events","type":"Organization","site_admin":false},"repo":{"id":22964867,"name":"Cheddar","full_name":"travel-cloud/Cheddar","owner":{"login":"travel-cloud","id":885969,"avatar_url":"https://avatars.githubusercontent.com/u/885969?v=3","gravatar_id":"","url":"https://api.github.com/users/travel-cloud","html_url":"https://github.com/travel-cloud","followers_url":"https://api.github.com/users/travel-cloud/followers","following_url":"https://api.github.com/users/travel-cloud/following{/other_user}","gists_url":"https://api.github.com/users/travel-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/travel-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travel-cloud/subscriptions","organizations_url":"https://api.github.com/users/travel-cloud/orgs","repos_url":"https://api.github.com/users/travel-cloud/repos","events_url":"https://api.github.com/users/travel-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/travel-cloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/travel-cloud/Cheddar","description":"Click's Hexagonal Domain Driven Architecture","fork":false,"url":"https://api.github.com/repos/travel-cloud/Cheddar","forks_url":"https://api.github.com/repos/travel-cloud/Cheddar/forks","keys_url":"https://api.github.com/repos/travel-cloud/Cheddar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/travel-cloud/Cheddar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/travel-cloud/Cheddar/teams","hooks_url":"https://api.github.com/repos/travel-cloud/Cheddar/hooks","issue_events_url":"https://api.github.com/repos/travel-cloud/Cheddar/issues/events{/number}","events_url":"https://api.github.com/repos/travel-cloud/Cheddar/events","assignees_url":"https://api.github.com/repos/travel-cloud/Cheddar/assignees{/user}","branches_url":"https://api.github.com/repos/travel-cloud/Cheddar/branches{/branch}","tags_url":"https://api.github.com/repos/travel-cloud/Cheddar/tags","blobs_url":"https://api.github.com/repos/travel-cloud/Cheddar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/travel-cloud/Cheddar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/travel-cloud/Cheddar/git/refs{/sha}","trees_url":"https://api.github.com/repos/travel-cloud/Cheddar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/travel-cloud/Cheddar/statuses/{sha}","languages_url":"https://api.github.com/repos/travel-cloud/Cheddar/languages","stargazers_url":"https://api.github.com/repos/travel-cloud/Cheddar/stargazers","contributors_url":"https://api.github.com/repos/travel-cloud/Cheddar/contributors","subscribers_url":"https://api.github.com/repos/travel-cloud/Cheddar/subscribers","subscription_url":"https://api.github.com/repos/travel-cloud/Cheddar/subscription","commits_url":"https://api.github.com/repos/travel-cloud/Cheddar/commits{/sha}","git_commits_url":"https://api.github.com/repos/travel-cloud/Cheddar/git/commits{/sha}","comments_url":"https://api.github.com/repos/travel-cloud/Cheddar/comments{/number}","issue_comment_url":"https://api.github.com/repos/travel-cloud/Cheddar/issues/comments{/number}","contents_url":"https://api.github.com/repos/travel-cloud/Cheddar/contents/{+path}","compare_url":"https://api.github.com/repos/travel-cloud/Cheddar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/travel-cloud/Cheddar/merges","archive_url":"https://api.github.com/repos/travel-cloud/Cheddar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/travel-cloud/Cheddar/downloads","issues_url":"https://api.github.com/repos/travel-cloud/Cheddar/issues{/number}","pulls_url":"https://api.github.com/repos/travel-cloud/Cheddar/pulls{/number}","milestones_url":"https://api.github.com/repos/travel-cloud/Cheddar/milestones{/number}","notifications_url":"https://api.github.com/repos/travel-cloud/Cheddar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/travel-cloud/Cheddar/labels{/name}","releases_url":"https://api.github.com/repos/travel-cloud/Cheddar/releases{/id}","deployments_url":"https://api.github.com/repos/travel-cloud/Cheddar/deployments","created_at":"2014-08-14T18:50:56Z","updated_at":"2016-12-19T22:08:26Z","pushed_at":"2016-12-21T08:34:44Z","git_url":"git://github.com/travel-cloud/Cheddar.git","ssh_url":"git@github.com:travel-cloud/Cheddar.git","clone_url":"https://github.com/travel-cloud/Cheddar.git","svn_url":"https://github.com/travel-cloud/Cheddar","homepage":null,"size":1551,"stargazers_count":50,"watchers_count":50,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":2,"forks":29,"open_issues":2,"watchers":50,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193"},"html":{"href":"https://github.com/travel-cloud/Cheddar/pull/193"},"issue":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/issues/193"},"comments":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/issues/193/comments"},"review_comments":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193/comments"},"review_comment":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/pulls/193/commits"},"statuses":{"href":"https://api.github.com/repos/travel-cloud/Cheddar/statuses/c18a83fb176b891b5a19cc611ee30083bca75e40"}}}}
{"actor":{"display_login":"clicktravel-basharat"}}