{"action":"created","comment":{"url":"https://api.github.com/repos/almighty/almighty-core/pulls/comments/79331898","id":79331898,"diff_hunk":"@@ -0,0 +1,56 @@\n+package remoteworkitem\n+\n+import (\n+\t\"reflect\"\n+\t\"strings\"\n+)\n+\n+type stack []string\n+\n+func (s *stack) push(v string) {\n+\t*s = append(*s, v)\n+}\n+\n+func (s *stack) pop() string {\n+\tl := len(*s)\n+\tif l == 0 {\n+\t\treturn \"\"\n+\t}\n+\tstackReference := *s // because *s[:l-1] did not work.\n+\tpoppedData := stackReference[l-1]\n+\t*s = stackReference[:l-1]\n+\treturn poppedData\n+}\n+\n+func (s stack) String() string {\n+\treturn strings.Join(s, \".\")\n+}\n+\n+// MapFlattener defines the data structures and the implemetation of how to flatten a nested map.\n+type MapFlattener struct {","path":"remoteworkitem/flatten.go","position":30,"original_position":30,"commit_id":"abfeccfd41ddc40b608a6d8fabe5e8aa9be1df54","original_commit_id":"39bfb39e29a615c2dd5c89da9f34a0846db465b6","user":{"login":"aslakknutsen","id":132158,"avatar_url":"https://avatars.githubusercontent.com/u/132158?v=3","gravatar_id":"","url":"https://api.github.com/users/aslakknutsen","html_url":"https://github.com/aslakknutsen","followers_url":"https://api.github.com/users/aslakknutsen/followers","following_url":"https://api.github.com/users/aslakknutsen/following{/other_user}","gists_url":"https://api.github.com/users/aslakknutsen/gists{/gist_id}","starred_url":"https://api.github.com/users/aslakknutsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aslakknutsen/subscriptions","organizations_url":"https://api.github.com/users/aslakknutsen/orgs","repos_url":"https://api.github.com/users/aslakknutsen/repos","events_url":"https://api.github.com/users/aslakknutsen/events{/privacy}","received_events_url":"https://api.github.com/users/aslakknutsen/received_events","type":"User","site_admin":false},"body":"You don't need it as a global variable to make it a function. Use Flatten() as an API exposed function, then call a recursive helper function internally and pass the needed values as arguments.","created_at":"2016-09-19T06:22:50Z","updated_at":"2016-09-19T06:22:50Z","html_url":"https://github.com/almighty/almighty-core/pull/227#discussion_r79331898","pull_request_url":"https://api.github.com/repos/almighty/almighty-core/pulls/227","_links":{"self":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/comments/79331898"},"html":{"href":"https://github.com/almighty/almighty-core/pull/227#discussion_r79331898"},"pull_request":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/227"}}},"pull_request":{"url":"https://api.github.com/repos/almighty/almighty-core/pulls/227","id":84434796,"html_url":"https://github.com/almighty/almighty-core/pull/227","diff_url":"https://github.com/almighty/almighty-core/pull/227.diff","patch_url":"https://github.com/almighty/almighty-core/pull/227.patch","issue_url":"https://api.github.com/repos/almighty/almighty-core/issues/227","number":227,"state":"open","locked":false,"title":"Added a method to flatten multi-level maps into single level maps.","user":{"login":"sbose78","id":545280,"avatar_url":"https://avatars.githubusercontent.com/u/545280?v=3","gravatar_id":"","url":"https://api.github.com/users/sbose78","html_url":"https://github.com/sbose78","followers_url":"https://api.github.com/users/sbose78/followers","following_url":"https://api.github.com/users/sbose78/following{/other_user}","gists_url":"https://api.github.com/users/sbose78/gists{/gist_id}","starred_url":"https://api.github.com/users/sbose78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbose78/subscriptions","organizations_url":"https://api.github.com/users/sbose78/orgs","repos_url":"https://api.github.com/users/sbose78/repos","events_url":"https://api.github.com/users/sbose78/events{/privacy}","received_events_url":"https://api.github.com/users/sbose78/received_events","type":"User","site_admin":false},"body":"\r\nTo enable simple ways of declaring remote-to-local Workitem maps,\r\nwe would need single level JSON structures in the remote tracker responses.\r\n\r\nExample,\r\n```\r\nProviderGithub: WorkItemMap{\r\n\t\tAttributeExpression(\"title\"): SystemTitle,\r\n\t\tAttributeExpression(\"body\"):  SystemDescription,\r\n\t\tAttributeExpression(\"state\"): SystemStatus,\r\n\t\tAttributeExpression(\"id\"):    SystemRemoteItemId,\r\n},\r\n```\r\n\r\nThe above map is a static map which is used to imply that the `title` field in the remote work item needs to be mapped as `system.title`\r\n\r\nNow the trouble is when the remote work item ( for some remote providers ) has the `title` defined\r\nin \r\n\r\n```\r\n{ \r\n   \"meta\":\r\n              {   \r\n                 \"title\":\" some title\",\r\n                 \"description\" : \" some desc\"\r\n              }\r\n}\r\n```\r\n\r\nIn such cases, we would want to declare our remote-to-local Work item mapping to still look simple\r\n```\r\n{\r\n      \"meta.description\" :\"Some description\",\r\n     \"meta.title\":\"some title\"\r\n}\r\n```\r\nIn this case our remote-to-local Work item map would looks something like ( an example  ) :\r\n```\r\nProviderJira: WorkItemMap{\r\n\t\tAttributeExpression(\"meta.title\"): SystemTitle,\r\n\t\tAttributeExpression(\"meta.description\"):  SystemDescription,\r\n\t\tAttributeExpression(\"state.stage\"): SystemStatus,\r\n\t\tAttributeExpression(\"id\"):    SystemRemoteItemId,\r\n},\r\n```\r\n\r\nFor this I've implemented a DFS which flattens a multiple level map into a single level map.\r\n\r\nFixes #214 \r\n<!-- Reviewable:start -->\r\n---\r\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/almighty/almighty-core/227)\r\n<!-- Reviewable:end -->\r\n","created_at":"2016-09-08T08:30:00Z","updated_at":"2016-09-19T06:22:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a0cc82dc3ff1c0e277cf996f879773ceb0baa62","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/almighty/almighty-core/pulls/227/commits","review_comments_url":"https://api.github.com/repos/almighty/almighty-core/pulls/227/comments","review_comment_url":"https://api.github.com/repos/almighty/almighty-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/almighty/almighty-core/issues/227/comments","statuses_url":"https://api.github.com/repos/almighty/almighty-core/statuses/abfeccfd41ddc40b608a6d8fabe5e8aa9be1df54","head":{"label":"sbose78:flatten-map-to-1-level","ref":"flatten-map-to-1-level","sha":"abfeccfd41ddc40b608a6d8fabe5e8aa9be1df54","user":{"login":"sbose78","id":545280,"avatar_url":"https://avatars.githubusercontent.com/u/545280?v=3","gravatar_id":"","url":"https://api.github.com/users/sbose78","html_url":"https://github.com/sbose78","followers_url":"https://api.github.com/users/sbose78/followers","following_url":"https://api.github.com/users/sbose78/following{/other_user}","gists_url":"https://api.github.com/users/sbose78/gists{/gist_id}","starred_url":"https://api.github.com/users/sbose78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbose78/subscriptions","organizations_url":"https://api.github.com/users/sbose78/orgs","repos_url":"https://api.github.com/users/sbose78/repos","events_url":"https://api.github.com/users/sbose78/events{/privacy}","received_events_url":"https://api.github.com/users/sbose78/received_events","type":"User","site_admin":false},"repo":{"id":64824078,"name":"almighty-core","full_name":"sbose78/almighty-core","owner":{"login":"sbose78","id":545280,"avatar_url":"https://avatars.githubusercontent.com/u/545280?v=3","gravatar_id":"","url":"https://api.github.com/users/sbose78","html_url":"https://github.com/sbose78","followers_url":"https://api.github.com/users/sbose78/followers","following_url":"https://api.github.com/users/sbose78/following{/other_user}","gists_url":"https://api.github.com/users/sbose78/gists{/gist_id}","starred_url":"https://api.github.com/users/sbose78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbose78/subscriptions","organizations_url":"https://api.github.com/users/sbose78/orgs","repos_url":"https://api.github.com/users/sbose78/repos","events_url":"https://api.github.com/users/sbose78/events{/privacy}","received_events_url":"https://api.github.com/users/sbose78/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sbose78/almighty-core","description":null,"fork":true,"url":"https://api.github.com/repos/sbose78/almighty-core","forks_url":"https://api.github.com/repos/sbose78/almighty-core/forks","keys_url":"https://api.github.com/repos/sbose78/almighty-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sbose78/almighty-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sbose78/almighty-core/teams","hooks_url":"https://api.github.com/repos/sbose78/almighty-core/hooks","issue_events_url":"https://api.github.com/repos/sbose78/almighty-core/issues/events{/number}","events_url":"https://api.github.com/repos/sbose78/almighty-core/events","assignees_url":"https://api.github.com/repos/sbose78/almighty-core/assignees{/user}","branches_url":"https://api.github.com/repos/sbose78/almighty-core/branches{/branch}","tags_url":"https://api.github.com/repos/sbose78/almighty-core/tags","blobs_url":"https://api.github.com/repos/sbose78/almighty-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sbose78/almighty-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sbose78/almighty-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/sbose78/almighty-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sbose78/almighty-core/statuses/{sha}","languages_url":"https://api.github.com/repos/sbose78/almighty-core/languages","stargazers_url":"https://api.github.com/repos/sbose78/almighty-core/stargazers","contributors_url":"https://api.github.com/repos/sbose78/almighty-core/contributors","subscribers_url":"https://api.github.com/repos/sbose78/almighty-core/subscribers","subscription_url":"https://api.github.com/repos/sbose78/almighty-core/subscription","commits_url":"https://api.github.com/repos/sbose78/almighty-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/sbose78/almighty-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/sbose78/almighty-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/sbose78/almighty-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/sbose78/almighty-core/contents/{+path}","compare_url":"https://api.github.com/repos/sbose78/almighty-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sbose78/almighty-core/merges","archive_url":"https://api.github.com/repos/sbose78/almighty-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sbose78/almighty-core/downloads","issues_url":"https://api.github.com/repos/sbose78/almighty-core/issues{/number}","pulls_url":"https://api.github.com/repos/sbose78/almighty-core/pulls{/number}","milestones_url":"https://api.github.com/repos/sbose78/almighty-core/milestones{/number}","notifications_url":"https://api.github.com/repos/sbose78/almighty-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sbose78/almighty-core/labels{/name}","releases_url":"https://api.github.com/repos/sbose78/almighty-core/releases{/id}","deployments_url":"https://api.github.com/repos/sbose78/almighty-core/deployments","created_at":"2016-08-03T07:12:02Z","updated_at":"2016-08-05T15:12:18Z","pushed_at":"2016-09-19T06:09:25Z","git_url":"git://github.com/sbose78/almighty-core.git","ssh_url":"git@github.com:sbose78/almighty-core.git","clone_url":"https://github.com/sbose78/almighty-core.git","svn_url":"https://github.com/sbose78/almighty-core","homepage":"http://devdoc.almighty.io","size":324,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"almighty:master","ref":"master","sha":"5c04a5ba536c437dc51e040b4246af1f71e5981a","user":{"login":"almighty","id":17783151,"avatar_url":"https://avatars.githubusercontent.com/u/17783151?v=3","gravatar_id":"","url":"https://api.github.com/users/almighty","html_url":"https://github.com/almighty","followers_url":"https://api.github.com/users/almighty/followers","following_url":"https://api.github.com/users/almighty/following{/other_user}","gists_url":"https://api.github.com/users/almighty/gists{/gist_id}","starred_url":"https://api.github.com/users/almighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almighty/subscriptions","organizations_url":"https://api.github.com/users/almighty/orgs","repos_url":"https://api.github.com/users/almighty/repos","events_url":"https://api.github.com/users/almighty/events{/privacy}","received_events_url":"https://api.github.com/users/almighty/received_events","type":"Organization","site_admin":false},"repo":{"id":54260706,"name":"almighty-core","full_name":"almighty/almighty-core","owner":{"login":"almighty","id":17783151,"avatar_url":"https://avatars.githubusercontent.com/u/17783151?v=3","gravatar_id":"","url":"https://api.github.com/users/almighty","html_url":"https://github.com/almighty","followers_url":"https://api.github.com/users/almighty/followers","following_url":"https://api.github.com/users/almighty/following{/other_user}","gists_url":"https://api.github.com/users/almighty/gists{/gist_id}","starred_url":"https://api.github.com/users/almighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almighty/subscriptions","organizations_url":"https://api.github.com/users/almighty/orgs","repos_url":"https://api.github.com/users/almighty/repos","events_url":"https://api.github.com/users/almighty/events{/privacy}","received_events_url":"https://api.github.com/users/almighty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/almighty/almighty-core","description":"","fork":false,"url":"https://api.github.com/repos/almighty/almighty-core","forks_url":"https://api.github.com/repos/almighty/almighty-core/forks","keys_url":"https://api.github.com/repos/almighty/almighty-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/almighty/almighty-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/almighty/almighty-core/teams","hooks_url":"https://api.github.com/repos/almighty/almighty-core/hooks","issue_events_url":"https://api.github.com/repos/almighty/almighty-core/issues/events{/number}","events_url":"https://api.github.com/repos/almighty/almighty-core/events","assignees_url":"https://api.github.com/repos/almighty/almighty-core/assignees{/user}","branches_url":"https://api.github.com/repos/almighty/almighty-core/branches{/branch}","tags_url":"https://api.github.com/repos/almighty/almighty-core/tags","blobs_url":"https://api.github.com/repos/almighty/almighty-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/almighty/almighty-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/almighty/almighty-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/almighty/almighty-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/almighty/almighty-core/statuses/{sha}","languages_url":"https://api.github.com/repos/almighty/almighty-core/languages","stargazers_url":"https://api.github.com/repos/almighty/almighty-core/stargazers","contributors_url":"https://api.github.com/repos/almighty/almighty-core/contributors","subscribers_url":"https://api.github.com/repos/almighty/almighty-core/subscribers","subscription_url":"https://api.github.com/repos/almighty/almighty-core/subscription","commits_url":"https://api.github.com/repos/almighty/almighty-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/almighty/almighty-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/almighty/almighty-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/almighty/almighty-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/almighty/almighty-core/contents/{+path}","compare_url":"https://api.github.com/repos/almighty/almighty-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/almighty/almighty-core/merges","archive_url":"https://api.github.com/repos/almighty/almighty-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/almighty/almighty-core/downloads","issues_url":"https://api.github.com/repos/almighty/almighty-core/issues{/number}","pulls_url":"https://api.github.com/repos/almighty/almighty-core/pulls{/number}","milestones_url":"https://api.github.com/repos/almighty/almighty-core/milestones{/number}","notifications_url":"https://api.github.com/repos/almighty/almighty-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/almighty/almighty-core/labels{/name}","releases_url":"https://api.github.com/repos/almighty/almighty-core/releases{/id}","deployments_url":"https://api.github.com/repos/almighty/almighty-core/deployments","created_at":"2016-03-19T10:42:15Z","updated_at":"2016-09-08T17:51:28Z","pushed_at":"2016-09-19T06:20:47Z","git_url":"git://github.com/almighty/almighty-core.git","ssh_url":"git@github.com:almighty/almighty-core.git","clone_url":"https://github.com/almighty/almighty-core.git","svn_url":"https://github.com/almighty/almighty-core","homepage":"http://devdoc.almighty.io/","size":4544,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":89,"forks":26,"open_issues":89,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/227"},"html":{"href":"https://github.com/almighty/almighty-core/pull/227"},"issue":{"href":"https://api.github.com/repos/almighty/almighty-core/issues/227"},"comments":{"href":"https://api.github.com/repos/almighty/almighty-core/issues/227/comments"},"review_comments":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/227/comments"},"review_comment":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/almighty/almighty-core/pulls/227/commits"},"statuses":{"href":"https://api.github.com/repos/almighty/almighty-core/statuses/abfeccfd41ddc40b608a6d8fabe5e8aa9be1df54"}}}}
{"actor":{"display_login":"aslakknutsen"}}