{"action":"created","comment":{"url":"https://api.github.com/repos/joelmeiller/p2p/pulls/comments/88862729","pull_request_review_id":9421243,"id":88862729,"diff_hunk":"@@ -0,0 +1,146 @@\n+package ch.fhnw.p2p.controller;\n+\n+import ch.fhnw.p2p.authorization.AccessControl;\n+import ch.fhnw.p2p.entities.Member;\n+import ch.fhnw.p2p.entities.Project;\n+import ch.fhnw.p2p.entities.Role;\n+import ch.fhnw.p2p.entities.User;\n+import ch.fhnw.p2p.repositories.MemberRepository;\n+import ch.fhnw.p2p.repositories.ProjectRepository;\n+import ch.fhnw.p2p.repositories.ProjectRepositoryImpl;\n+import ch.fhnw.p2p.repositories.UserRepository;\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.http.HttpStatus;\n+import org.springframework.http.ResponseEntity;\n+import org.springframework.validation.BindingResult;\n+import org.springframework.web.bind.annotation.*;\n+\n+import javax.persistence.EntityManager;\n+import javax.persistence.PersistenceContext;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.validation.Valid;\n+\n+import java.util.ArrayList;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Set;\n+\n+/**\n+ * REST api controller for the project list\n+ *\n+ * @author Michelle Andrey\n+ */\n+\n+@RestController\n+@CrossOrigin(origins = \"http://localhost:3000\")\n+@RequestMapping(\"/api/projects\")\n+public class ProjectController {\n+\t// ------------------------\n+\t// PRIVATE FIELDS\n+\t// ------------------------\n+\tprivate Log logger = LogFactory.getLog(this.getClass());\n+\n+\t@Autowired\n+\tprivate AccessControl accessControl;\n+\n+\t@Autowired\n+\tprivate ProjectRepository projectRepo;\n+\n+\t@Autowired\n+\tUserRepository userRepo;\n+\t\n+\t@PersistenceContext\n+\tEntityManager entityManager;\n+\n+\t// ------------------------\n+\t// PUBLIC METHODS\n+\t// ------------------------\n+\t\n+\t/**\n+\t * Fetch full project (for editing).\n+\t */\n+\t@RequestMapping(value=\"{id}\", method = RequestMethod.GET)\n+\tpublic ResponseEntity<Project> getProject(HttpServletRequest request, @PathVariable Long id) {\n+\t\tUser user = accessControl.login(request, AccessControl.Allowed.COACH);\n+\t\tlogger.info(\"GET project user=\" + user.getEmail());\n+\t\tProject project = projectRepo.findById(id);\n+\t\treturn new ResponseEntity<Project>(project, HttpStatus.OK);\n+\t}\n+\n+\t/**\n+\t * Update an existing project.\n+\t */\n+\t@RequestMapping(value=\"{id}\", method = RequestMethod.PUT)\n+\tpublic ResponseEntity<HttpStatus> updateProject(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody Project project, BindingResult result) {\n+\t\tUser user = accessControl.login(request, AccessControl.Allowed.COACH);\n+\t\tlogger.info(\"PUT project user=\" + user.getEmail());\n+\t\tif (result.hasErrors()) {\n+\t\t\treturn new ResponseEntity<HttpStatus>(HttpStatus.PRECONDITION_FAILED);\n+\t\t}\n+\t\tProject oldProject = projectRepo.findById(project.getId());\n+\t\tif (oldProject == null) {\n+\t\t\treturn new ResponseEntity<HttpStatus>(HttpStatus.NOT_FOUND);\n+\t\t}\n+\t\toldProject.setTitle(project.getTitle());\n+\t\toldProject.setStart(project.getStart());\n+\t\toldProject.setStop(project.getStop());\n+\t\toldProject.setZeitmodell(project.getZeitmodell());","path":"src/main/java/ch/fhnw/p2p/controller/ProjectController.java","position":89,"original_position":89,"commit_id":"78b446e920492dac32dee14790fc02576d1dad18","original_commit_id":"78b446e920492dac32dee14790fc02576d1dad18","user":{"login":"joelmeiller","id":11474224,"avatar_url":"https://avatars.githubusercontent.com/u/11474224?v=3","gravatar_id":"","url":"https://api.github.com/users/joelmeiller","html_url":"https://github.com/joelmeiller","followers_url":"https://api.github.com/users/joelmeiller/followers","following_url":"https://api.github.com/users/joelmeiller/following{/other_user}","gists_url":"https://api.github.com/users/joelmeiller/gists{/gist_id}","starred_url":"https://api.github.com/users/joelmeiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelmeiller/subscriptions","organizations_url":"https://api.github.com/users/joelmeiller/orgs","repos_url":"https://api.github.com/users/joelmeiller/repos","events_url":"https://api.github.com/users/joelmeiller/events{/privacy}","received_events_url":"https://api.github.com/users/joelmeiller/received_events","type":"User","site_admin":false},"body":"wiederum englisch wäre noch cool ;)","created_at":"2016-11-21T10:09:50Z","updated_at":"2016-11-21T10:09:50Z","html_url":"https://github.com/joelmeiller/p2p/pull/22#discussion_r88862729","pull_request_url":"https://api.github.com/repos/joelmeiller/p2p/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/joelmeiller/p2p/pulls/comments/88862729"},"html":{"href":"https://github.com/joelmeiller/p2p/pull/22#discussion_r88862729"},"pull_request":{"href":"https://api.github.com/repos/joelmeiller/p2p/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/joelmeiller/p2p/pulls/22","id":94487849,"html_url":"https://github.com/joelmeiller/p2p/pull/22","diff_url":"https://github.com/joelmeiller/p2p/pull/22.diff","patch_url":"https://github.com/joelmeiller/p2p/pull/22.patch","issue_url":"https://api.github.com/repos/joelmeiller/p2p/issues/22","number":22,"state":"open","locked":false,"title":"Api rest projects","user":{"login":"MizuBishi","id":14868976,"avatar_url":"https://avatars.githubusercontent.com/u/14868976?v=3","gravatar_id":"","url":"https://api.github.com/users/MizuBishi","html_url":"https://github.com/MizuBishi","followers_url":"https://api.github.com/users/MizuBishi/followers","following_url":"https://api.github.com/users/MizuBishi/following{/other_user}","gists_url":"https://api.github.com/users/MizuBishi/gists{/gist_id}","starred_url":"https://api.github.com/users/MizuBishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MizuBishi/subscriptions","organizations_url":"https://api.github.com/users/MizuBishi/orgs","repos_url":"https://api.github.com/users/MizuBishi/repos","events_url":"https://api.github.com/users/MizuBishi/events{/privacy}","received_events_url":"https://api.github.com/users/MizuBishi/received_events","type":"User","site_admin":false},"body":"Hoi Joel, ich hab mal den ProjectController gemacht. Er scheint zu funktionieren. Momentan werden noch viele Daten zurückgegeben, dort werde ich noch eine entsprechende Filterung reinnehmen müssen um dann nur die benötigten Felder zu bekommen. Was meinst Du?","created_at":"2016-11-19T17:09:30Z","updated_at":"2016-11-21T10:09:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc116e02f6909ec239e2ab17f558e2bfa7a11f0b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/joelmeiller/p2p/pulls/22/commits","review_comments_url":"https://api.github.com/repos/joelmeiller/p2p/pulls/22/comments","review_comment_url":"https://api.github.com/repos/joelmeiller/p2p/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joelmeiller/p2p/issues/22/comments","statuses_url":"https://api.github.com/repos/joelmeiller/p2p/statuses/78b446e920492dac32dee14790fc02576d1dad18","head":{"label":"joelmeiller:api-rest-projects","ref":"api-rest-projects","sha":"78b446e920492dac32dee14790fc02576d1dad18","user":{"login":"joelmeiller","id":11474224,"avatar_url":"https://avatars.githubusercontent.com/u/11474224?v=3","gravatar_id":"","url":"https://api.github.com/users/joelmeiller","html_url":"https://github.com/joelmeiller","followers_url":"https://api.github.com/users/joelmeiller/followers","following_url":"https://api.github.com/users/joelmeiller/following{/other_user}","gists_url":"https://api.github.com/users/joelmeiller/gists{/gist_id}","starred_url":"https://api.github.com/users/joelmeiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelmeiller/subscriptions","organizations_url":"https://api.github.com/users/joelmeiller/orgs","repos_url":"https://api.github.com/users/joelmeiller/repos","events_url":"https://api.github.com/users/joelmeiller/events{/privacy}","received_events_url":"https://api.github.com/users/joelmeiller/received_events","type":"User","site_admin":false},"repo":{"id":64202593,"name":"p2p","full_name":"joelmeiller/p2p","owner":{"login":"joelmeiller","id":11474224,"avatar_url":"https://avatars.githubusercontent.com/u/11474224?v=3","gravatar_id":"","url":"https://api.github.com/users/joelmeiller","html_url":"https://github.com/joelmeiller","followers_url":"https://api.github.com/users/joelmeiller/followers","following_url":"https://api.github.com/users/joelmeiller/following{/other_user}","gists_url":"https://api.github.com/users/joelmeiller/gists{/gist_id}","starred_url":"https://api.github.com/users/joelmeiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelmeiller/subscriptions","organizations_url":"https://api.github.com/users/joelmeiller/orgs","repos_url":"https://api.github.com/users/joelmeiller/repos","events_url":"https://api.github.com/users/joelmeiller/events{/privacy}","received_events_url":"https://api.github.com/users/joelmeiller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joelmeiller/p2p","description":"p2p assessment","fork":false,"url":"https://api.github.com/repos/joelmeiller/p2p","forks_url":"https://api.github.com/repos/joelmeiller/p2p/forks","keys_url":"https://api.github.com/repos/joelmeiller/p2p/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joelmeiller/p2p/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joelmeiller/p2p/teams","hooks_url":"https://api.github.com/repos/joelmeiller/p2p/hooks","issue_events_url":"https://api.github.com/repos/joelmeiller/p2p/issues/events{/number}","events_url":"https://api.github.com/repos/joelmeiller/p2p/events","assignees_url":"https://api.github.com/repos/joelmeiller/p2p/assignees{/user}","branches_url":"https://api.github.com/repos/joelmeiller/p2p/branches{/branch}","tags_url":"https://api.github.com/repos/joelmeiller/p2p/tags","blobs_url":"https://api.github.com/repos/joelmeiller/p2p/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joelmeiller/p2p/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joelmeiller/p2p/git/refs{/sha}","trees_url":"https://api.github.com/repos/joelmeiller/p2p/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joelmeiller/p2p/statuses/{sha}","languages_url":"https://api.github.com/repos/joelmeiller/p2p/languages","stargazers_url":"https://api.github.com/repos/joelmeiller/p2p/stargazers","contributors_url":"https://api.github.com/repos/joelmeiller/p2p/contributors","subscribers_url":"https://api.github.com/repos/joelmeiller/p2p/subscribers","subscription_url":"https://api.github.com/repos/joelmeiller/p2p/subscription","commits_url":"https://api.github.com/repos/joelmeiller/p2p/commits{/sha}","git_commits_url":"https://api.github.com/repos/joelmeiller/p2p/git/commits{/sha}","comments_url":"https://api.github.com/repos/joelmeiller/p2p/comments{/number}","issue_comment_url":"https://api.github.com/repos/joelmeiller/p2p/issues/comments{/number}","contents_url":"https://api.github.com/repos/joelmeiller/p2p/contents/{+path}","compare_url":"https://api.github.com/repos/joelmeiller/p2p/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joelmeiller/p2p/merges","archive_url":"https://api.github.com/repos/joelmeiller/p2p/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joelmeiller/p2p/downloads","issues_url":"https://api.github.com/repos/joelmeiller/p2p/issues{/number}","pulls_url":"https://api.github.com/repos/joelmeiller/p2p/pulls{/number}","milestones_url":"https://api.github.com/repos/joelmeiller/p2p/milestones{/number}","notifications_url":"https://api.github.com/repos/joelmeiller/p2p/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joelmeiller/p2p/labels{/name}","releases_url":"https://api.github.com/repos/joelmeiller/p2p/releases{/id}","deployments_url":"https://api.github.com/repos/joelmeiller/p2p/deployments","created_at":"2016-07-26T08:07:42Z","updated_at":"2016-07-26T09:00:00Z","pushed_at":"2016-11-21T09:25:37Z","git_url":"git://github.com/joelmeiller/p2p.git","ssh_url":"git@github.com:joelmeiller/p2p.git","clone_url":"https://github.com/joelmeiller/p2p.git","svn_url":"https://github.com/joelmeiller/p2p","homepage":null,"size":7453,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"joelmeiller:master","ref":"master","sha":"3e90b229afd1f85a887981fc34f35c674b0af56e","user":{"login":"joelmeiller","id":11474224,"avatar_url":"https://avatars.githubusercontent.com/u/11474224?v=3","gravatar_id":"","url":"https://api.github.com/users/joelmeiller","html_url":"https://github.com/joelmeiller","followers_url":"https://api.github.com/users/joelmeiller/followers","following_url":"https://api.github.com/users/joelmeiller/following{/other_user}","gists_url":"https://api.github.com/users/joelmeiller/gists{/gist_id}","starred_url":"https://api.github.com/users/joelmeiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelmeiller/subscriptions","organizations_url":"https://api.github.com/users/joelmeiller/orgs","repos_url":"https://api.github.com/users/joelmeiller/repos","events_url":"https://api.github.com/users/joelmeiller/events{/privacy}","received_events_url":"https://api.github.com/users/joelmeiller/received_events","type":"User","site_admin":false},"repo":{"id":64202593,"name":"p2p","full_name":"joelmeiller/p2p","owner":{"login":"joelmeiller","id":11474224,"avatar_url":"https://avatars.githubusercontent.com/u/11474224?v=3","gravatar_id":"","url":"https://api.github.com/users/joelmeiller","html_url":"https://github.com/joelmeiller","followers_url":"https://api.github.com/users/joelmeiller/followers","following_url":"https://api.github.com/users/joelmeiller/following{/other_user}","gists_url":"https://api.github.com/users/joelmeiller/gists{/gist_id}","starred_url":"https://api.github.com/users/joelmeiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelmeiller/subscriptions","organizations_url":"https://api.github.com/users/joelmeiller/orgs","repos_url":"https://api.github.com/users/joelmeiller/repos","events_url":"https://api.github.com/users/joelmeiller/events{/privacy}","received_events_url":"https://api.github.com/users/joelmeiller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joelmeiller/p2p","description":"p2p assessment","fork":false,"url":"https://api.github.com/repos/joelmeiller/p2p","forks_url":"https://api.github.com/repos/joelmeiller/p2p/forks","keys_url":"https://api.github.com/repos/joelmeiller/p2p/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joelmeiller/p2p/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joelmeiller/p2p/teams","hooks_url":"https://api.github.com/repos/joelmeiller/p2p/hooks","issue_events_url":"https://api.github.com/repos/joelmeiller/p2p/issues/events{/number}","events_url":"https://api.github.com/repos/joelmeiller/p2p/events","assignees_url":"https://api.github.com/repos/joelmeiller/p2p/assignees{/user}","branches_url":"https://api.github.com/repos/joelmeiller/p2p/branches{/branch}","tags_url":"https://api.github.com/repos/joelmeiller/p2p/tags","blobs_url":"https://api.github.com/repos/joelmeiller/p2p/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joelmeiller/p2p/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joelmeiller/p2p/git/refs{/sha}","trees_url":"https://api.github.com/repos/joelmeiller/p2p/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joelmeiller/p2p/statuses/{sha}","languages_url":"https://api.github.com/repos/joelmeiller/p2p/languages","stargazers_url":"https://api.github.com/repos/joelmeiller/p2p/stargazers","contributors_url":"https://api.github.com/repos/joelmeiller/p2p/contributors","subscribers_url":"https://api.github.com/repos/joelmeiller/p2p/subscribers","subscription_url":"https://api.github.com/repos/joelmeiller/p2p/subscription","commits_url":"https://api.github.com/repos/joelmeiller/p2p/commits{/sha}","git_commits_url":"https://api.github.com/repos/joelmeiller/p2p/git/commits{/sha}","comments_url":"https://api.github.com/repos/joelmeiller/p2p/comments{/number}","issue_comment_url":"https://api.github.com/repos/joelmeiller/p2p/issues/comments{/number}","contents_url":"https://api.github.com/repos/joelmeiller/p2p/contents/{+path}","compare_url":"https://api.github.com/repos/joelmeiller/p2p/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joelmeiller/p2p/merges","archive_url":"https://api.github.com/repos/joelmeiller/p2p/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joelmeiller/p2p/downloads","issues_url":"https://api.github.com/repos/joelmeiller/p2p/issues{/number}","pulls_url":"https://api.github.com/repos/joelmeiller/p2p/pulls{/number}","milestones_url":"https://api.github.com/repos/joelmeiller/p2p/milestones{/number}","notifications_url":"https://api.github.com/repos/joelmeiller/p2p/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joelmeiller/p2p/labels{/name}","releases_url":"https://api.github.com/repos/joelmeiller/p2p/releases{/id}","deployments_url":"https://api.github.com/repos/joelmeiller/p2p/deployments","created_at":"2016-07-26T08:07:42Z","updated_at":"2016-07-26T09:00:00Z","pushed_at":"2016-11-21T09:25:37Z","git_url":"git://github.com/joelmeiller/p2p.git","ssh_url":"git@github.com:joelmeiller/p2p.git","clone_url":"https://github.com/joelmeiller/p2p.git","svn_url":"https://github.com/joelmeiller/p2p","homepage":null,"size":7453,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joelmeiller/p2p/pulls/22"},"html":{"href":"https://github.com/joelmeiller/p2p/pull/22"},"issue":{"href":"https://api.github.com/repos/joelmeiller/p2p/issues/22"},"comments":{"href":"https://api.github.com/repos/joelmeiller/p2p/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/joelmeiller/p2p/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/joelmeiller/p2p/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joelmeiller/p2p/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/joelmeiller/p2p/statuses/78b446e920492dac32dee14790fc02576d1dad18"}}}}
{"actor":{"display_login":"joelmeiller"}}