{"action":"created","comment":{"url":"https://api.github.com/repos/owncloud/core/pulls/comments/45875723","id":45875723,"diff_hunk":"@@ -0,0 +1,241 @@\n+<?php\n+/**\n+ * @author Vincent Petry <pvince81@owncloud.com>\n+ *\n+ * @copyright Copyright (c) 2015, ownCloud, Inc.\n+ * @license AGPL-3.0\n+ *\n+ * This code is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU Affero General Public License, version 3,\n+ * as published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+ * GNU Affero General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License, version 3,\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>\n+ *\n+ */\n+\n+namespace OC\\SystemTag;\n+\n+use \\OCP\\IDBConnection;\n+use \\OCP\\SystemTag\\TagNotFoundException;\n+use \\OCP\\SystemTag\\TagAlreadyExistsException;\n+\n+use \\Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException;\n+\n+class SystemTagManager implements \\OCP\\SystemTag\\ISystemTagManager {\n+\n+\tconst TAG_TABLE = 'systemtag';\n+\n+\t/**\n+\t * @var IDBConnection\n+\t */\n+\tprivate $connection;\n+\n+\t/**\n+\t * Prepared query for selecting tags directly\n+\t *\n+\t * @var \\OCP\\DB\\QueryBuilder\\IQueryBuilder\n+\t */\n+\tprivate $selectTagQuery;\n+\n+\t/**\n+\t* Constructor.\n+\t*\n+\t* @param IDBConnection $connection database connection\n+\t*/\n+\tpublic function __construct(IDBConnection $connection) {\n+\t\t$this->connection = $connection;\n+\n+\t\t$query = $this->connection->getQueryBuilder();\n+\t\t$this->selectTagQuery = $query->select('*')\n+\t\t\t->from(self::TAG_TABLE)\n+\t\t\t->where($query->expr()->eq('name', $query->createParameter('name')))\n+\t\t\t->andWhere($query->expr()->eq('visibility', $query->createParameter('visibility')))\n+\t\t\t->andWhere($query->expr()->eq('editable', $query->createParameter('editable')));\n+\t}\n+\n+\t/**\n+\t * {%inheritdoc}\n+\t */\n+\tpublic function getTagsById($tagIds) {\n+\t\tif (!is_array($tagIds)) {\n+\t\t\t$tagIds = [$tagIds];\n+\t\t}\n+\n+\t\t$tags = [];\n+\n+\t\t$query = $this->connection->getQueryBuilder();\n+\t\t$query->select('*')\n+\t\t\t->from(self::TAG_TABLE)\n+\t\t\t->where($query->expr()->in('id', $query->createParameter('tagids')))\n+\t\t\t->addOrderBy('name', 'ASC')\n+\t\t\t->addOrderBy('visibility', 'ASC')\n+\t\t\t->addOrderBy('editable', 'ASC')\n+\t\t\t->setParameter('tagids', $tagIds, \\Doctrine\\DBAL\\Connection::PARAM_INT_ARRAY);\n+\n+\t\t$result = $query->execute();\n+\t\twhile ($row = $result->fetch()) {\n+\t\t\t$tags[] = $this->createSystemTagFromRow($row);","path":"lib/private/systemtag/systemtagmanager.php","position":83,"original_position":83,"commit_id":"9760ef1868ee4bd0f4ee72e651f2d68fd70f4a0b","original_commit_id":"9760ef1868ee4bd0f4ee72e651f2d68fd70f4a0b","user":{"login":"nickvergessen","id":213943,"avatar_url":"https://avatars.githubusercontent.com/u/213943?v=3","gravatar_id":"","url":"https://api.github.com/users/nickvergessen","html_url":"https://github.com/nickvergessen","followers_url":"https://api.github.com/users/nickvergessen/followers","following_url":"https://api.github.com/users/nickvergessen/following{/other_user}","gists_url":"https://api.github.com/users/nickvergessen/gists{/gist_id}","starred_url":"https://api.github.com/users/nickvergessen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickvergessen/subscriptions","organizations_url":"https://api.github.com/users/nickvergessen/orgs","repos_url":"https://api.github.com/users/nickvergessen/repos","events_url":"https://api.github.com/users/nickvergessen/events{/privacy}","received_events_url":"https://api.github.com/users/nickvergessen/received_events","type":"User","site_admin":false},"body":"use the `id` as key in the array, to make it easier to get the right tag?","created_at":"2015-11-25T15:00:03Z","updated_at":"2015-11-25T15:00:03Z","html_url":"https://github.com/owncloud/core/pull/20650#discussion_r45875723","pull_request_url":"https://api.github.com/repos/owncloud/core/pulls/20650","_links":{"self":{"href":"https://api.github.com/repos/owncloud/core/pulls/comments/45875723"},"html":{"href":"https://github.com/owncloud/core/pull/20650#discussion_r45875723"},"pull_request":{"href":"https://api.github.com/repos/owncloud/core/pulls/20650"}}},"pull_request":{"url":"https://api.github.com/repos/owncloud/core/pulls/20650","id":51384882,"html_url":"https://github.com/owncloud/core/pull/20650","diff_url":"https://github.com/owncloud/core/pull/20650.diff","patch_url":"https://github.com/owncloud/core/pull/20650.patch","issue_url":"https://api.github.com/repos/owncloud/core/issues/20650","number":20650,"state":"open","locked":false,"title":"[WIP] Implement systemtag managers and mapper","user":{"login":"PVince81","id":277525,"avatar_url":"https://avatars.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"body":":construction: \r\n\r\nContributes to https://github.com/owncloud/core/issues/20258 and https://github.com/owncloud/core/issues/16325\r\n\r\n- [x] db structure\r\n- [x] implement SystemTagManager\r\n- [ ] implement SystemTagObjectMapper\r\n- [x] unit test SystemTagManager\r\n- [x] unit test SystemTagObjectMapper\r\n\r\n@DeepDiver1975 @nickvergessen FYI\r\n\r\nPlease let me know if the database structure is acceptable.\r\nI can remove the indices like @blizzz did in his PR if needed.","created_at":"2015-11-20T17:33:23Z","updated_at":"2015-11-25T15:00:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e8ba690bec35d01536a12809e56eceb8ba68d0a","assignee":null,"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/48","html_url":"https://github.com/owncloud/core/milestones/9.0-current","labels_url":"https://api.github.com/repos/owncloud/core/milestones/48/labels","id":1196845,"number":48,"title":"9.0-current","description":"","creator":{"login":"cmonteroluque","id":879976,"avatar_url":"https://avatars.githubusercontent.com/u/879976?v=3","gravatar_id":"","url":"https://api.github.com/users/cmonteroluque","html_url":"https://github.com/cmonteroluque","followers_url":"https://api.github.com/users/cmonteroluque/followers","following_url":"https://api.github.com/users/cmonteroluque/following{/other_user}","gists_url":"https://api.github.com/users/cmonteroluque/gists{/gist_id}","starred_url":"https://api.github.com/users/cmonteroluque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmonteroluque/subscriptions","organizations_url":"https://api.github.com/users/cmonteroluque/orgs","repos_url":"https://api.github.com/users/cmonteroluque/repos","events_url":"https://api.github.com/users/cmonteroluque/events{/privacy}","received_events_url":"https://api.github.com/users/cmonteroluque/received_events","type":"User","site_admin":false},"open_issues":558,"closed_issues":452,"state":"open","created_at":"2015-07-07T14:21:23Z","updated_at":"2015-11-25T14:40:59Z","due_on":"2016-02-09T05:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/owncloud/core/pulls/20650/commits","review_comments_url":"https://api.github.com/repos/owncloud/core/pulls/20650/comments","review_comment_url":"https://api.github.com/repos/owncloud/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/owncloud/core/issues/20650/comments","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/9760ef1868ee4bd0f4ee72e651f2d68fd70f4a0b","head":{"label":"owncloud:systemtags-core","ref":"systemtags-core","sha":"9760ef1868ee4bd0f4ee72e651f2d68fd70f4a0b","user":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"repo":{"id":5550552,"name":"core","full_name":"owncloud/core","owner":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owncloud/core","description":"The ownCloud core","fork":false,"url":"https://api.github.com/repos/owncloud/core","forks_url":"https://api.github.com/repos/owncloud/core/forks","keys_url":"https://api.github.com/repos/owncloud/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owncloud/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owncloud/core/teams","hooks_url":"https://api.github.com/repos/owncloud/core/hooks","issue_events_url":"https://api.github.com/repos/owncloud/core/issues/events{/number}","events_url":"https://api.github.com/repos/owncloud/core/events","assignees_url":"https://api.github.com/repos/owncloud/core/assignees{/user}","branches_url":"https://api.github.com/repos/owncloud/core/branches{/branch}","tags_url":"https://api.github.com/repos/owncloud/core/tags","blobs_url":"https://api.github.com/repos/owncloud/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owncloud/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owncloud/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/owncloud/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/{sha}","languages_url":"https://api.github.com/repos/owncloud/core/languages","stargazers_url":"https://api.github.com/repos/owncloud/core/stargazers","contributors_url":"https://api.github.com/repos/owncloud/core/contributors","subscribers_url":"https://api.github.com/repos/owncloud/core/subscribers","subscription_url":"https://api.github.com/repos/owncloud/core/subscription","commits_url":"https://api.github.com/repos/owncloud/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/owncloud/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/owncloud/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/owncloud/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/owncloud/core/contents/{+path}","compare_url":"https://api.github.com/repos/owncloud/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owncloud/core/merges","archive_url":"https://api.github.com/repos/owncloud/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owncloud/core/downloads","issues_url":"https://api.github.com/repos/owncloud/core/issues{/number}","pulls_url":"https://api.github.com/repos/owncloud/core/pulls{/number}","milestones_url":"https://api.github.com/repos/owncloud/core/milestones{/number}","notifications_url":"https://api.github.com/repos/owncloud/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owncloud/core/labels{/name}","releases_url":"https://api.github.com/repos/owncloud/core/releases{/id}","created_at":"2012-08-25T10:32:48Z","updated_at":"2015-11-24T13:58:10Z","pushed_at":"2015-11-25T14:29:29Z","git_url":"git://github.com/owncloud/core.git","ssh_url":"git@github.com:owncloud/core.git","clone_url":"https://github.com/owncloud/core.git","svn_url":"https://github.com/owncloud/core","homepage":"https://owncloud.org/","size":280301,"stargazers_count":3875,"watchers_count":3875,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1238,"mirror_url":null,"open_issues_count":1808,"forks":1238,"open_issues":1808,"watchers":3875,"default_branch":"master"}},"base":{"label":"owncloud:master","ref":"master","sha":"f3ff85832356e197ff03582d8ccab729dbc6d375","user":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"repo":{"id":5550552,"name":"core","full_name":"owncloud/core","owner":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owncloud/core","description":"The ownCloud core","fork":false,"url":"https://api.github.com/repos/owncloud/core","forks_url":"https://api.github.com/repos/owncloud/core/forks","keys_url":"https://api.github.com/repos/owncloud/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owncloud/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owncloud/core/teams","hooks_url":"https://api.github.com/repos/owncloud/core/hooks","issue_events_url":"https://api.github.com/repos/owncloud/core/issues/events{/number}","events_url":"https://api.github.com/repos/owncloud/core/events","assignees_url":"https://api.github.com/repos/owncloud/core/assignees{/user}","branches_url":"https://api.github.com/repos/owncloud/core/branches{/branch}","tags_url":"https://api.github.com/repos/owncloud/core/tags","blobs_url":"https://api.github.com/repos/owncloud/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owncloud/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owncloud/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/owncloud/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/{sha}","languages_url":"https://api.github.com/repos/owncloud/core/languages","stargazers_url":"https://api.github.com/repos/owncloud/core/stargazers","contributors_url":"https://api.github.com/repos/owncloud/core/contributors","subscribers_url":"https://api.github.com/repos/owncloud/core/subscribers","subscription_url":"https://api.github.com/repos/owncloud/core/subscription","commits_url":"https://api.github.com/repos/owncloud/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/owncloud/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/owncloud/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/owncloud/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/owncloud/core/contents/{+path}","compare_url":"https://api.github.com/repos/owncloud/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owncloud/core/merges","archive_url":"https://api.github.com/repos/owncloud/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owncloud/core/downloads","issues_url":"https://api.github.com/repos/owncloud/core/issues{/number}","pulls_url":"https://api.github.com/repos/owncloud/core/pulls{/number}","milestones_url":"https://api.github.com/repos/owncloud/core/milestones{/number}","notifications_url":"https://api.github.com/repos/owncloud/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owncloud/core/labels{/name}","releases_url":"https://api.github.com/repos/owncloud/core/releases{/id}","created_at":"2012-08-25T10:32:48Z","updated_at":"2015-11-24T13:58:10Z","pushed_at":"2015-11-25T14:29:29Z","git_url":"git://github.com/owncloud/core.git","ssh_url":"git@github.com:owncloud/core.git","clone_url":"https://github.com/owncloud/core.git","svn_url":"https://github.com/owncloud/core","homepage":"https://owncloud.org/","size":280301,"stargazers_count":3875,"watchers_count":3875,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1238,"mirror_url":null,"open_issues_count":1808,"forks":1238,"open_issues":1808,"watchers":3875,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/owncloud/core/pulls/20650"},"html":{"href":"https://github.com/owncloud/core/pull/20650"},"issue":{"href":"https://api.github.com/repos/owncloud/core/issues/20650"},"comments":{"href":"https://api.github.com/repos/owncloud/core/issues/20650/comments"},"review_comments":{"href":"https://api.github.com/repos/owncloud/core/pulls/20650/comments"},"review_comment":{"href":"https://api.github.com/repos/owncloud/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/owncloud/core/pulls/20650/commits"},"statuses":{"href":"https://api.github.com/repos/owncloud/core/statuses/9760ef1868ee4bd0f4ee72e651f2d68fd70f4a0b"}}}}