{"action":"created","comment":{"url":"https://api.github.com/repos/caskdata/cdap/pulls/comments/25922438","id":25922438,"diff_hunk":"@@ -97,12 +97,62 @@ angular.module(PKG.name+'.services')\n     return obj;\n   }\n \n+  function convert(nodes, connections) {\n+    // Accepts list of nodes -> Converts to list of connections\n+    for (var i=0; i+1 < nodes.length; i++) {\n+\n+      if ( i === 0 && nodes[i].nodeType === 'FORK') {\n+        flatten(null, nodes[i], nodes[i+1], connections);\n+      }\n+\n+      if (nodes[i].nodeType === 'ACTION' && nodes[i+1].nodeType === 'ACTION') {\n+        connections.push({\n+          sourceName: nodes[i].program.programName + nodes[i].nodeId,\n+          targetName: nodes[i+1].program.programName + nodes[i+1].nodeId,\n+          sourceType: nodes[i].nodeType\n+        });\n+      } else if (nodes[i].nodeType === 'FORK') {\n+        flatten(nodes[i-1], nodes[i], nodes[i+1], connections);\n+      }\n+\n+      if ( (i+1 === nodes.length-1) && nodes[i+1].nodeType === 'FORK') {\n+        flatten(nodes[i], nodes[i+1], null, connections);\n+      }\n+    }\n+  }\n+\n+  function flatten(source, fork, target, connections) {\n+    // Flatten a source-fork-target combo to [list of connections]\n+    var branches = fork.branches,\n+        temp = [];\n+\n+    for (var i =0; i<branches.length; i++) {\n+      temp = branches[i];\n+      temp.unshift(source);\n+      temp.push(target);\n+      convert(temp, connections);\n+    }\n+  }\n+\n+  function expandForks(nodes, expandedNodes) {\n+    for(var i=0; i<nodes.length; i++) {\n+      if (nodes[i].nodeType === 'ACTION') {\n+        expandedNodes.push(nodes[i]);\n+      } else if (nodes[i].nodeType === 'FORK') {\n+        for (var j=0; j<nodes[i].branches.length; j++) {\n+          expandForks(nodes[i].branches[j], expandedNodes);\n+        }\n+      }\n+    }\n+  }","path":"cdap-ui/app/services/helpers.js","position":51,"original_position":51,"commit_id":"b6e52dc06c64ff7aabacdeab5d46cbf8bf3639a0","original_commit_id":"b6e52dc06c64ff7aabacdeab5d46cbf8bf3639a0","user":{"login":"gaarf","id":205004,"avatar_url":"https://avatars.githubusercontent.com/u/205004?v=3","gravatar_id":"","url":"https://api.github.com/users/gaarf","html_url":"https://github.com/gaarf","followers_url":"https://api.github.com/users/gaarf/followers","following_url":"https://api.github.com/users/gaarf/following{/other_user}","gists_url":"https://api.github.com/users/gaarf/gists{/gist_id}","starred_url":"https://api.github.com/users/gaarf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaarf/subscriptions","organizations_url":"https://api.github.com/users/gaarf/orgs","repos_url":"https://api.github.com/users/gaarf/repos","events_url":"https://api.github.com/users/gaarf/events{/privacy}","received_events_url":"https://api.github.com/users/gaarf/received_events","type":"User","site_admin":false},"body":"these 3 functions are very specific to the API being used... IMHO they should not live in `myHelpers`. For now I would put them in the controller file that uses them, or if they are going to be re-used, in a different service. Later this belongs in a `myWorkflowsApi`.","created_at":"2015-03-06T02:47:44Z","updated_at":"2015-03-06T02:47:44Z","html_url":"https://github.com/caskdata/cdap/pull/1505#discussion_r25922438","pull_request_url":"https://api.github.com/repos/caskdata/cdap/pulls/1505","_links":{"self":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/comments/25922438"},"html":{"href":"https://github.com/caskdata/cdap/pull/1505#discussion_r25922438"},"pull_request":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1505"}}},"pull_request":{"url":"https://api.github.com/repos/caskdata/cdap/pulls/1505","id":30605050,"html_url":"https://github.com/caskdata/cdap/pull/1505","diff_url":"https://github.com/caskdata/cdap/pull/1505.diff","patch_url":"https://github.com/caskdata/cdap/pull/1505.patch","issue_url":"https://api.github.com/repos/caskdata/cdap/issues/1505","number":1505,"state":"open","locked":false,"title":"adds flow graph visualization to app workflows","user":{"login":"astewes","id":5335210,"avatar_url":"https://avatars.githubusercontent.com/u/5335210?v=3","gravatar_id":"","url":"https://api.github.com/users/astewes","html_url":"https://github.com/astewes","followers_url":"https://api.github.com/users/astewes/followers","following_url":"https://api.github.com/users/astewes/following{/other_user}","gists_url":"https://api.github.com/users/astewes/gists{/gist_id}","starred_url":"https://api.github.com/users/astewes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astewes/subscriptions","organizations_url":"https://api.github.com/users/astewes/orgs","repos_url":"https://api.github.com/users/astewes/repos","events_url":"https://api.github.com/users/astewes/events{/privacy}","received_events_url":"https://api.github.com/users/astewes/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-05T23:01:20Z","updated_at":"2015-03-06T02:47:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"814797a15372e80617082d2b29354c65de8ea2c8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/caskdata/cdap/pulls/1505/commits","review_comments_url":"https://api.github.com/repos/caskdata/cdap/pulls/1505/comments","review_comment_url":"https://api.github.com/repos/caskdata/cdap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/caskdata/cdap/issues/1505/comments","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/b6e52dc06c64ff7aabacdeab5d46cbf8bf3639a0","head":{"label":"caskdata:feature/ui-workflow-connections","ref":"feature/ui-workflow-connections","sha":"b6e52dc06c64ff7aabacdeab5d46cbf8bf3639a0","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22542759,"name":"cdap","full_name":"caskdata/cdap","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/cdap","description":"Cask Data Application Platform (CDAP)","fork":false,"url":"https://api.github.com/repos/caskdata/cdap","forks_url":"https://api.github.com/repos/caskdata/cdap/forks","keys_url":"https://api.github.com/repos/caskdata/cdap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/cdap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/cdap/teams","hooks_url":"https://api.github.com/repos/caskdata/cdap/hooks","issue_events_url":"https://api.github.com/repos/caskdata/cdap/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/cdap/events","assignees_url":"https://api.github.com/repos/caskdata/cdap/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/cdap/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/cdap/tags","blobs_url":"https://api.github.com/repos/caskdata/cdap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/cdap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/cdap/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/cdap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/cdap/languages","stargazers_url":"https://api.github.com/repos/caskdata/cdap/stargazers","contributors_url":"https://api.github.com/repos/caskdata/cdap/contributors","subscribers_url":"https://api.github.com/repos/caskdata/cdap/subscribers","subscription_url":"https://api.github.com/repos/caskdata/cdap/subscription","commits_url":"https://api.github.com/repos/caskdata/cdap/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/cdap/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/cdap/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/cdap/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/cdap/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/cdap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/cdap/merges","archive_url":"https://api.github.com/repos/caskdata/cdap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/cdap/downloads","issues_url":"https://api.github.com/repos/caskdata/cdap/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/cdap/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/cdap/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/cdap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/cdap/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/cdap/releases{/id}","created_at":"2014-08-02T09:00:10Z","updated_at":"2015-03-06T01:39:55Z","pushed_at":"2015-03-06T02:34:15Z","git_url":"git://github.com/caskdata/cdap.git","ssh_url":"git@github.com:caskdata/cdap.git","clone_url":"https://github.com/caskdata/cdap.git","svn_url":"https://github.com/caskdata/cdap","homepage":"http://cdap.io","size":793527,"stargazers_count":29,"watchers_count":29,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":29,"forks":9,"open_issues":29,"watchers":29,"default_branch":"develop"}},"base":{"label":"caskdata:develop","ref":"develop","sha":"e059bf2e4c9254ddc18f611afbf338b3779d7c21","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22542759,"name":"cdap","full_name":"caskdata/cdap","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/cdap","description":"Cask Data Application Platform (CDAP)","fork":false,"url":"https://api.github.com/repos/caskdata/cdap","forks_url":"https://api.github.com/repos/caskdata/cdap/forks","keys_url":"https://api.github.com/repos/caskdata/cdap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/cdap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/cdap/teams","hooks_url":"https://api.github.com/repos/caskdata/cdap/hooks","issue_events_url":"https://api.github.com/repos/caskdata/cdap/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/cdap/events","assignees_url":"https://api.github.com/repos/caskdata/cdap/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/cdap/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/cdap/tags","blobs_url":"https://api.github.com/repos/caskdata/cdap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/cdap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/cdap/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/cdap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/cdap/languages","stargazers_url":"https://api.github.com/repos/caskdata/cdap/stargazers","contributors_url":"https://api.github.com/repos/caskdata/cdap/contributors","subscribers_url":"https://api.github.com/repos/caskdata/cdap/subscribers","subscription_url":"https://api.github.com/repos/caskdata/cdap/subscription","commits_url":"https://api.github.com/repos/caskdata/cdap/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/cdap/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/cdap/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/cdap/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/cdap/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/cdap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/cdap/merges","archive_url":"https://api.github.com/repos/caskdata/cdap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/cdap/downloads","issues_url":"https://api.github.com/repos/caskdata/cdap/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/cdap/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/cdap/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/cdap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/cdap/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/cdap/releases{/id}","created_at":"2014-08-02T09:00:10Z","updated_at":"2015-03-06T01:39:55Z","pushed_at":"2015-03-06T02:34:15Z","git_url":"git://github.com/caskdata/cdap.git","ssh_url":"git@github.com:caskdata/cdap.git","clone_url":"https://github.com/caskdata/cdap.git","svn_url":"https://github.com/caskdata/cdap","homepage":"http://cdap.io","size":793527,"stargazers_count":29,"watchers_count":29,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":29,"forks":9,"open_issues":29,"watchers":29,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1505"},"html":{"href":"https://github.com/caskdata/cdap/pull/1505"},"issue":{"href":"https://api.github.com/repos/caskdata/cdap/issues/1505"},"comments":{"href":"https://api.github.com/repos/caskdata/cdap/issues/1505/comments"},"review_comments":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1505/comments"},"review_comment":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1505/commits"},"statuses":{"href":"https://api.github.com/repos/caskdata/cdap/statuses/b6e52dc06c64ff7aabacdeab5d46cbf8bf3639a0"}}}}