{"action":"created","comment":{"url":"https://api.github.com/repos/vqtran/EchoQuery/pulls/comments/47438327","id":47438327,"diff_hunk":"@@ -0,0 +1,84 @@\n+package echoquery.intents;\n+\n+import java.io.IOException;\n+import java.sql.Connection;\n+\n+import org.apache.commons.lang3.ObjectUtils;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import com.amazon.speech.slu.Intent;\n+import com.amazon.speech.speechlet.Session;\n+import com.amazon.speech.speechlet.SpeechletResponse;\n+\n+import echoquery.sql.Querier;\n+import echoquery.sql.QueryRequest;\n+import echoquery.sql.QueryResult;\n+import echoquery.sql.model.ColumnType;\n+import echoquery.utils.Response;\n+import echoquery.utils.Serializer;\n+import echoquery.utils.SessionUtil;\n+import echoquery.utils.SlotUtil;\n+\n+public class NarrowHandler implements IntentHandler {\n+\n+  private static final Logger log =\n+      LoggerFactory.getLogger(NarrowHandler.class);\n+  private final Querier querier;\n+\n+  public NarrowHandler(Connection conn) {\n+    this.querier = new Querier(conn);\n+  }\n+\n+  @Override\n+  public SpeechletResponse respond(Intent intent, Session session) {\n+    try {\n+      QueryRequest request = \n+          updateRequest(intent, (QueryRequest) Serializer.deserialize(\n+              (String) session.getAttribute(SessionUtil.REQUEST_ATTRIBUTE)));\n+      session.setAttribute(\n+          SessionUtil.REQUEST_ATTRIBUTE, Serializer.serialize(request));\n+\n+      // Execute the request and handle results.\n+      QueryResult result = querier.execute(request);\n+      if (result.getStatus() == QueryResult.Status.REPAIR_REQUEST) {\n+        return Response.ask(result.getMessage(), result.getMessage());\n+      } else {\n+        return Response.say(result.getMessage());\n+      }\n+    } catch (ClassNotFoundException | IOException e) {\n+      e.printStackTrace();\n+      return Response.unexpectedError();\n+    }\n+  }\n+    \n+  /**\n+   * Exposed for testing purposes - SpeechletResponse is impossible to inspect.\n+   */\n+  public String getResponseInEnglish(Intent intent, Session session) {\n+    QueryRequest previousRequest;\n+    try {\n+      previousRequest = (QueryRequest) Serializer.deserialize(\n+                (String) session.getAttribute(SessionUtil.REQUEST_ATTRIBUTE));\n+      return querier.execute(updateRequest(intent, previousRequest)).getMessage();\n+    } catch (ClassNotFoundException | IOException e) {\n+      e.printStackTrace();\n+      return \"There was an error generating the response in English\";\n+    }\n+  }\n+  \n+  QueryRequest updateRequest(Intent intent, QueryRequest previousRequest) {","path":"src/main/java/echoquery/intents/NarrowHandler.java","position":70,"original_position":70,"commit_id":"a3b759d013152a46a903ebc8282c7ae6460b6dc3","original_commit_id":"a3b759d013152a46a903ebc8282c7ae6460b6dc3","user":{"login":"vqtran","id":3363601,"avatar_url":"https://avatars.githubusercontent.com/u/3363601?v=3","gravatar_id":"","url":"https://api.github.com/users/vqtran","html_url":"https://github.com/vqtran","followers_url":"https://api.github.com/users/vqtran/followers","following_url":"https://api.github.com/users/vqtran/following{/other_user}","gists_url":"https://api.github.com/users/vqtran/gists{/gist_id}","starred_url":"https://api.github.com/users/vqtran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqtran/subscriptions","organizations_url":"https://api.github.com/users/vqtran/orgs","repos_url":"https://api.github.com/users/vqtran/repos","events_url":"https://api.github.com/users/vqtran/events{/privacy}","received_events_url":"https://api.github.com/users/vqtran/received_events","type":"User","site_admin":false},"body":"private scope","created_at":"2015-12-12T23:40:03Z","updated_at":"2015-12-12T23:40:03Z","html_url":"https://github.com/vqtran/EchoQuery/pull/28#discussion_r47438327","pull_request_url":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/vqtran/EchoQuery/pulls/comments/47438327"},"html":{"href":"https://github.com/vqtran/EchoQuery/pull/28#discussion_r47438327"},"pull_request":{"href":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28","id":53487913,"html_url":"https://github.com/vqtran/EchoQuery/pull/28","diff_url":"https://github.com/vqtran/EchoQuery/pull/28.diff","patch_url":"https://github.com/vqtran/EchoQuery/pull/28.patch","issue_url":"https://api.github.com/repos/vqtran/EchoQuery/issues/28","number":28,"state":"open","locked":false,"title":"Additional detail","user":{"login":"GabeLoins","id":2455694,"avatar_url":"https://avatars.githubusercontent.com/u/2455694?v=3","gravatar_id":"","url":"https://api.github.com/users/GabeLoins","html_url":"https://github.com/GabeLoins","followers_url":"https://api.github.com/users/GabeLoins/followers","following_url":"https://api.github.com/users/GabeLoins/following{/other_user}","gists_url":"https://api.github.com/users/GabeLoins/gists{/gist_id}","starred_url":"https://api.github.com/users/GabeLoins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GabeLoins/subscriptions","organizations_url":"https://api.github.com/users/GabeLoins/orgs","repos_url":"https://api.github.com/users/GabeLoins/repos","events_url":"https://api.github.com/users/GabeLoins/events{/privacy}","received_events_url":"https://api.github.com/users/GabeLoins/received_events","type":"User","site_admin":false},"body":"don't flame me @vqtran ","created_at":"2015-12-12T23:01:37Z","updated_at":"2015-12-12T23:40:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f0c301944dba40bab2c7985ab7adf3002e16cd4a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28/commits","review_comments_url":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28/comments","review_comment_url":"https://api.github.com/repos/vqtran/EchoQuery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vqtran/EchoQuery/issues/28/comments","statuses_url":"https://api.github.com/repos/vqtran/EchoQuery/statuses/a3b759d013152a46a903ebc8282c7ae6460b6dc3","head":{"label":"vqtran:additional_detail","ref":"additional_detail","sha":"a3b759d013152a46a903ebc8282c7ae6460b6dc3","user":{"login":"vqtran","id":3363601,"avatar_url":"https://avatars.githubusercontent.com/u/3363601?v=3","gravatar_id":"","url":"https://api.github.com/users/vqtran","html_url":"https://github.com/vqtran","followers_url":"https://api.github.com/users/vqtran/followers","following_url":"https://api.github.com/users/vqtran/following{/other_user}","gists_url":"https://api.github.com/users/vqtran/gists{/gist_id}","starred_url":"https://api.github.com/users/vqtran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqtran/subscriptions","organizations_url":"https://api.github.com/users/vqtran/orgs","repos_url":"https://api.github.com/users/vqtran/repos","events_url":"https://api.github.com/users/vqtran/events{/privacy}","received_events_url":"https://api.github.com/users/vqtran/received_events","type":"User","site_admin":false},"repo":{"id":44494789,"name":"EchoQuery","full_name":"vqtran/EchoQuery","owner":{"login":"vqtran","id":3363601,"avatar_url":"https://avatars.githubusercontent.com/u/3363601?v=3","gravatar_id":"","url":"https://api.github.com/users/vqtran","html_url":"https://github.com/vqtran","followers_url":"https://api.github.com/users/vqtran/followers","following_url":"https://api.github.com/users/vqtran/following{/other_user}","gists_url":"https://api.github.com/users/vqtran/gists{/gist_id}","starred_url":"https://api.github.com/users/vqtran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqtran/subscriptions","organizations_url":"https://api.github.com/users/vqtran/orgs","repos_url":"https://api.github.com/users/vqtran/repos","events_url":"https://api.github.com/users/vqtran/events{/privacy}","received_events_url":"https://api.github.com/users/vqtran/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vqtran/EchoQuery","description":"A spoken dialogue interface for relational databases.","fork":false,"url":"https://api.github.com/repos/vqtran/EchoQuery","forks_url":"https://api.github.com/repos/vqtran/EchoQuery/forks","keys_url":"https://api.github.com/repos/vqtran/EchoQuery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vqtran/EchoQuery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vqtran/EchoQuery/teams","hooks_url":"https://api.github.com/repos/vqtran/EchoQuery/hooks","issue_events_url":"https://api.github.com/repos/vqtran/EchoQuery/issues/events{/number}","events_url":"https://api.github.com/repos/vqtran/EchoQuery/events","assignees_url":"https://api.github.com/repos/vqtran/EchoQuery/assignees{/user}","branches_url":"https://api.github.com/repos/vqtran/EchoQuery/branches{/branch}","tags_url":"https://api.github.com/repos/vqtran/EchoQuery/tags","blobs_url":"https://api.github.com/repos/vqtran/EchoQuery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vqtran/EchoQuery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vqtran/EchoQuery/git/refs{/sha}","trees_url":"https://api.github.com/repos/vqtran/EchoQuery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vqtran/EchoQuery/statuses/{sha}","languages_url":"https://api.github.com/repos/vqtran/EchoQuery/languages","stargazers_url":"https://api.github.com/repos/vqtran/EchoQuery/stargazers","contributors_url":"https://api.github.com/repos/vqtran/EchoQuery/contributors","subscribers_url":"https://api.github.com/repos/vqtran/EchoQuery/subscribers","subscription_url":"https://api.github.com/repos/vqtran/EchoQuery/subscription","commits_url":"https://api.github.com/repos/vqtran/EchoQuery/commits{/sha}","git_commits_url":"https://api.github.com/repos/vqtran/EchoQuery/git/commits{/sha}","comments_url":"https://api.github.com/repos/vqtran/EchoQuery/comments{/number}","issue_comment_url":"https://api.github.com/repos/vqtran/EchoQuery/issues/comments{/number}","contents_url":"https://api.github.com/repos/vqtran/EchoQuery/contents/{+path}","compare_url":"https://api.github.com/repos/vqtran/EchoQuery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vqtran/EchoQuery/merges","archive_url":"https://api.github.com/repos/vqtran/EchoQuery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vqtran/EchoQuery/downloads","issues_url":"https://api.github.com/repos/vqtran/EchoQuery/issues{/number}","pulls_url":"https://api.github.com/repos/vqtran/EchoQuery/pulls{/number}","milestones_url":"https://api.github.com/repos/vqtran/EchoQuery/milestones{/number}","notifications_url":"https://api.github.com/repos/vqtran/EchoQuery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vqtran/EchoQuery/labels{/name}","releases_url":"https://api.github.com/repos/vqtran/EchoQuery/releases{/id}","created_at":"2015-10-18T20:17:15Z","updated_at":"2015-10-21T23:43:23Z","pushed_at":"2015-12-12T23:01:37Z","git_url":"git://github.com/vqtran/EchoQuery.git","ssh_url":"git@github.com:vqtran/EchoQuery.git","clone_url":"https://github.com/vqtran/EchoQuery.git","svn_url":"https://github.com/vqtran/EchoQuery","homepage":"","size":454,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"vqtran:master","ref":"master","sha":"81a5db2ebd575ea6b542c24ad73ed1a2d0765b17","user":{"login":"vqtran","id":3363601,"avatar_url":"https://avatars.githubusercontent.com/u/3363601?v=3","gravatar_id":"","url":"https://api.github.com/users/vqtran","html_url":"https://github.com/vqtran","followers_url":"https://api.github.com/users/vqtran/followers","following_url":"https://api.github.com/users/vqtran/following{/other_user}","gists_url":"https://api.github.com/users/vqtran/gists{/gist_id}","starred_url":"https://api.github.com/users/vqtran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqtran/subscriptions","organizations_url":"https://api.github.com/users/vqtran/orgs","repos_url":"https://api.github.com/users/vqtran/repos","events_url":"https://api.github.com/users/vqtran/events{/privacy}","received_events_url":"https://api.github.com/users/vqtran/received_events","type":"User","site_admin":false},"repo":{"id":44494789,"name":"EchoQuery","full_name":"vqtran/EchoQuery","owner":{"login":"vqtran","id":3363601,"avatar_url":"https://avatars.githubusercontent.com/u/3363601?v=3","gravatar_id":"","url":"https://api.github.com/users/vqtran","html_url":"https://github.com/vqtran","followers_url":"https://api.github.com/users/vqtran/followers","following_url":"https://api.github.com/users/vqtran/following{/other_user}","gists_url":"https://api.github.com/users/vqtran/gists{/gist_id}","starred_url":"https://api.github.com/users/vqtran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vqtran/subscriptions","organizations_url":"https://api.github.com/users/vqtran/orgs","repos_url":"https://api.github.com/users/vqtran/repos","events_url":"https://api.github.com/users/vqtran/events{/privacy}","received_events_url":"https://api.github.com/users/vqtran/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vqtran/EchoQuery","description":"A spoken dialogue interface for relational databases.","fork":false,"url":"https://api.github.com/repos/vqtran/EchoQuery","forks_url":"https://api.github.com/repos/vqtran/EchoQuery/forks","keys_url":"https://api.github.com/repos/vqtran/EchoQuery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vqtran/EchoQuery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vqtran/EchoQuery/teams","hooks_url":"https://api.github.com/repos/vqtran/EchoQuery/hooks","issue_events_url":"https://api.github.com/repos/vqtran/EchoQuery/issues/events{/number}","events_url":"https://api.github.com/repos/vqtran/EchoQuery/events","assignees_url":"https://api.github.com/repos/vqtran/EchoQuery/assignees{/user}","branches_url":"https://api.github.com/repos/vqtran/EchoQuery/branches{/branch}","tags_url":"https://api.github.com/repos/vqtran/EchoQuery/tags","blobs_url":"https://api.github.com/repos/vqtran/EchoQuery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vqtran/EchoQuery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vqtran/EchoQuery/git/refs{/sha}","trees_url":"https://api.github.com/repos/vqtran/EchoQuery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vqtran/EchoQuery/statuses/{sha}","languages_url":"https://api.github.com/repos/vqtran/EchoQuery/languages","stargazers_url":"https://api.github.com/repos/vqtran/EchoQuery/stargazers","contributors_url":"https://api.github.com/repos/vqtran/EchoQuery/contributors","subscribers_url":"https://api.github.com/repos/vqtran/EchoQuery/subscribers","subscription_url":"https://api.github.com/repos/vqtran/EchoQuery/subscription","commits_url":"https://api.github.com/repos/vqtran/EchoQuery/commits{/sha}","git_commits_url":"https://api.github.com/repos/vqtran/EchoQuery/git/commits{/sha}","comments_url":"https://api.github.com/repos/vqtran/EchoQuery/comments{/number}","issue_comment_url":"https://api.github.com/repos/vqtran/EchoQuery/issues/comments{/number}","contents_url":"https://api.github.com/repos/vqtran/EchoQuery/contents/{+path}","compare_url":"https://api.github.com/repos/vqtran/EchoQuery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vqtran/EchoQuery/merges","archive_url":"https://api.github.com/repos/vqtran/EchoQuery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vqtran/EchoQuery/downloads","issues_url":"https://api.github.com/repos/vqtran/EchoQuery/issues{/number}","pulls_url":"https://api.github.com/repos/vqtran/EchoQuery/pulls{/number}","milestones_url":"https://api.github.com/repos/vqtran/EchoQuery/milestones{/number}","notifications_url":"https://api.github.com/repos/vqtran/EchoQuery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vqtran/EchoQuery/labels{/name}","releases_url":"https://api.github.com/repos/vqtran/EchoQuery/releases{/id}","created_at":"2015-10-18T20:17:15Z","updated_at":"2015-10-21T23:43:23Z","pushed_at":"2015-12-12T23:01:37Z","git_url":"git://github.com/vqtran/EchoQuery.git","ssh_url":"git@github.com:vqtran/EchoQuery.git","clone_url":"https://github.com/vqtran/EchoQuery.git","svn_url":"https://github.com/vqtran/EchoQuery","homepage":"","size":454,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28"},"html":{"href":"https://github.com/vqtran/EchoQuery/pull/28"},"issue":{"href":"https://api.github.com/repos/vqtran/EchoQuery/issues/28"},"comments":{"href":"https://api.github.com/repos/vqtran/EchoQuery/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/vqtran/EchoQuery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vqtran/EchoQuery/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/vqtran/EchoQuery/statuses/a3b759d013152a46a903ebc8282c7ae6460b6dc3"}}}}