{"action":"created","comment":{"url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/comments/26832858","id":26832858,"diff_hunk":"@@ -0,0 +1,132 @@\n+/*\n+ * Copyright (C) 2015 47 Degrees, LLC http://47deg.com hello@47deg.com\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License. You may obtain\n+ * 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.fortysevendeg.translatebubble.modules.repository.impl\n+\n+import android.content.ContentValues\n+import android.database.Cursor\n+import com.fortysevendeg.macroid.extras.AppContextProvider\n+import com.fortysevendeg.translatebubble.modules.repository._\n+import com.fortysevendeg.translatebubble.provider.TranslationHistoryEntity._\n+import com.fortysevendeg.translatebubble.provider.{TranslateBubbleSqlHelper, TranslateBubbleContentProvider, TranslationHistoryEntity}\n+import com.fortysevendeg.translatebubble.service.Service\n+import com.fortysevendeg.translatebubble.utils.DBUtils\n+import com.fortysevendeg.translatebubble.utils.LanguageTypeTransformer._\n+\n+import scala.concurrent.ExecutionContext.Implicits.global\n+import scala.concurrent.{ExecutionContext, Future}\n+import scala.util.{Failure, Success, Try}\n+\n+trait RepositoryServicesComponentImpl extends RepositoryServicesComponent with DBUtils {\n+  self: AppContextProvider =>\n+\n+  lazy val repositoryServices = new RepositoryServicesImpl\n+\n+  class RepositoryServicesImpl\n+      extends RepositoryServices {\n+    override def addTranslationHistory: Service[AddTranslationHistoryRequest, AddTranslationHistoryResponse] =\n+      request => {\n+        tryToFuture {\n+          Try {\n+            val contentValues = new ContentValues()\n+            contentValues.put(originalText, request.data.originalText)\n+            contentValues.put(translatedText, request.data.translatedText)\n+            contentValues.put(fromLanguage, toMyMemory(request.data.from))\n+            contentValues.put(toLanguage, toMyMemory(request.data.to))\n+\n+            val uri = appContextProvider.get.getContentResolver.insert(\n+              TranslateBubbleContentProvider.contentUriTranslationHistory,\n+              contentValues)\n+\n+            AddTranslationHistoryResponse(\n+              success = true,\n+              message = \"The translation history item has been added successfully\",\n+              translationHistoryEntity = Some(TranslationHistoryEntity(\n+                id = Integer.parseInt(uri.getPathSegments.get(1)),\n+                data = request.data)))\n+\n+          } recover {\n+            case e: Exception =>\n+              AddTranslationHistoryResponse(\n+                success = false,\n+                message = \"Unexpected error when adding a translation history item\",","path":"src/main/scala/com/fortysevendeg/translatebubble/modules/repository/impl/RepositoryServicesComponentImpl.scala","position":65,"original_position":65,"commit_id":"1e1a0d57fc6543f24d0f3623a34c9538bf3d6627","original_commit_id":"1e1a0d57fc6543f24d0f3623a34c9538bf3d6627","user":{"login":"franciscodr","id":1200151,"avatar_url":"https://avatars.githubusercontent.com/u/1200151?v=3","gravatar_id":"","url":"https://api.github.com/users/franciscodr","html_url":"https://github.com/franciscodr","followers_url":"https://api.github.com/users/franciscodr/followers","following_url":"https://api.github.com/users/franciscodr/following{/other_user}","gists_url":"https://api.github.com/users/franciscodr/gists{/gist_id}","starred_url":"https://api.github.com/users/franciscodr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/franciscodr/subscriptions","organizations_url":"https://api.github.com/users/franciscodr/orgs","repos_url":"https://api.github.com/users/franciscodr/repos","events_url":"https://api.github.com/users/franciscodr/events{/privacy}","received_events_url":"https://api.github.com/users/franciscodr/received_events","type":"User","site_admin":false},"body":"Agree with you, I'll remove it","created_at":"2015-03-20T11:19:44Z","updated_at":"2015-03-20T11:19:44Z","html_url":"https://github.com/47deg/translate-bubble-android/pull/22#discussion_r26832858","pull_request_url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/comments/26832858"},"html":{"href":"https://github.com/47deg/translate-bubble-android/pull/22#discussion_r26832858"},"pull_request":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22","id":31596413,"html_url":"https://github.com/47deg/translate-bubble-android/pull/22","diff_url":"https://github.com/47deg/translate-bubble-android/pull/22.diff","patch_url":"https://github.com/47deg/translate-bubble-android/pull/22.patch","issue_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues/22","number":22,"state":"open","locked":false,"title":"paco-tb-8-translation-history","user":{"login":"franciscodr","id":1200151,"avatar_url":"https://avatars.githubusercontent.com/u/1200151?v=3","gravatar_id":"","url":"https://api.github.com/users/franciscodr","html_url":"https://github.com/franciscodr","followers_url":"https://api.github.com/users/franciscodr/followers","following_url":"https://api.github.com/users/franciscodr/following{/other_user}","gists_url":"https://api.github.com/users/franciscodr/gists{/gist_id}","starred_url":"https://api.github.com/users/franciscodr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/franciscodr/subscriptions","organizations_url":"https://api.github.com/users/franciscodr/orgs","repos_url":"https://api.github.com/users/franciscodr/repos","events_url":"https://api.github.com/users/franciscodr/events{/privacy}","received_events_url":"https://api.github.com/users/franciscodr/received_events","type":"User","site_admin":false},"body":"This PR adds:\r\n- Repository for saving translations\r\n- Fixes a issue related to an animation\r\n\r\n@javipacheco Could you review this code, please? Thanks!","created_at":"2015-03-20T08:45:38Z","updated_at":"2015-03-20T11:19:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0b131134066ca7efdf3024723bf40d3b2634e998","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22/commits","review_comments_url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22/comments","review_comment_url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues/22/comments","statuses_url":"https://api.github.com/repos/47deg/translate-bubble-android/statuses/1e1a0d57fc6543f24d0f3623a34c9538bf3d6627","head":{"label":"47deg:paco-tb-8-translation-history","ref":"paco-tb-8-translation-history","sha":"1e1a0d57fc6543f24d0f3623a34c9538bf3d6627","user":{"login":"47deg","id":479857,"avatar_url":"https://avatars.githubusercontent.com/u/479857?v=3","gravatar_id":"","url":"https://api.github.com/users/47deg","html_url":"https://github.com/47deg","followers_url":"https://api.github.com/users/47deg/followers","following_url":"https://api.github.com/users/47deg/following{/other_user}","gists_url":"https://api.github.com/users/47deg/gists{/gist_id}","starred_url":"https://api.github.com/users/47deg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/47deg/subscriptions","organizations_url":"https://api.github.com/users/47deg/orgs","repos_url":"https://api.github.com/users/47deg/repos","events_url":"https://api.github.com/users/47deg/events{/privacy}","received_events_url":"https://api.github.com/users/47deg/received_events","type":"Organization","site_admin":false},"repo":{"id":25027889,"name":"translate-bubble-android","full_name":"47deg/translate-bubble-android","owner":{"login":"47deg","id":479857,"avatar_url":"https://avatars.githubusercontent.com/u/479857?v=3","gravatar_id":"","url":"https://api.github.com/users/47deg","html_url":"https://github.com/47deg","followers_url":"https://api.github.com/users/47deg/followers","following_url":"https://api.github.com/users/47deg/following{/other_user}","gists_url":"https://api.github.com/users/47deg/gists{/gist_id}","starred_url":"https://api.github.com/users/47deg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/47deg/subscriptions","organizations_url":"https://api.github.com/users/47deg/orgs","repos_url":"https://api.github.com/users/47deg/repos","events_url":"https://api.github.com/users/47deg/events{/privacy}","received_events_url":"https://api.github.com/users/47deg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/47deg/translate-bubble-android","description":"Translations without interruptions","fork":false,"url":"https://api.github.com/repos/47deg/translate-bubble-android","forks_url":"https://api.github.com/repos/47deg/translate-bubble-android/forks","keys_url":"https://api.github.com/repos/47deg/translate-bubble-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/47deg/translate-bubble-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/47deg/translate-bubble-android/teams","hooks_url":"https://api.github.com/repos/47deg/translate-bubble-android/hooks","issue_events_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues/events{/number}","events_url":"https://api.github.com/repos/47deg/translate-bubble-android/events","assignees_url":"https://api.github.com/repos/47deg/translate-bubble-android/assignees{/user}","branches_url":"https://api.github.com/repos/47deg/translate-bubble-android/branches{/branch}","tags_url":"https://api.github.com/repos/47deg/translate-bubble-android/tags","blobs_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/47deg/translate-bubble-android/statuses/{sha}","languages_url":"https://api.github.com/repos/47deg/translate-bubble-android/languages","stargazers_url":"https://api.github.com/repos/47deg/translate-bubble-android/stargazers","contributors_url":"https://api.github.com/repos/47deg/translate-bubble-android/contributors","subscribers_url":"https://api.github.com/repos/47deg/translate-bubble-android/subscribers","subscription_url":"https://api.github.com/repos/47deg/translate-bubble-android/subscription","commits_url":"https://api.github.com/repos/47deg/translate-bubble-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/47deg/translate-bubble-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/47deg/translate-bubble-android/contents/{+path}","compare_url":"https://api.github.com/repos/47deg/translate-bubble-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/47deg/translate-bubble-android/merges","archive_url":"https://api.github.com/repos/47deg/translate-bubble-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/47deg/translate-bubble-android/downloads","issues_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues{/number}","pulls_url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls{/number}","milestones_url":"https://api.github.com/repos/47deg/translate-bubble-android/milestones{/number}","notifications_url":"https://api.github.com/repos/47deg/translate-bubble-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/47deg/translate-bubble-android/labels{/name}","releases_url":"https://api.github.com/repos/47deg/translate-bubble-android/releases{/id}","created_at":"2014-10-10T08:53:39Z","updated_at":"2015-03-20T05:53:04Z","pushed_at":"2015-03-20T08:45:38Z","git_url":"git://github.com/47deg/translate-bubble-android.git","ssh_url":"git@github.com:47deg/translate-bubble-android.git","clone_url":"https://github.com/47deg/translate-bubble-android.git","svn_url":"https://github.com/47deg/translate-bubble-android","homepage":"http://47deg.github.io/translate-bubble-android/","size":5502,"stargazers_count":154,"watchers_count":154,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":3,"forks":11,"open_issues":3,"watchers":154,"default_branch":"master"}},"base":{"label":"47deg:master","ref":"master","sha":"9679ad37d4360e6da98e5b4c18884f51e02377e1","user":{"login":"47deg","id":479857,"avatar_url":"https://avatars.githubusercontent.com/u/479857?v=3","gravatar_id":"","url":"https://api.github.com/users/47deg","html_url":"https://github.com/47deg","followers_url":"https://api.github.com/users/47deg/followers","following_url":"https://api.github.com/users/47deg/following{/other_user}","gists_url":"https://api.github.com/users/47deg/gists{/gist_id}","starred_url":"https://api.github.com/users/47deg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/47deg/subscriptions","organizations_url":"https://api.github.com/users/47deg/orgs","repos_url":"https://api.github.com/users/47deg/repos","events_url":"https://api.github.com/users/47deg/events{/privacy}","received_events_url":"https://api.github.com/users/47deg/received_events","type":"Organization","site_admin":false},"repo":{"id":25027889,"name":"translate-bubble-android","full_name":"47deg/translate-bubble-android","owner":{"login":"47deg","id":479857,"avatar_url":"https://avatars.githubusercontent.com/u/479857?v=3","gravatar_id":"","url":"https://api.github.com/users/47deg","html_url":"https://github.com/47deg","followers_url":"https://api.github.com/users/47deg/followers","following_url":"https://api.github.com/users/47deg/following{/other_user}","gists_url":"https://api.github.com/users/47deg/gists{/gist_id}","starred_url":"https://api.github.com/users/47deg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/47deg/subscriptions","organizations_url":"https://api.github.com/users/47deg/orgs","repos_url":"https://api.github.com/users/47deg/repos","events_url":"https://api.github.com/users/47deg/events{/privacy}","received_events_url":"https://api.github.com/users/47deg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/47deg/translate-bubble-android","description":"Translations without interruptions","fork":false,"url":"https://api.github.com/repos/47deg/translate-bubble-android","forks_url":"https://api.github.com/repos/47deg/translate-bubble-android/forks","keys_url":"https://api.github.com/repos/47deg/translate-bubble-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/47deg/translate-bubble-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/47deg/translate-bubble-android/teams","hooks_url":"https://api.github.com/repos/47deg/translate-bubble-android/hooks","issue_events_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues/events{/number}","events_url":"https://api.github.com/repos/47deg/translate-bubble-android/events","assignees_url":"https://api.github.com/repos/47deg/translate-bubble-android/assignees{/user}","branches_url":"https://api.github.com/repos/47deg/translate-bubble-android/branches{/branch}","tags_url":"https://api.github.com/repos/47deg/translate-bubble-android/tags","blobs_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/47deg/translate-bubble-android/statuses/{sha}","languages_url":"https://api.github.com/repos/47deg/translate-bubble-android/languages","stargazers_url":"https://api.github.com/repos/47deg/translate-bubble-android/stargazers","contributors_url":"https://api.github.com/repos/47deg/translate-bubble-android/contributors","subscribers_url":"https://api.github.com/repos/47deg/translate-bubble-android/subscribers","subscription_url":"https://api.github.com/repos/47deg/translate-bubble-android/subscription","commits_url":"https://api.github.com/repos/47deg/translate-bubble-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/47deg/translate-bubble-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/47deg/translate-bubble-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/47deg/translate-bubble-android/contents/{+path}","compare_url":"https://api.github.com/repos/47deg/translate-bubble-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/47deg/translate-bubble-android/merges","archive_url":"https://api.github.com/repos/47deg/translate-bubble-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/47deg/translate-bubble-android/downloads","issues_url":"https://api.github.com/repos/47deg/translate-bubble-android/issues{/number}","pulls_url":"https://api.github.com/repos/47deg/translate-bubble-android/pulls{/number}","milestones_url":"https://api.github.com/repos/47deg/translate-bubble-android/milestones{/number}","notifications_url":"https://api.github.com/repos/47deg/translate-bubble-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/47deg/translate-bubble-android/labels{/name}","releases_url":"https://api.github.com/repos/47deg/translate-bubble-android/releases{/id}","created_at":"2014-10-10T08:53:39Z","updated_at":"2015-03-20T05:53:04Z","pushed_at":"2015-03-20T08:45:38Z","git_url":"git://github.com/47deg/translate-bubble-android.git","ssh_url":"git@github.com:47deg/translate-bubble-android.git","clone_url":"https://github.com/47deg/translate-bubble-android.git","svn_url":"https://github.com/47deg/translate-bubble-android","homepage":"http://47deg.github.io/translate-bubble-android/","size":5502,"stargazers_count":154,"watchers_count":154,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":3,"forks":11,"open_issues":3,"watchers":154,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22"},"html":{"href":"https://github.com/47deg/translate-bubble-android/pull/22"},"issue":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/issues/22"},"comments":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/47deg/translate-bubble-android/statuses/1e1a0d57fc6543f24d0f3623a34c9538bf3d6627"}}}}