{"action":"created","comment":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/59360975","id":59360975,"diff_hunk":"@@ -0,0 +1,422 @@\n+/**\n+ * Copyright 2016 IBM Corp.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain 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+module.exports = function (RED) {\n+  var request = require('request');\n+  var cfenv = require('cfenv');\n+  var watson = require('watson-developer-cloud');\n+\n+  var username, password;\n+  var service = cfenv.getAppEnv().getServiceCreds(/concept insights/i);\n+\n+  if (service) {\n+    username = service.username;\n+    password = service.password;\n+  }\n+\n+  RED.httpAdmin.get('/watson-concept-insights/vcap', function (req, res) {\n+    res.json(service ? {bound_service: true} : null);\n+  });\n+\n+  function CorpusConfigurationNode(config) {\n+    RED.nodes.createNode(this,config);\n+    this.cname = config.cname;\n+    this.access = config.access;\n+    this.publiccorpus = config.publiccorpus;\n+  }\n+\n+  RED.nodes.registerType(\"watson-concept-insights-corpus\", CorpusConfigurationNode);\n+\n+  function searchNode(config) {\n+    RED.nodes.createNode(this, config);\n+    var node = this;\n+\n+    this.on('input', function(msg) {\n+      setupConceptInsightsNode(msg,config,this,function(concept_insights,account_id) {\n+        this.corpus = RED.nodes.getNode(config.corpus);\n+        \n+        if (this.corpus) {\n+          var corpus_name;\n+          if (this.corpus.cname) {\n+            corpus_name = this.corpus.cname;\n+          } else {\n+            console.log(this.corpus);\n+            corpus_name = this.corpus.publiccorpus;\n+            account_id = 'public';\n+          }        \n+          var document_name = config.docname;\n+\n+          node.status({fill:\"blue\",shape:\"ring\",text:\"requesting...\"});\n+\n+          //Check for document or corpus mode\n+          if (config.mode === 'document') {\n+\n+            if (!document_name) {\n+              node.status({});\n+              var message = 'No document name specified';\n+              return node.error(message, msg);\n+            }\n+\n+            var params = {\n+              id: '/corpora/'+account_id+'/'+corpus_name+'/documents/'+document_name\n+            }\n+\n+            switch (config.docapicall) {\n+              case 'annotations':\n+                params.id = params.id+'/annotations';\n+                concept_insights.corpora.getDocumentAnnotations(params, function(err,res) {\n+                  handleWatsonCallback(node,msg,err,res);\n+                });\n+                break;\n+\n+              case 'relatedconcepts':\n+                concept_insights.corpora.getRelatedConcepts(params, function(err,res) {\n+                  handleWatsonCallback(node,msg,err,res);\n+                });\n+                break;\n+\n+              case 'relationscores':\n+              params.concepts = msg.concepts;\n+                concept_insights.corpora.getRelationScores(params, function(err,res) {\n+                  handleWatsonCallback(node,msg,err,res);\n+                });\n+                break;\n+            }\n+          } else {\n+            //Corpus mode\n+            var params = {\n+              corpus: '/corpora/'+account_id+'/'+corpus_name\n+            }\n+            switch (config.corpusapicall) {\n+              case 'statistics':\n+                concept_insights.corpora.getCorpusStats(params, function(err,res) {\n+                  handleWatsonCallback(node,msg,err,res);\n+                });\n+                break;\n+\n+              case 'relatedconcepts':\n+                concept_insights.corpora.getRelatedConcepts(params, function(err,res) {\n+                  handleWatsonCallback(node,msg,err,res);\n+                });\n+                break;\n+\n+              case 'relationscores':\n+                params.concepts = msg.concepts;\n+                concept_insights.corpora.getRelationScores(params, function(err,res) {\n+                  handleWatsonCallback(node,msg,err,res);\n+                });\n+                break;\n+\n+              case 'conceptualsearch':\n+                if (msg.concepts) {\n+                  params.ids = msg.concepts;\n+                  concept_insights.corpora.getRelatedDocuments(params, function(err,res) {\n+                    handleWatsonCallback(node,msg,err,res);\n+                  });\n+                } else {\n+                  node.status({});\n+                  var message = 'No concepts exist on the msg object';","path":"services/concept_insights/ci.js","position":131,"original_position":131,"commit_id":"48d92d70fc7575d5f12a9938337335c8c294d392","original_commit_id":"48d92d70fc7575d5f12a9938337335c8c294d392","user":{"login":"yrezgui","id":1113976,"avatar_url":"https://avatars.githubusercontent.com/u/1113976?v=3","gravatar_id":"","url":"https://api.github.com/users/yrezgui","html_url":"https://github.com/yrezgui","followers_url":"https://api.github.com/users/yrezgui/followers","following_url":"https://api.github.com/users/yrezgui/following{/other_user}","gists_url":"https://api.github.com/users/yrezgui/gists{/gist_id}","starred_url":"https://api.github.com/users/yrezgui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yrezgui/subscriptions","organizations_url":"https://api.github.com/users/yrezgui/orgs","repos_url":"https://api.github.com/users/yrezgui/repos","events_url":"https://api.github.com/users/yrezgui/events{/privacy}","received_events_url":"https://api.github.com/users/yrezgui/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Variable 'message' is already declared in line 69.](https://www.codacy.com/app/rezgui-y/node-red-node-watson/file/2392377031/issues/source?bid=3225115&fileBranchId=3228814#l131)","created_at":"2016-04-12T11:39:28Z","updated_at":"2016-04-12T11:39:28Z","html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/14#discussion_r59360975","pull_request_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/59360975"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/14#discussion_r59360975"},"pull_request":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14","id":66055107,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/14","diff_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/14.diff","patch_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/14.patch","issue_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/14","number":14,"state":"open","locked":false,"title":"Concept insights dev","user":{"login":"DanCunnington","id":5956283,"avatar_url":"https://avatars.githubusercontent.com/u/5956283?v=3","gravatar_id":"","url":"https://api.github.com/users/DanCunnington","html_url":"https://github.com/DanCunnington","followers_url":"https://api.github.com/users/DanCunnington/followers","following_url":"https://api.github.com/users/DanCunnington/following{/other_user}","gists_url":"https://api.github.com/users/DanCunnington/gists{/gist_id}","starred_url":"https://api.github.com/users/DanCunnington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanCunnington/subscriptions","organizations_url":"https://api.github.com/users/DanCunnington/orgs","repos_url":"https://api.github.com/users/DanCunnington/repos","events_url":"https://api.github.com/users/DanCunnington/events{/privacy}","received_events_url":"https://api.github.com/users/DanCunnington/received_events","type":"User","site_admin":false},"body":"First code drop of concept insights node","created_at":"2016-04-11T20:16:29Z","updated_at":"2016-04-12T11:39:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41b8b2955b6308668a826c658e03c09e8009f74e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14/commits","review_comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14/comments","review_comment_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/14/comments","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/48d92d70fc7575d5f12a9938337335c8c294d392","head":{"label":"DanCunnington:concept-insights-dev","ref":"concept-insights-dev","sha":"48d92d70fc7575d5f12a9938337335c8c294d392","user":{"login":"DanCunnington","id":5956283,"avatar_url":"https://avatars.githubusercontent.com/u/5956283?v=3","gravatar_id":"","url":"https://api.github.com/users/DanCunnington","html_url":"https://github.com/DanCunnington","followers_url":"https://api.github.com/users/DanCunnington/followers","following_url":"https://api.github.com/users/DanCunnington/following{/other_user}","gists_url":"https://api.github.com/users/DanCunnington/gists{/gist_id}","starred_url":"https://api.github.com/users/DanCunnington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanCunnington/subscriptions","organizations_url":"https://api.github.com/users/DanCunnington/orgs","repos_url":"https://api.github.com/users/DanCunnington/repos","events_url":"https://api.github.com/users/DanCunnington/events{/privacy}","received_events_url":"https://api.github.com/users/DanCunnington/received_events","type":"User","site_admin":false},"repo":{"id":55425684,"name":"node-red-node-watson","full_name":"DanCunnington/node-red-node-watson","owner":{"login":"DanCunnington","id":5956283,"avatar_url":"https://avatars.githubusercontent.com/u/5956283?v=3","gravatar_id":"","url":"https://api.github.com/users/DanCunnington","html_url":"https://github.com/DanCunnington","followers_url":"https://api.github.com/users/DanCunnington/followers","following_url":"https://api.github.com/users/DanCunnington/following{/other_user}","gists_url":"https://api.github.com/users/DanCunnington/gists{/gist_id}","starred_url":"https://api.github.com/users/DanCunnington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanCunnington/subscriptions","organizations_url":"https://api.github.com/users/DanCunnington/orgs","repos_url":"https://api.github.com/users/DanCunnington/repos","events_url":"https://api.github.com/users/DanCunnington/events{/privacy}","received_events_url":"https://api.github.com/users/DanCunnington/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DanCunnington/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":true,"url":"https://api.github.com/repos/DanCunnington/node-red-node-watson","forks_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/DanCunnington/node-red-node-watson/deployments","created_at":"2016-04-04T16:07:49Z","updated_at":"2016-04-04T16:07:51Z","pushed_at":"2016-04-11T20:15:40Z","git_url":"git://github.com/DanCunnington/node-red-node-watson.git","ssh_url":"git@github.com:DanCunnington/node-red-node-watson.git","clone_url":"https://github.com/DanCunnington/node-red-node-watson.git","svn_url":"https://github.com/DanCunnington/node-red-node-watson","homepage":null,"size":67,"stargazers_count":0,"watchers_count":0,"language":"HTML","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":"watson-developer-cloud:master","ref":"master","sha":"16458d4769f5ad59e32972eaa83d3f537343b904","user":{"login":"watson-developer-cloud","id":10017763,"avatar_url":"https://avatars.githubusercontent.com/u/10017763?v=3","gravatar_id":"","url":"https://api.github.com/users/watson-developer-cloud","html_url":"https://github.com/watson-developer-cloud","followers_url":"https://api.github.com/users/watson-developer-cloud/followers","following_url":"https://api.github.com/users/watson-developer-cloud/following{/other_user}","gists_url":"https://api.github.com/users/watson-developer-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/watson-developer-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watson-developer-cloud/subscriptions","organizations_url":"https://api.github.com/users/watson-developer-cloud/orgs","repos_url":"https://api.github.com/users/watson-developer-cloud/repos","events_url":"https://api.github.com/users/watson-developer-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/watson-developer-cloud/received_events","type":"Organization","site_admin":false},"repo":{"id":55415107,"name":"node-red-node-watson","full_name":"watson-developer-cloud/node-red-node-watson","owner":{"login":"watson-developer-cloud","id":10017763,"avatar_url":"https://avatars.githubusercontent.com/u/10017763?v=3","gravatar_id":"","url":"https://api.github.com/users/watson-developer-cloud","html_url":"https://github.com/watson-developer-cloud","followers_url":"https://api.github.com/users/watson-developer-cloud/followers","following_url":"https://api.github.com/users/watson-developer-cloud/following{/other_user}","gists_url":"https://api.github.com/users/watson-developer-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/watson-developer-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watson-developer-cloud/subscriptions","organizations_url":"https://api.github.com/users/watson-developer-cloud/orgs","repos_url":"https://api.github.com/users/watson-developer-cloud/repos","events_url":"https://api.github.com/users/watson-developer-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/watson-developer-cloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":true,"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson","forks_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/deployments","created_at":"2016-04-04T13:51:28Z","updated_at":"2016-04-11T13:49:32Z","pushed_at":"2016-04-12T10:53:45Z","git_url":"git://github.com/watson-developer-cloud/node-red-node-watson.git","ssh_url":"git@github.com:watson-developer-cloud/node-red-node-watson.git","clone_url":"https://github.com/watson-developer-cloud/node-red-node-watson.git","svn_url":"https://github.com/watson-developer-cloud/node-red-node-watson","homepage":null,"size":4538,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":3,"forks":5,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/14"},"issue":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/14"},"comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/48d92d70fc7575d5f12a9938337335c8c294d392"}}}}