{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments/172124407","pull_request_review_id":101087464,"id":172124407,"diff_hunk":"@@ -844,6 +848,53 @@ public Response getAttributes(@PathParam(\"siddhiAppName\") String siddhiAppName,\n                 ).build();\n     }\n \n+    /**\n+     * Converts a given Siddhi App string to a specific JSON format for a graph that diagrammatically\n+     * display's the Siddhi App to be generated in the Editor design view.\n+     *\n+     * @param siddhiAppBase64 The Siddhi App (encoded to Base64) to be converted to JSON\n+     * @return The JSON result in a predefined format\n+     */\n+    @POST\n+    @Path(\"/event-flow\")\n+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)\n+    @Produces(MediaType.APPLICATION_JSON)\n+    public Response constructEventFlowJsonString(String siddhiAppBase64) {\n+        Response response;\n+\n+        try {\n+            String siddhiAppString = new String(Base64.getDecoder().decode(siddhiAppBase64),\n+                    Charset.defaultCharset());\n+\n+            SiddhiAppMap siddhiAppMap = new SiddhiAppMap(siddhiAppString);\n+            EventFlow eventFlow = new EventFlow(siddhiAppMap);\n+\n+            // The 'Access-Control-Allow-Origin' header must be set to '*' as this might be accessed\n+            // by other domains in the future.\n+            response = Response.status(Response.Status.OK)\n+                    .header(\"Access-Control-Allow-Origin\", \"*\")\n+                    .entity(eventFlow.getEventFlowJSON().toString())\n+                    .build();\n+        } catch (SiddhiAppCreationException e) {\n+            // SiddhiAppCreationException is caught if the provided 'SiddhiAppString' contains any syntax errors.\n+            log.info(\"Cannot Generate Graph View: \" + e.getMessage());","path":"components/org.wso2.carbon.siddhi.editor.core/src/main/java/org/wso2/carbon/siddhi/editor/core/internal/EditorMicroservice.java","position":85,"original_position":85,"commit_id":"19ddd9b3e344aeea64483c22f6cfd38712d2a57e","original_commit_id":"19ddd9b3e344aeea64483c22f6cfd38712d2a57e","user":{"login":"moizalicious","id":25219255,"avatar_url":"https://avatars2.githubusercontent.com/u/25219255?v=4","gravatar_id":"","url":"https://api.github.com/users/moizalicious","html_url":"https://github.com/moizalicious","followers_url":"https://api.github.com/users/moizalicious/followers","following_url":"https://api.github.com/users/moizalicious/following{/other_user}","gists_url":"https://api.github.com/users/moizalicious/gists{/gist_id}","starred_url":"https://api.github.com/users/moizalicious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moizalicious/subscriptions","organizations_url":"https://api.github.com/users/moizalicious/orgs","repos_url":"https://api.github.com/users/moizalicious/repos","events_url":"https://api.github.com/users/moizalicious/events{/privacy}","received_events_url":"https://api.github.com/users/moizalicious/received_events","type":"User","site_admin":false},"body":"Hi, so I spoke to Damith regarding the matter, and he said that it's ok if we print this as an error with the stack trace as well. Cause anyway the end goal of that line is to inform the user that he/she cannot switch to the graph view because the written siddhi app contains errors.","created_at":"2018-03-05T09:12:37Z","updated_at":"2018-03-05T09:12:38Z","html_url":"https://github.com/wso2/carbon-analytics/pull/1170#discussion_r172124407","pull_request_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments/172124407"},"html":{"href":"https://github.com/wso2/carbon-analytics/pull/1170#discussion_r172124407"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170"}},"in_reply_to_id":172096083},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170","id":172454926,"html_url":"https://github.com/wso2/carbon-analytics/pull/1170","diff_url":"https://github.com/wso2/carbon-analytics/pull/1170.diff","patch_url":"https://github.com/wso2/carbon-analytics/pull/1170.patch","issue_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/1170","number":1170,"state":"open","locked":false,"title":"Siddhi Editor Core - Graph Generation Implementation","user":{"login":"moizalicious","id":25219255,"avatar_url":"https://avatars2.githubusercontent.com/u/25219255?v=4","gravatar_id":"","url":"https://api.github.com/users/moizalicious","html_url":"https://github.com/moizalicious","followers_url":"https://api.github.com/users/moizalicious/followers","following_url":"https://api.github.com/users/moizalicious/following{/other_user}","gists_url":"https://api.github.com/users/moizalicious/gists{/gist_id}","starred_url":"https://api.github.com/users/moizalicious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moizalicious/subscriptions","organizations_url":"https://api.github.com/users/moizalicious/orgs","repos_url":"https://api.github.com/users/moizalicious/repos","events_url":"https://api.github.com/users/moizalicious/events{/privacy}","received_events_url":"https://api.github.com/users/moizalicious/received_events","type":"User","site_admin":false},"body":"## Purpose\r\nCode to display Siddhi Apps that are written in the Stream Processor Editor as a visual tree-like structure.\r\n\r\n## Goals\r\nAllow the user to be able to switch from the 'Source View' to a 'Design View' where the design view will display a diagrammatical representation of the Siddhi App that is written in the source view.\r\n\r\n## Approach\r\nWhen the user clicks on the 'Toggle To Design View' button, the source of the respective Siddhi App is sent to a back-end microservice in the `EditorMicroservice` class. There the source is obtained as a string and is used to create `SiddhiApp` & `SiddhiAppRuntime` instances. Using these two classes, a JSON object of a predefined format is created and sent back to the front-end, the returned JSON object is what holds information that defines how the graph should be displayed in the Editor.\r\n\r\nThe following GIF shows the graph generated from the `RecieveAndCount` example:\r\n\r\n![pr-demo](https://user-images.githubusercontent.com/25219255/36889554-82c0bcf0-1e20-11e8-8867-89fa9152aea4.gif)\r\n\r\nThe flow of the entire graph generation process is described in the following diagram:\r\n\r\n![pr-flow](https://user-images.githubusercontent.com/25219255/36891120-7032ed0a-1e26-11e8-9acf-98465921ce56.png)\r\n\r\n## Security checks\r\n - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes\r\n - Ran FindSecurityBugs plugin and verified report? yes\r\n - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes\r\n\r\n## Learning\r\nThe [Dagre-D3](https://github.com/dagrejs/dagre-d3) JavaScript library is used to generate and render the graphs from the Siddhi Apps.\r\n","created_at":"2018-03-02T09:18:16Z","updated_at":"2018-03-05T09:12:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e1e2d03257b54eb85d0fbffeccc1200c802f383","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/1170/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-analytics/statuses/19ddd9b3e344aeea64483c22f6cfd38712d2a57e","head":{"label":"moizalicious:master","ref":"master","sha":"19ddd9b3e344aeea64483c22f6cfd38712d2a57e","user":{"login":"moizalicious","id":25219255,"avatar_url":"https://avatars2.githubusercontent.com/u/25219255?v=4","gravatar_id":"","url":"https://api.github.com/users/moizalicious","html_url":"https://github.com/moizalicious","followers_url":"https://api.github.com/users/moizalicious/followers","following_url":"https://api.github.com/users/moizalicious/following{/other_user}","gists_url":"https://api.github.com/users/moizalicious/gists{/gist_id}","starred_url":"https://api.github.com/users/moizalicious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moizalicious/subscriptions","organizations_url":"https://api.github.com/users/moizalicious/orgs","repos_url":"https://api.github.com/users/moizalicious/repos","events_url":"https://api.github.com/users/moizalicious/events{/privacy}","received_events_url":"https://api.github.com/users/moizalicious/received_events","type":"User","site_admin":false},"repo":{"id":121358877,"name":"carbon-analytics","full_name":"moizalicious/carbon-analytics","owner":{"login":"moizalicious","id":25219255,"avatar_url":"https://avatars2.githubusercontent.com/u/25219255?v=4","gravatar_id":"","url":"https://api.github.com/users/moizalicious","html_url":"https://github.com/moizalicious","followers_url":"https://api.github.com/users/moizalicious/followers","following_url":"https://api.github.com/users/moizalicious/following{/other_user}","gists_url":"https://api.github.com/users/moizalicious/gists{/gist_id}","starred_url":"https://api.github.com/users/moizalicious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moizalicious/subscriptions","organizations_url":"https://api.github.com/users/moizalicious/orgs","repos_url":"https://api.github.com/users/moizalicious/repos","events_url":"https://api.github.com/users/moizalicious/events{/privacy}","received_events_url":"https://api.github.com/users/moizalicious/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/moizalicious/carbon-analytics","description":null,"fork":true,"url":"https://api.github.com/repos/moizalicious/carbon-analytics","forks_url":"https://api.github.com/repos/moizalicious/carbon-analytics/forks","keys_url":"https://api.github.com/repos/moizalicious/carbon-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moizalicious/carbon-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moizalicious/carbon-analytics/teams","hooks_url":"https://api.github.com/repos/moizalicious/carbon-analytics/hooks","issue_events_url":"https://api.github.com/repos/moizalicious/carbon-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/moizalicious/carbon-analytics/events","assignees_url":"https://api.github.com/repos/moizalicious/carbon-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/moizalicious/carbon-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/moizalicious/carbon-analytics/tags","blobs_url":"https://api.github.com/repos/moizalicious/carbon-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moizalicious/carbon-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moizalicious/carbon-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/moizalicious/carbon-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moizalicious/carbon-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/moizalicious/carbon-analytics/languages","stargazers_url":"https://api.github.com/repos/moizalicious/carbon-analytics/stargazers","contributors_url":"https://api.github.com/repos/moizalicious/carbon-analytics/contributors","subscribers_url":"https://api.github.com/repos/moizalicious/carbon-analytics/subscribers","subscription_url":"https://api.github.com/repos/moizalicious/carbon-analytics/subscription","commits_url":"https://api.github.com/repos/moizalicious/carbon-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/moizalicious/carbon-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/moizalicious/carbon-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/moizalicious/carbon-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/moizalicious/carbon-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/moizalicious/carbon-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moizalicious/carbon-analytics/merges","archive_url":"https://api.github.com/repos/moizalicious/carbon-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moizalicious/carbon-analytics/downloads","issues_url":"https://api.github.com/repos/moizalicious/carbon-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/moizalicious/carbon-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/moizalicious/carbon-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/moizalicious/carbon-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moizalicious/carbon-analytics/labels{/name}","releases_url":"https://api.github.com/repos/moizalicious/carbon-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/moizalicious/carbon-analytics/deployments","created_at":"2018-02-13T08:45:01Z","updated_at":"2018-02-13T08:45:10Z","pushed_at":"2018-03-02T10:10:15Z","git_url":"git://github.com/moizalicious/carbon-analytics.git","ssh_url":"git@github.com:moizalicious/carbon-analytics.git","clone_url":"https://github.com/moizalicious/carbon-analytics.git","svn_url":"https://github.com/moizalicious/carbon-analytics","homepage":null,"size":88729,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"0623f11b62da4aee647c84d5dd7015c1267b915a","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars3.githubusercontent.com/u/533043?v=4","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":16543113,"name":"carbon-analytics","full_name":"wso2/carbon-analytics","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars3.githubusercontent.com/u/533043?v=4","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-analytics","description":null,"fork":false,"url":"https://api.github.com/repos/wso2/carbon-analytics","forks_url":"https://api.github.com/repos/wso2/carbon-analytics/forks","keys_url":"https://api.github.com/repos/wso2/carbon-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-analytics/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-analytics/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-analytics/events","assignees_url":"https://api.github.com/repos/wso2/carbon-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-analytics/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-analytics/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-analytics/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-analytics/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-analytics/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-analytics/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-analytics/merges","archive_url":"https://api.github.com/repos/wso2/carbon-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-analytics/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-analytics/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-analytics/deployments","created_at":"2014-02-05T11:40:58Z","updated_at":"2018-01-08T10:27:35Z","pushed_at":"2018-03-02T16:52:26Z","git_url":"git://github.com/wso2/carbon-analytics.git","ssh_url":"git@github.com:wso2/carbon-analytics.git","clone_url":"https://github.com/wso2/carbon-analytics.git","svn_url":"https://github.com/wso2/carbon-analytics","homepage":null,"size":88619,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":118,"mirror_url":null,"archived":false,"open_issues_count":31,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":118,"open_issues":31,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170"},"html":{"href":"https://github.com/wso2/carbon-analytics/pull/1170"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-analytics/issues/1170"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-analytics/issues/1170/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-analytics/pulls/1170/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-analytics/statuses/19ddd9b3e344aeea64483c22f6cfd38712d2a57e"}},"author_association":"NONE"}}
{"actor":{"display_login":"moizalicious"}}