{"action":"created","comment":{"url":"https://api.github.com/repos/foglamp/FogLAMP/pulls/comments/199156981","pull_request_review_id":133220780,"id":199156981,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTE1Njk4MQ==","diff_hunk":"@@ -0,0 +1,512 @@\n+/*\n+ * FogLAMP FogLAMP Configuration management.\n+ *\n+ * Copyright (c) 2018 Dianomic Systems\n+ *\n+ * Released under the Apache 2.0 Licence\n+ *\n+ * Author: Massimiliano Pinto\n+ */\n+\n+#include <configuration_manager.h>\n+#include <rapidjson/writer.h>\n+\n+using namespace std;\n+using namespace rapidjson;\n+\n+ConfigurationManager *ConfigurationManager::m_instance = 0;\n+\n+/**\n+ * Constructor\n+ *\n+ * @param host    Storage layer TCP address\n+ * @param port\t  Storage layer TCP port\n+ */\n+ConfigurationManager::ConfigurationManager(const string& host,\n+\t\t\t\t\t   unsigned short port)\n+{\n+\tm_storage = new StorageClient(host, port);\n+}\n+\n+// Destructor\n+ConfigurationManager::~ConfigurationManager()\n+{\n+\tdelete m_storage;\n+}\n+\n+/**\n+ * Return the singleton instance of the configuration manager\n+ *\n+ * @param host    Storage layer TCP address\n+ * @param port\t  Storage layer TCP port\n+ * @return        The configuration manager class instance\n+ */\n+ConfigurationManager* ConfigurationManager::getInstance(const string& host,\n+\t\t\t\t\t\t\tunsigned short port)\n+{\n+\tif (m_instance == 0)\n+\t{\n+\t\tm_instance = new ConfigurationManager(host, port);\n+\t}\n+\treturn m_instance;\n+}\n+\n+/**\n+ * Return all FogLAMP categories from storage layer\n+ *\n+ * @return\tConfigCategories class object with\n+ *\t\tkey and description for all found categories.\n+ */\n+ConfigCategories ConfigurationManager::getAllCategoryNames() const\n+{\n+\tvector<Returns *> columns;\n+\tcolumns.push_back(new Returns(\"key\"));\n+\tcolumns.push_back(new Returns(\"description\"));\n+\tQuery qAllCategories(columns);\n+\n+\t// Query via Storage client\n+\tResultSet* allCategories = m_storage->queryTable(\"configuration\", qAllCategories);\n+\n+\tConfigCategories categories;\n+\n+\tfor (ResultSet::RowIterator it = allCategories->firstRow(); ;)\n+\t{\n+\t\tResultSet::Row* row = *it;\n+\t\tif (!row)\n+\t\t{\n+\t\t\tdelete allCategories;\n+\t\t\tthrow NoSuchRowxception();\n+\t\t}\t\n+\t\tResultSet::ColumnValue* key = row->getColumn(\"key\");\n+\t\tResultSet::ColumnValue* description = row->getColumn(\"description\");\n+\n+\t\tConfigCategoryDescription *value = new ConfigCategoryDescription(key->getString(),\n+\t\t\t\t\t\t\t\t\t\t description->getString());\n+\n+\t\t// Add current row data to categories;\n+\t\tcategories.addCategoryDescription(value);\n+\t\n+\t\tif (allCategories->isLastRow(it))\n+\t\t{\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tit++;\n+\t}\n+\n+\tdelete allCategories;\n+\n+\treturn categories;\n+}\n+\n+/**\n+ * Return all the items of a specific category\n+ * from the storage layer.\n+ *\n+ * @param categoryName\tThe specified category name\n+ * @return\t\tConfigCategory calss object\n+ *\t\t\twith all category items\n+ * @throw \t\tNoSuchCategoryException\n+ * @throw\t\tException\n+ */\n+\n+ConfigCategory ConfigurationManager::getCategoryAllItems(const string& categoryName) const\n+{\n+\t// SELECT * FROM foglamp.configuration WHERE key = categoryName\n+\tconst Condition conditionKey(Equals);\n+\tWhere *wKey = new Where(\"key\", conditionKey, categoryName);\n+\tQuery qKey(wKey);\n+\n+\t// Query via storage client\n+\tResultSet* categoryItems = m_storage->queryTable(\"configuration\", qKey);\n+\n+\t// Cayegory not found\n+\tif (!categoryItems->rowCount())\n+\t{\n+\t\tdelete categoryItems;\n+\t\tthrow NoSuchCategoryException();\n+\t}\n+\n+\t// Get first row\n+\tResultSet::RowIterator it = categoryItems->firstRow();\n+\tResultSet::Row* row = *it;\n+\tif (!row)\n+\t{\n+\t\tdelete categoryItems;\n+\t\tthrow NoSuchRowxception();","path":"C/services/core/configuration_manager.cpp","position":136,"original_position":136,"commit_id":"1444276051bfc0344fcfd15ed396327a7fba7705","original_commit_id":"1444276051bfc0344fcfd15ed396327a7fba7705","user":{"login":"MarkRiddoch","id":6051869,"node_id":"MDQ6VXNlcjYwNTE4Njk=","avatar_url":"https://avatars2.githubusercontent.com/u/6051869?v=4","gravatar_id":"","url":"https://api.github.com/users/MarkRiddoch","html_url":"https://github.com/MarkRiddoch","followers_url":"https://api.github.com/users/MarkRiddoch/followers","following_url":"https://api.github.com/users/MarkRiddoch/following{/other_user}","gists_url":"https://api.github.com/users/MarkRiddoch/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkRiddoch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkRiddoch/subscriptions","organizations_url":"https://api.github.com/users/MarkRiddoch/orgs","repos_url":"https://api.github.com/users/MarkRiddoch/repos","events_url":"https://api.github.com/users/MarkRiddoch/events{/privacy}","received_events_url":"https://api.github.com/users/MarkRiddoch/received_events","type":"User","site_admin":false},"body":"As above","created_at":"2018-06-29T13:23:45Z","updated_at":"2018-06-29T13:28:43Z","html_url":"https://github.com/foglamp/FogLAMP/pull/873#discussion_r199156981","pull_request_url":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/foglamp/FogLAMP/pulls/comments/199156981"},"html":{"href":"https://github.com/foglamp/FogLAMP/pull/873#discussion_r199156981"},"pull_request":{"href":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873"}}},"pull_request":{"url":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873","id":196447881,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2NDQ3ODgx","html_url":"https://github.com/foglamp/FogLAMP/pull/873","diff_url":"https://github.com/foglamp/FogLAMP/pull/873.diff","patch_url":"https://github.com/foglamp/FogLAMP/pull/873.patch","issue_url":"https://api.github.com/repos/foglamp/FogLAMP/issues/873","number":873,"state":"open","locked":false,"title":"FOGL-1453: first implementation of ConfigurationManager","user":{"login":"pintomax","id":24681922,"node_id":"MDQ6VXNlcjI0NjgxOTIy","avatar_url":"https://avatars0.githubusercontent.com/u/24681922?v=4","gravatar_id":"","url":"https://api.github.com/users/pintomax","html_url":"https://github.com/pintomax","followers_url":"https://api.github.com/users/pintomax/followers","following_url":"https://api.github.com/users/pintomax/following{/other_user}","gists_url":"https://api.github.com/users/pintomax/gists{/gist_id}","starred_url":"https://api.github.com/users/pintomax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pintomax/subscriptions","organizations_url":"https://api.github.com/users/pintomax/orgs","repos_url":"https://api.github.com/users/pintomax/repos","events_url":"https://api.github.com/users/pintomax/events{/privacy}","received_events_url":"https://api.github.com/users/pintomax/received_events","type":"User","site_admin":false},"body":"FOGL-1453: first implementation of ConfigurationManager","created_at":"2018-06-21T13:14:24Z","updated_at":"2018-06-29T13:28:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b01a114b0ea2d0e51f1361ffe536e0cd2ad26da9","assignee":null,"assignees":[],"requested_reviewers":[{"login":"sstefano69","id":4919069,"node_id":"MDQ6VXNlcjQ5MTkwNjk=","avatar_url":"https://avatars3.githubusercontent.com/u/4919069?v=4","gravatar_id":"","url":"https://api.github.com/users/sstefano69","html_url":"https://github.com/sstefano69","followers_url":"https://api.github.com/users/sstefano69/followers","following_url":"https://api.github.com/users/sstefano69/following{/other_user}","gists_url":"https://api.github.com/users/sstefano69/gists{/gist_id}","starred_url":"https://api.github.com/users/sstefano69/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sstefano69/subscriptions","organizations_url":"https://api.github.com/users/sstefano69/orgs","repos_url":"https://api.github.com/users/sstefano69/repos","events_url":"https://api.github.com/users/sstefano69/events{/privacy}","received_events_url":"https://api.github.com/users/sstefano69/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873/commits","review_comments_url":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873/comments","review_comment_url":"https://api.github.com/repos/foglamp/FogLAMP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/foglamp/FogLAMP/issues/873/comments","statuses_url":"https://api.github.com/repos/foglamp/FogLAMP/statuses/1444276051bfc0344fcfd15ed396327a7fba7705","head":{"label":"foglamp:FOGL-1453","ref":"FOGL-1453","sha":"1444276051bfc0344fcfd15ed396327a7fba7705","user":{"login":"foglamp","id":27822234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3ODIyMjM0","avatar_url":"https://avatars0.githubusercontent.com/u/27822234?v=4","gravatar_id":"","url":"https://api.github.com/users/foglamp","html_url":"https://github.com/foglamp","followers_url":"https://api.github.com/users/foglamp/followers","following_url":"https://api.github.com/users/foglamp/following{/other_user}","gists_url":"https://api.github.com/users/foglamp/gists{/gist_id}","starred_url":"https://api.github.com/users/foglamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foglamp/subscriptions","organizations_url":"https://api.github.com/users/foglamp/orgs","repos_url":"https://api.github.com/users/foglamp/repos","events_url":"https://api.github.com/users/foglamp/events{/privacy}","received_events_url":"https://api.github.com/users/foglamp/received_events","type":"Organization","site_admin":false},"repo":{"id":88887957,"node_id":"MDEwOlJlcG9zaXRvcnk4ODg4Nzk1Nw==","name":"FogLAMP","full_name":"foglamp/FogLAMP","owner":{"login":"foglamp","id":27822234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3ODIyMjM0","avatar_url":"https://avatars0.githubusercontent.com/u/27822234?v=4","gravatar_id":"","url":"https://api.github.com/users/foglamp","html_url":"https://github.com/foglamp","followers_url":"https://api.github.com/users/foglamp/followers","following_url":"https://api.github.com/users/foglamp/following{/other_user}","gists_url":"https://api.github.com/users/foglamp/gists{/gist_id}","starred_url":"https://api.github.com/users/foglamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foglamp/subscriptions","organizations_url":"https://api.github.com/users/foglamp/orgs","repos_url":"https://api.github.com/users/foglamp/repos","events_url":"https://api.github.com/users/foglamp/events{/privacy}","received_events_url":"https://api.github.com/users/foglamp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/foglamp/FogLAMP","description":"An open source platform for the Internet of Things, it acts as an edge gateway between sensor devices and cloud storage systems","fork":false,"url":"https://api.github.com/repos/foglamp/FogLAMP","forks_url":"https://api.github.com/repos/foglamp/FogLAMP/forks","keys_url":"https://api.github.com/repos/foglamp/FogLAMP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/foglamp/FogLAMP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/foglamp/FogLAMP/teams","hooks_url":"https://api.github.com/repos/foglamp/FogLAMP/hooks","issue_events_url":"https://api.github.com/repos/foglamp/FogLAMP/issues/events{/number}","events_url":"https://api.github.com/repos/foglamp/FogLAMP/events","assignees_url":"https://api.github.com/repos/foglamp/FogLAMP/assignees{/user}","branches_url":"https://api.github.com/repos/foglamp/FogLAMP/branches{/branch}","tags_url":"https://api.github.com/repos/foglamp/FogLAMP/tags","blobs_url":"https://api.github.com/repos/foglamp/FogLAMP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/foglamp/FogLAMP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/foglamp/FogLAMP/git/refs{/sha}","trees_url":"https://api.github.com/repos/foglamp/FogLAMP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/foglamp/FogLAMP/statuses/{sha}","languages_url":"https://api.github.com/repos/foglamp/FogLAMP/languages","stargazers_url":"https://api.github.com/repos/foglamp/FogLAMP/stargazers","contributors_url":"https://api.github.com/repos/foglamp/FogLAMP/contributors","subscribers_url":"https://api.github.com/repos/foglamp/FogLAMP/subscribers","subscription_url":"https://api.github.com/repos/foglamp/FogLAMP/subscription","commits_url":"https://api.github.com/repos/foglamp/FogLAMP/commits{/sha}","git_commits_url":"https://api.github.com/repos/foglamp/FogLAMP/git/commits{/sha}","comments_url":"https://api.github.com/repos/foglamp/FogLAMP/comments{/number}","issue_comment_url":"https://api.github.com/repos/foglamp/FogLAMP/issues/comments{/number}","contents_url":"https://api.github.com/repos/foglamp/FogLAMP/contents/{+path}","compare_url":"https://api.github.com/repos/foglamp/FogLAMP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/foglamp/FogLAMP/merges","archive_url":"https://api.github.com/repos/foglamp/FogLAMP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/foglamp/FogLAMP/downloads","issues_url":"https://api.github.com/repos/foglamp/FogLAMP/issues{/number}","pulls_url":"https://api.github.com/repos/foglamp/FogLAMP/pulls{/number}","milestones_url":"https://api.github.com/repos/foglamp/FogLAMP/milestones{/number}","notifications_url":"https://api.github.com/repos/foglamp/FogLAMP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/foglamp/FogLAMP/labels{/name}","releases_url":"https://api.github.com/repos/foglamp/FogLAMP/releases{/id}","deployments_url":"https://api.github.com/repos/foglamp/FogLAMP/deployments","created_at":"2017-04-20T16:35:27Z","updated_at":"2018-06-29T13:10:26Z","pushed_at":"2018-06-29T13:23:05Z","git_url":"git://github.com/foglamp/FogLAMP.git","ssh_url":"git@github.com:foglamp/FogLAMP.git","clone_url":"https://github.com/foglamp/FogLAMP.git","svn_url":"https://github.com/foglamp/FogLAMP","homepage":"http://foglamp.readthedocs.io/","size":13330,"stargazers_count":25,"watchers_count":25,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":19,"open_issues":10,"watchers":25,"default_branch":"develop"}},"base":{"label":"foglamp:FOGL-1452","ref":"FOGL-1452","sha":"6c2ea51440e4bd1e507e3f51f1a74cf9782bbc69","user":{"login":"foglamp","id":27822234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3ODIyMjM0","avatar_url":"https://avatars0.githubusercontent.com/u/27822234?v=4","gravatar_id":"","url":"https://api.github.com/users/foglamp","html_url":"https://github.com/foglamp","followers_url":"https://api.github.com/users/foglamp/followers","following_url":"https://api.github.com/users/foglamp/following{/other_user}","gists_url":"https://api.github.com/users/foglamp/gists{/gist_id}","starred_url":"https://api.github.com/users/foglamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foglamp/subscriptions","organizations_url":"https://api.github.com/users/foglamp/orgs","repos_url":"https://api.github.com/users/foglamp/repos","events_url":"https://api.github.com/users/foglamp/events{/privacy}","received_events_url":"https://api.github.com/users/foglamp/received_events","type":"Organization","site_admin":false},"repo":{"id":88887957,"node_id":"MDEwOlJlcG9zaXRvcnk4ODg4Nzk1Nw==","name":"FogLAMP","full_name":"foglamp/FogLAMP","owner":{"login":"foglamp","id":27822234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3ODIyMjM0","avatar_url":"https://avatars0.githubusercontent.com/u/27822234?v=4","gravatar_id":"","url":"https://api.github.com/users/foglamp","html_url":"https://github.com/foglamp","followers_url":"https://api.github.com/users/foglamp/followers","following_url":"https://api.github.com/users/foglamp/following{/other_user}","gists_url":"https://api.github.com/users/foglamp/gists{/gist_id}","starred_url":"https://api.github.com/users/foglamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foglamp/subscriptions","organizations_url":"https://api.github.com/users/foglamp/orgs","repos_url":"https://api.github.com/users/foglamp/repos","events_url":"https://api.github.com/users/foglamp/events{/privacy}","received_events_url":"https://api.github.com/users/foglamp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/foglamp/FogLAMP","description":"An open source platform for the Internet of Things, it acts as an edge gateway between sensor devices and cloud storage systems","fork":false,"url":"https://api.github.com/repos/foglamp/FogLAMP","forks_url":"https://api.github.com/repos/foglamp/FogLAMP/forks","keys_url":"https://api.github.com/repos/foglamp/FogLAMP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/foglamp/FogLAMP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/foglamp/FogLAMP/teams","hooks_url":"https://api.github.com/repos/foglamp/FogLAMP/hooks","issue_events_url":"https://api.github.com/repos/foglamp/FogLAMP/issues/events{/number}","events_url":"https://api.github.com/repos/foglamp/FogLAMP/events","assignees_url":"https://api.github.com/repos/foglamp/FogLAMP/assignees{/user}","branches_url":"https://api.github.com/repos/foglamp/FogLAMP/branches{/branch}","tags_url":"https://api.github.com/repos/foglamp/FogLAMP/tags","blobs_url":"https://api.github.com/repos/foglamp/FogLAMP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/foglamp/FogLAMP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/foglamp/FogLAMP/git/refs{/sha}","trees_url":"https://api.github.com/repos/foglamp/FogLAMP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/foglamp/FogLAMP/statuses/{sha}","languages_url":"https://api.github.com/repos/foglamp/FogLAMP/languages","stargazers_url":"https://api.github.com/repos/foglamp/FogLAMP/stargazers","contributors_url":"https://api.github.com/repos/foglamp/FogLAMP/contributors","subscribers_url":"https://api.github.com/repos/foglamp/FogLAMP/subscribers","subscription_url":"https://api.github.com/repos/foglamp/FogLAMP/subscription","commits_url":"https://api.github.com/repos/foglamp/FogLAMP/commits{/sha}","git_commits_url":"https://api.github.com/repos/foglamp/FogLAMP/git/commits{/sha}","comments_url":"https://api.github.com/repos/foglamp/FogLAMP/comments{/number}","issue_comment_url":"https://api.github.com/repos/foglamp/FogLAMP/issues/comments{/number}","contents_url":"https://api.github.com/repos/foglamp/FogLAMP/contents/{+path}","compare_url":"https://api.github.com/repos/foglamp/FogLAMP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/foglamp/FogLAMP/merges","archive_url":"https://api.github.com/repos/foglamp/FogLAMP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/foglamp/FogLAMP/downloads","issues_url":"https://api.github.com/repos/foglamp/FogLAMP/issues{/number}","pulls_url":"https://api.github.com/repos/foglamp/FogLAMP/pulls{/number}","milestones_url":"https://api.github.com/repos/foglamp/FogLAMP/milestones{/number}","notifications_url":"https://api.github.com/repos/foglamp/FogLAMP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/foglamp/FogLAMP/labels{/name}","releases_url":"https://api.github.com/repos/foglamp/FogLAMP/releases{/id}","deployments_url":"https://api.github.com/repos/foglamp/FogLAMP/deployments","created_at":"2017-04-20T16:35:27Z","updated_at":"2018-06-29T13:10:26Z","pushed_at":"2018-06-29T13:23:05Z","git_url":"git://github.com/foglamp/FogLAMP.git","ssh_url":"git@github.com:foglamp/FogLAMP.git","clone_url":"https://github.com/foglamp/FogLAMP.git","svn_url":"https://github.com/foglamp/FogLAMP","homepage":"http://foglamp.readthedocs.io/","size":13330,"stargazers_count":25,"watchers_count":25,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":19,"open_issues":10,"watchers":25,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873"},"html":{"href":"https://github.com/foglamp/FogLAMP/pull/873"},"issue":{"href":"https://api.github.com/repos/foglamp/FogLAMP/issues/873"},"comments":{"href":"https://api.github.com/repos/foglamp/FogLAMP/issues/873/comments"},"review_comments":{"href":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873/comments"},"review_comment":{"href":"https://api.github.com/repos/foglamp/FogLAMP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/foglamp/FogLAMP/pulls/873/commits"},"statuses":{"href":"https://api.github.com/repos/foglamp/FogLAMP/statuses/1444276051bfc0344fcfd15ed396327a7fba7705"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"MarkRiddoch"}}