{"action":"created","comment":{"url":"https://api.github.com/repos/zanata/zanata-server/pulls/comments/26367424","id":26367424,"diff_hunk":"@@ -0,0 +1,230 @@\n+package org.zanata.action;\n+\n+import java.io.Serializable;\n+import java.util.Collections;\n+import java.util.List;\n+\n+import javax.faces.application.FacesMessage;\n+import javax.faces.component.UIOutput;\n+import javax.faces.event.AjaxBehaviorEvent;\n+import javax.faces.event.ValueChangeEvent;\n+\n+import lombok.Getter;\n+import lombok.Setter;\n+\n+import org.apache.commons.lang.StringUtils;\n+import org.jboss.seam.ScopeType;\n+import org.jboss.seam.annotations.Create;\n+import org.jboss.seam.annotations.In;\n+import org.jboss.seam.annotations.Name;\n+import org.jboss.seam.annotations.Scope;\n+import org.jboss.seam.faces.FacesMessages;\n+import org.jboss.seam.international.StatusMessage;\n+import org.zanata.async.handle.MergeTranslationsTaskHandle;\n+import org.zanata.common.EntityStatus;\n+import org.zanata.dao.ProjectDAO;\n+import org.zanata.dao.ProjectIterationDAO;\n+import org.zanata.i18n.Messages;\n+import org.zanata.model.HProject;\n+import org.zanata.model.HProjectIteration;\n+import org.zanata.ui.CopyAction;\n+\n+/**\n+ * Handles action from merge_trans_modal.xhtml\n+ *\n+ * @author Alex Eng <a href=\"mailto:aeng@redhat.com\">aeng@redhat.com</a>\n+ */\n+@Name(\"mergeTransAction\")\n+@Scope(ScopeType.PAGE)\n+public class MergeTransAction implements Serializable, CopyAction {\n+\n+    @Getter\n+    private String targetProjectSlug;\n+\n+    @Getter\n+    @Setter\n+    private String targetVersionSlug;\n+\n+    @Getter\n+    private String sourceProjectSlug;\n+\n+    @Getter\n+    @Setter\n+    private String sourceVersionSlug;\n+\n+    @Getter\n+    @Setter\n+    private boolean keepExistingTranslation;\n+\n+    @In\n+    private ProjectDAO projectDAO;\n+\n+    @In\n+    private ProjectIterationDAO projectIterationDAO;\n+\n+    @In\n+    private MergeTranslationsManager mergeTranslationsManager;\n+\n+    @In\n+    private CopyTransManager copyTransManager;\n+\n+    @In\n+    private CopyVersionManager copyVersionManager;\n+\n+    @In\n+    private Messages msgs;\n+\n+    private HProjectIteration targetVersion;\n+\n+    private HProject sourceProject;\n+\n+    public void setTargetProjectSlug(String targetProjectSlug) {\n+        this.targetProjectSlug = targetProjectSlug;\n+\n+        /**\n+         * This should only true during first instantiation. See pages.xml\n+         * for setter of mergeTransAction.targetProjectSlug\n+         */\n+        if(sourceProjectSlug == null) {\n+            setSourceProjectSlug(targetProjectSlug);\n+        }\n+    }\n+\n+    public void setSourceProjectSlug(String sourceProjectSlug) {\n+        if(!StringUtils.equals(this.sourceProjectSlug, sourceProjectSlug)) {\n+            this.sourceProjectSlug = sourceProjectSlug;\n+            sourceProject = null;\n+            if (!getSourceProject().getProjectIterations().isEmpty()) {\n+                sourceVersionSlug =\n+                        getSourceProject().getProjectIterations().get(0)\n+                                .getSlug();\n+            }\n+        }\n+    }\n+\n+    public HProjectIteration getTargetVersion() {\n+        if(targetVersion == null) {\n+            targetVersion =\n+                    projectIterationDAO.getBySlug(targetProjectSlug,\n+                            targetVersionSlug);\n+        }\n+        return targetVersion;\n+    }\n+\n+    public HProject getSourceProject() {\n+        if(sourceProject == null) {\n+            sourceProject = projectDAO.getBySlug(sourceProjectSlug);\n+        }\n+        return sourceProject;\n+    }\n+\n+    public List<HProjectIteration> getSourceVersions() {\n+        List<HProjectIteration> versions =\n+                getSourceProject().getProjectIterations();\n+\n+        if(versions.isEmpty()) {\n+            return Collections.emptyList();\n+        }\n+\n+        //remove target version if both are the same project or obsolete\n+        if (StringUtils.equals(sourceProjectSlug, targetProjectSlug)) {\n+            for (HProjectIteration version : versions) {\n+                if (version.getSlug().equals(targetVersionSlug)\n+                        || version.getStatus().equals(EntityStatus.OBSOLETE)) {","path":"zanata-war/src/main/java/org/zanata/action/MergeTransAction.java","position":133,"original_position":133,"commit_id":"f0419d1e34877b75d82f12ded3fc2ff0427662b7","original_commit_id":"f0419d1e34877b75d82f12ded3fc2ff0427662b7","user":{"login":"davidmason","id":482026,"avatar_url":"https://avatars.githubusercontent.com/u/482026?v=3","gravatar_id":"","url":"https://api.github.com/users/davidmason","html_url":"https://github.com/davidmason","followers_url":"https://api.github.com/users/davidmason/followers","following_url":"https://api.github.com/users/davidmason/following{/other_user}","gists_url":"https://api.github.com/users/davidmason/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmason/subscriptions","organizations_url":"https://api.github.com/users/davidmason/orgs","repos_url":"https://api.github.com/users/davidmason/repos","events_url":"https://api.github.com/users/davidmason/events{/privacy}","received_events_url":"https://api.github.com/users/davidmason/received_events","type":"User","site_admin":false},"body":"I think this check for obsolete versions should happen regardless whether it is the same project. This looks like it would still show obsolete versions if they are in a different project.\r\nMaybe remove the first `if` and move its condition in front of the second `if` so that it is\r\n\r\n```\r\nif (version.getStatus().equals(EntityStatus.OBSOLETE) ||\r\n        StringUtils.equals(sourceProjectSlug, targetProjectSlug) &&\r\n        version.getSlug().equals(targetVersionSlug)) {\r\n```","created_at":"2015-03-13T06:37:43Z","updated_at":"2015-03-13T06:37:43Z","html_url":"https://github.com/zanata/zanata-server/pull/719#discussion_r26367424","pull_request_url":"https://api.github.com/repos/zanata/zanata-server/pulls/719","_links":{"self":{"href":"https://api.github.com/repos/zanata/zanata-server/pulls/comments/26367424"},"html":{"href":"https://github.com/zanata/zanata-server/pull/719#discussion_r26367424"},"pull_request":{"href":"https://api.github.com/repos/zanata/zanata-server/pulls/719"}}},"pull_request":{"url":"https://api.github.com/repos/zanata/zanata-server/pulls/719","id":30736849,"html_url":"https://github.com/zanata/zanata-server/pull/719","diff_url":"https://github.com/zanata/zanata-server/pull/719.diff","patch_url":"https://github.com/zanata/zanata-server/pull/719.patch","issue_url":"https://api.github.com/repos/zanata/zanata-server/issues/719","number":719,"state":"open","locked":false,"title":"Merge translation from existing version to another","user":{"login":"aeng","id":766762,"avatar_url":"https://avatars.githubusercontent.com/u/766762?v=3","gravatar_id":"","url":"https://api.github.com/users/aeng","html_url":"https://github.com/aeng","followers_url":"https://api.github.com/users/aeng/followers","following_url":"https://api.github.com/users/aeng/following{/other_user}","gists_url":"https://api.github.com/users/aeng/gists{/gist_id}","starred_url":"https://api.github.com/users/aeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeng/subscriptions","organizations_url":"https://api.github.com/users/aeng/orgs","repos_url":"https://api.github.com/users/aeng/repos","events_url":"https://api.github.com/users/aeng/events{/privacy}","received_events_url":"https://api.github.com/users/aeng/received_events","type":"User","site_admin":false},"body":"https://bugzilla.redhat.com/show_bug.cgi?id=1133989","created_at":"2015-03-09T05:20:24Z","updated_at":"2015-03-13T06:37:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf3668e212adacac8229f9957f9968dce75ae01c","assignee":{"login":"carlosmunoz","id":84676,"avatar_url":"https://avatars.githubusercontent.com/u/84676?v=3","gravatar_id":"","url":"https://api.github.com/users/carlosmunoz","html_url":"https://github.com/carlosmunoz","followers_url":"https://api.github.com/users/carlosmunoz/followers","following_url":"https://api.github.com/users/carlosmunoz/following{/other_user}","gists_url":"https://api.github.com/users/carlosmunoz/gists{/gist_id}","starred_url":"https://api.github.com/users/carlosmunoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlosmunoz/subscriptions","organizations_url":"https://api.github.com/users/carlosmunoz/orgs","repos_url":"https://api.github.com/users/carlosmunoz/repos","events_url":"https://api.github.com/users/carlosmunoz/events{/privacy}","received_events_url":"https://api.github.com/users/carlosmunoz/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/zanata/zanata-server/pulls/719/commits","review_comments_url":"https://api.github.com/repos/zanata/zanata-server/pulls/719/comments","review_comment_url":"https://api.github.com/repos/zanata/zanata-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zanata/zanata-server/issues/719/comments","statuses_url":"https://api.github.com/repos/zanata/zanata-server/statuses/f0419d1e34877b75d82f12ded3fc2ff0427662b7","head":{"label":"zanata:rhbz1133989","ref":"rhbz1133989","sha":"f0419d1e34877b75d82f12ded3fc2ff0427662b7","user":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=3","gravatar_id":"","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"repo":{"id":1461609,"name":"zanata-server","full_name":"zanata/zanata-server","owner":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=3","gravatar_id":"","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zanata/zanata-server","description":"Zanata is a web-based system for translators to translate documentation and software online using a web browser.","fork":false,"url":"https://api.github.com/repos/zanata/zanata-server","forks_url":"https://api.github.com/repos/zanata/zanata-server/forks","keys_url":"https://api.github.com/repos/zanata/zanata-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zanata/zanata-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zanata/zanata-server/teams","hooks_url":"https://api.github.com/repos/zanata/zanata-server/hooks","issue_events_url":"https://api.github.com/repos/zanata/zanata-server/issues/events{/number}","events_url":"https://api.github.com/repos/zanata/zanata-server/events","assignees_url":"https://api.github.com/repos/zanata/zanata-server/assignees{/user}","branches_url":"https://api.github.com/repos/zanata/zanata-server/branches{/branch}","tags_url":"https://api.github.com/repos/zanata/zanata-server/tags","blobs_url":"https://api.github.com/repos/zanata/zanata-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zanata/zanata-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zanata/zanata-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/zanata/zanata-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zanata/zanata-server/statuses/{sha}","languages_url":"https://api.github.com/repos/zanata/zanata-server/languages","stargazers_url":"https://api.github.com/repos/zanata/zanata-server/stargazers","contributors_url":"https://api.github.com/repos/zanata/zanata-server/contributors","subscribers_url":"https://api.github.com/repos/zanata/zanata-server/subscribers","subscription_url":"https://api.github.com/repos/zanata/zanata-server/subscription","commits_url":"https://api.github.com/repos/zanata/zanata-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/zanata/zanata-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/zanata/zanata-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/zanata/zanata-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/zanata/zanata-server/contents/{+path}","compare_url":"https://api.github.com/repos/zanata/zanata-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zanata/zanata-server/merges","archive_url":"https://api.github.com/repos/zanata/zanata-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zanata/zanata-server/downloads","issues_url":"https://api.github.com/repos/zanata/zanata-server/issues{/number}","pulls_url":"https://api.github.com/repos/zanata/zanata-server/pulls{/number}","milestones_url":"https://api.github.com/repos/zanata/zanata-server/milestones{/number}","notifications_url":"https://api.github.com/repos/zanata/zanata-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zanata/zanata-server/labels{/name}","releases_url":"https://api.github.com/repos/zanata/zanata-server/releases{/id}","created_at":"2011-03-10T00:24:47Z","updated_at":"2015-03-12T04:52:13Z","pushed_at":"2015-03-13T05:29:12Z","git_url":"git://github.com/zanata/zanata-server.git","ssh_url":"git@github.com:zanata/zanata-server.git","clone_url":"https://github.com/zanata/zanata-server.git","svn_url":"https://github.com/zanata/zanata-server","homepage":"http://zanata.org","size":230212,"stargazers_count":87,"watchers_count":87,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":18,"forks":24,"open_issues":18,"watchers":87,"default_branch":"master"}},"base":{"label":"zanata:integration/master","ref":"integration/master","sha":"baef61afe74989d5e2970700c6e10fcfb6efddfb","user":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=3","gravatar_id":"","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"repo":{"id":1461609,"name":"zanata-server","full_name":"zanata/zanata-server","owner":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=3","gravatar_id":"","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zanata/zanata-server","description":"Zanata is a web-based system for translators to translate documentation and software online using a web browser.","fork":false,"url":"https://api.github.com/repos/zanata/zanata-server","forks_url":"https://api.github.com/repos/zanata/zanata-server/forks","keys_url":"https://api.github.com/repos/zanata/zanata-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zanata/zanata-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zanata/zanata-server/teams","hooks_url":"https://api.github.com/repos/zanata/zanata-server/hooks","issue_events_url":"https://api.github.com/repos/zanata/zanata-server/issues/events{/number}","events_url":"https://api.github.com/repos/zanata/zanata-server/events","assignees_url":"https://api.github.com/repos/zanata/zanata-server/assignees{/user}","branches_url":"https://api.github.com/repos/zanata/zanata-server/branches{/branch}","tags_url":"https://api.github.com/repos/zanata/zanata-server/tags","blobs_url":"https://api.github.com/repos/zanata/zanata-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zanata/zanata-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zanata/zanata-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/zanata/zanata-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zanata/zanata-server/statuses/{sha}","languages_url":"https://api.github.com/repos/zanata/zanata-server/languages","stargazers_url":"https://api.github.com/repos/zanata/zanata-server/stargazers","contributors_url":"https://api.github.com/repos/zanata/zanata-server/contributors","subscribers_url":"https://api.github.com/repos/zanata/zanata-server/subscribers","subscription_url":"https://api.github.com/repos/zanata/zanata-server/subscription","commits_url":"https://api.github.com/repos/zanata/zanata-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/zanata/zanata-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/zanata/zanata-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/zanata/zanata-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/zanata/zanata-server/contents/{+path}","compare_url":"https://api.github.com/repos/zanata/zanata-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zanata/zanata-server/merges","archive_url":"https://api.github.com/repos/zanata/zanata-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zanata/zanata-server/downloads","issues_url":"https://api.github.com/repos/zanata/zanata-server/issues{/number}","pulls_url":"https://api.github.com/repos/zanata/zanata-server/pulls{/number}","milestones_url":"https://api.github.com/repos/zanata/zanata-server/milestones{/number}","notifications_url":"https://api.github.com/repos/zanata/zanata-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zanata/zanata-server/labels{/name}","releases_url":"https://api.github.com/repos/zanata/zanata-server/releases{/id}","created_at":"2011-03-10T00:24:47Z","updated_at":"2015-03-12T04:52:13Z","pushed_at":"2015-03-13T05:29:12Z","git_url":"git://github.com/zanata/zanata-server.git","ssh_url":"git@github.com:zanata/zanata-server.git","clone_url":"https://github.com/zanata/zanata-server.git","svn_url":"https://github.com/zanata/zanata-server","homepage":"http://zanata.org","size":230212,"stargazers_count":87,"watchers_count":87,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":18,"forks":24,"open_issues":18,"watchers":87,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zanata/zanata-server/pulls/719"},"html":{"href":"https://github.com/zanata/zanata-server/pull/719"},"issue":{"href":"https://api.github.com/repos/zanata/zanata-server/issues/719"},"comments":{"href":"https://api.github.com/repos/zanata/zanata-server/issues/719/comments"},"review_comments":{"href":"https://api.github.com/repos/zanata/zanata-server/pulls/719/comments"},"review_comment":{"href":"https://api.github.com/repos/zanata/zanata-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zanata/zanata-server/pulls/719/commits"},"statuses":{"href":"https://api.github.com/repos/zanata/zanata-server/statuses/f0419d1e34877b75d82f12ded3fc2ff0427662b7"}}}}