{"action":"created","comment":{"url":"https://api.github.com/repos/rxn1d/courses/pulls/comments/56804212","id":56804212,"diff_hunk":"@@ -0,0 +1,155 @@\n+package com.courses.spalah.dao;\n+\n+import java.io.*;\n+import java.net.URISyntaxException;\n+import java.net.URL;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import com.courses.spalah.FileReader;\n+import com.courses.spalah.domain.Person;\n+\n+/**\n+ * Implement this file. Work with DB simulation\n+ *\n+ * @author Ievgen Tararaka\n+ */\n+public class PersonDao implements Dao<Person> {\n+    FileReader fileReader;\n+    List<Person> persons;\n+    Long lastId;\n+\n+    private URL url;\n+\n+    public PersonDao(FileReader fileReader) {\n+        this.fileReader = fileReader;\n+        url = Thread.currentThread().getContextClassLoader().getResource(fileReader.getPathToFile());\n+        lastId = 0L;\n+    }\n+\n+    @Override\n+    public List<Person> findAll() {\n+        List<Person> persons = new ArrayList<>();\n+        BufferedReader data = new BufferedReader(new StringReader(fileReader.readFile()));\n+        try {\n+            while (data.ready()) {\n+                String line = data.readLine();\n+                if (line == null) break;\n+                persons.add(parseLineToPerson(line));\n+            }\n+        } catch (IOException e) {\n+            e.printStackTrace();\n+        }\n+        this.persons = persons;\n+        return persons;\n+    }\n+\n+    @Override\n+    public Person findById(Long id) {\n+        if (persons == null) {\n+            persons = findAll();\n+        }\n+        for (Person person : persons) {\n+            if (person.getId().equals(id)) return person;\n+        }\n+        System.out.println(\"Person with id = \" + id + \" don't found.\");\n+        return null;\n+    }\n+\n+    @Override\n+    public boolean update(Person entity) {\n+        Person person = findById(entity.getId());\n+        if (person != null) {\n+            int index = persons.indexOf(person);\n+            persons.remove(index);\n+            persons.add(index, entity);\n+            writePersons();\n+            return true;\n+        } else {\n+            return false;\n+        }\n+    }\n+\n+    @Override\n+    public boolean insert(Person entity) {","path":"topic10/src/main/java/com/courses/spalah/dao/PersonDao.java","position":74,"original_position":74,"commit_id":"6138368aea60c302bc0ae70a651d582db908ad28","original_commit_id":"6138368aea60c302bc0ae70a651d582db908ad28","user":{"login":"rxn1d","id":3824602,"avatar_url":"https://avatars.githubusercontent.com/u/3824602?v=3","gravatar_id":"","url":"https://api.github.com/users/rxn1d","html_url":"https://github.com/rxn1d","followers_url":"https://api.github.com/users/rxn1d/followers","following_url":"https://api.github.com/users/rxn1d/following{/other_user}","gists_url":"https://api.github.com/users/rxn1d/gists{/gist_id}","starred_url":"https://api.github.com/users/rxn1d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxn1d/subscriptions","organizations_url":"https://api.github.com/users/rxn1d/orgs","repos_url":"https://api.github.com/users/rxn1d/repos","events_url":"https://api.github.com/users/rxn1d/events{/privacy}","received_events_url":"https://api.github.com/users/rxn1d/received_events","type":"User","site_admin":false},"body":"а что будет, если попытаться вставить entity с `id` < `lastId` ?","created_at":"2016-03-21T10:45:10Z","updated_at":"2016-03-21T10:45:10Z","html_url":"https://github.com/rxn1d/courses/pull/31#discussion_r56804212","pull_request_url":"https://api.github.com/repos/rxn1d/courses/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/rxn1d/courses/pulls/comments/56804212"},"html":{"href":"https://github.com/rxn1d/courses/pull/31#discussion_r56804212"},"pull_request":{"href":"https://api.github.com/repos/rxn1d/courses/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/rxn1d/courses/pulls/31","id":63482179,"html_url":"https://github.com/rxn1d/courses/pull/31","diff_url":"https://github.com/rxn1d/courses/pull/31.diff","patch_url":"https://github.com/rxn1d/courses/pull/31.patch","issue_url":"https://api.github.com/repos/rxn1d/courses/issues/31","number":31,"state":"open","locked":false,"title":"Topic10","user":{"login":"denisko21","id":5048760,"avatar_url":"https://avatars.githubusercontent.com/u/5048760?v=3","gravatar_id":"","url":"https://api.github.com/users/denisko21","html_url":"https://github.com/denisko21","followers_url":"https://api.github.com/users/denisko21/followers","following_url":"https://api.github.com/users/denisko21/following{/other_user}","gists_url":"https://api.github.com/users/denisko21/gists{/gist_id}","starred_url":"https://api.github.com/users/denisko21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisko21/subscriptions","organizations_url":"https://api.github.com/users/denisko21/orgs","repos_url":"https://api.github.com/users/denisko21/repos","events_url":"https://api.github.com/users/denisko21/events{/privacy}","received_events_url":"https://api.github.com/users/denisko21/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-19T23:42:14Z","updated_at":"2016-03-21T10:45:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32a0aad143ae7101e9dde2ea62eaf731ab0b3aa8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rxn1d/courses/pulls/31/commits","review_comments_url":"https://api.github.com/repos/rxn1d/courses/pulls/31/comments","review_comment_url":"https://api.github.com/repos/rxn1d/courses/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rxn1d/courses/issues/31/comments","statuses_url":"https://api.github.com/repos/rxn1d/courses/statuses/6138368aea60c302bc0ae70a651d582db908ad28","head":{"label":"denisko21:master","ref":"master","sha":"6138368aea60c302bc0ae70a651d582db908ad28","user":{"login":"denisko21","id":5048760,"avatar_url":"https://avatars.githubusercontent.com/u/5048760?v=3","gravatar_id":"","url":"https://api.github.com/users/denisko21","html_url":"https://github.com/denisko21","followers_url":"https://api.github.com/users/denisko21/followers","following_url":"https://api.github.com/users/denisko21/following{/other_user}","gists_url":"https://api.github.com/users/denisko21/gists{/gist_id}","starred_url":"https://api.github.com/users/denisko21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisko21/subscriptions","organizations_url":"https://api.github.com/users/denisko21/orgs","repos_url":"https://api.github.com/users/denisko21/repos","events_url":"https://api.github.com/users/denisko21/events{/privacy}","received_events_url":"https://api.github.com/users/denisko21/received_events","type":"User","site_admin":false},"repo":{"id":52292937,"name":"courses","full_name":"denisko21/courses","owner":{"login":"denisko21","id":5048760,"avatar_url":"https://avatars.githubusercontent.com/u/5048760?v=3","gravatar_id":"","url":"https://api.github.com/users/denisko21","html_url":"https://github.com/denisko21","followers_url":"https://api.github.com/users/denisko21/followers","following_url":"https://api.github.com/users/denisko21/following{/other_user}","gists_url":"https://api.github.com/users/denisko21/gists{/gist_id}","starred_url":"https://api.github.com/users/denisko21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denisko21/subscriptions","organizations_url":"https://api.github.com/users/denisko21/orgs","repos_url":"https://api.github.com/users/denisko21/repos","events_url":"https://api.github.com/users/denisko21/events{/privacy}","received_events_url":"https://api.github.com/users/denisko21/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/denisko21/courses","description":"Java courses materials","fork":true,"url":"https://api.github.com/repos/denisko21/courses","forks_url":"https://api.github.com/repos/denisko21/courses/forks","keys_url":"https://api.github.com/repos/denisko21/courses/keys{/key_id}","collaborators_url":"https://api.github.com/repos/denisko21/courses/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/denisko21/courses/teams","hooks_url":"https://api.github.com/repos/denisko21/courses/hooks","issue_events_url":"https://api.github.com/repos/denisko21/courses/issues/events{/number}","events_url":"https://api.github.com/repos/denisko21/courses/events","assignees_url":"https://api.github.com/repos/denisko21/courses/assignees{/user}","branches_url":"https://api.github.com/repos/denisko21/courses/branches{/branch}","tags_url":"https://api.github.com/repos/denisko21/courses/tags","blobs_url":"https://api.github.com/repos/denisko21/courses/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/denisko21/courses/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/denisko21/courses/git/refs{/sha}","trees_url":"https://api.github.com/repos/denisko21/courses/git/trees{/sha}","statuses_url":"https://api.github.com/repos/denisko21/courses/statuses/{sha}","languages_url":"https://api.github.com/repos/denisko21/courses/languages","stargazers_url":"https://api.github.com/repos/denisko21/courses/stargazers","contributors_url":"https://api.github.com/repos/denisko21/courses/contributors","subscribers_url":"https://api.github.com/repos/denisko21/courses/subscribers","subscription_url":"https://api.github.com/repos/denisko21/courses/subscription","commits_url":"https://api.github.com/repos/denisko21/courses/commits{/sha}","git_commits_url":"https://api.github.com/repos/denisko21/courses/git/commits{/sha}","comments_url":"https://api.github.com/repos/denisko21/courses/comments{/number}","issue_comment_url":"https://api.github.com/repos/denisko21/courses/issues/comments{/number}","contents_url":"https://api.github.com/repos/denisko21/courses/contents/{+path}","compare_url":"https://api.github.com/repos/denisko21/courses/compare/{base}...{head}","merges_url":"https://api.github.com/repos/denisko21/courses/merges","archive_url":"https://api.github.com/repos/denisko21/courses/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/denisko21/courses/downloads","issues_url":"https://api.github.com/repos/denisko21/courses/issues{/number}","pulls_url":"https://api.github.com/repos/denisko21/courses/pulls{/number}","milestones_url":"https://api.github.com/repos/denisko21/courses/milestones{/number}","notifications_url":"https://api.github.com/repos/denisko21/courses/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/denisko21/courses/labels{/name}","releases_url":"https://api.github.com/repos/denisko21/courses/releases{/id}","deployments_url":"https://api.github.com/repos/denisko21/courses/deployments","created_at":"2016-02-22T17:52:00Z","updated_at":"2016-02-22T17:52:01Z","pushed_at":"2016-03-20T22:36:04Z","git_url":"git://github.com/denisko21/courses.git","ssh_url":"git@github.com:denisko21/courses.git","clone_url":"https://github.com/denisko21/courses.git","svn_url":"https://github.com/denisko21/courses","homepage":null,"size":243,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"rxn1d:courses/denisko21","ref":"courses/denisko21","sha":"76c99feb707bdcb263c2e02f1a0e7ce04312ba10","user":{"login":"rxn1d","id":3824602,"avatar_url":"https://avatars.githubusercontent.com/u/3824602?v=3","gravatar_id":"","url":"https://api.github.com/users/rxn1d","html_url":"https://github.com/rxn1d","followers_url":"https://api.github.com/users/rxn1d/followers","following_url":"https://api.github.com/users/rxn1d/following{/other_user}","gists_url":"https://api.github.com/users/rxn1d/gists{/gist_id}","starred_url":"https://api.github.com/users/rxn1d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxn1d/subscriptions","organizations_url":"https://api.github.com/users/rxn1d/orgs","repos_url":"https://api.github.com/users/rxn1d/repos","events_url":"https://api.github.com/users/rxn1d/events{/privacy}","received_events_url":"https://api.github.com/users/rxn1d/received_events","type":"User","site_admin":false},"repo":{"id":50372781,"name":"courses","full_name":"rxn1d/courses","owner":{"login":"rxn1d","id":3824602,"avatar_url":"https://avatars.githubusercontent.com/u/3824602?v=3","gravatar_id":"","url":"https://api.github.com/users/rxn1d","html_url":"https://github.com/rxn1d","followers_url":"https://api.github.com/users/rxn1d/followers","following_url":"https://api.github.com/users/rxn1d/following{/other_user}","gists_url":"https://api.github.com/users/rxn1d/gists{/gist_id}","starred_url":"https://api.github.com/users/rxn1d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxn1d/subscriptions","organizations_url":"https://api.github.com/users/rxn1d/orgs","repos_url":"https://api.github.com/users/rxn1d/repos","events_url":"https://api.github.com/users/rxn1d/events{/privacy}","received_events_url":"https://api.github.com/users/rxn1d/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rxn1d/courses","description":"Java courses materials","fork":false,"url":"https://api.github.com/repos/rxn1d/courses","forks_url":"https://api.github.com/repos/rxn1d/courses/forks","keys_url":"https://api.github.com/repos/rxn1d/courses/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rxn1d/courses/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rxn1d/courses/teams","hooks_url":"https://api.github.com/repos/rxn1d/courses/hooks","issue_events_url":"https://api.github.com/repos/rxn1d/courses/issues/events{/number}","events_url":"https://api.github.com/repos/rxn1d/courses/events","assignees_url":"https://api.github.com/repos/rxn1d/courses/assignees{/user}","branches_url":"https://api.github.com/repos/rxn1d/courses/branches{/branch}","tags_url":"https://api.github.com/repos/rxn1d/courses/tags","blobs_url":"https://api.github.com/repos/rxn1d/courses/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rxn1d/courses/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rxn1d/courses/git/refs{/sha}","trees_url":"https://api.github.com/repos/rxn1d/courses/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rxn1d/courses/statuses/{sha}","languages_url":"https://api.github.com/repos/rxn1d/courses/languages","stargazers_url":"https://api.github.com/repos/rxn1d/courses/stargazers","contributors_url":"https://api.github.com/repos/rxn1d/courses/contributors","subscribers_url":"https://api.github.com/repos/rxn1d/courses/subscribers","subscription_url":"https://api.github.com/repos/rxn1d/courses/subscription","commits_url":"https://api.github.com/repos/rxn1d/courses/commits{/sha}","git_commits_url":"https://api.github.com/repos/rxn1d/courses/git/commits{/sha}","comments_url":"https://api.github.com/repos/rxn1d/courses/comments{/number}","issue_comment_url":"https://api.github.com/repos/rxn1d/courses/issues/comments{/number}","contents_url":"https://api.github.com/repos/rxn1d/courses/contents/{+path}","compare_url":"https://api.github.com/repos/rxn1d/courses/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rxn1d/courses/merges","archive_url":"https://api.github.com/repos/rxn1d/courses/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rxn1d/courses/downloads","issues_url":"https://api.github.com/repos/rxn1d/courses/issues{/number}","pulls_url":"https://api.github.com/repos/rxn1d/courses/pulls{/number}","milestones_url":"https://api.github.com/repos/rxn1d/courses/milestones{/number}","notifications_url":"https://api.github.com/repos/rxn1d/courses/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rxn1d/courses/labels{/name}","releases_url":"https://api.github.com/repos/rxn1d/courses/releases{/id}","deployments_url":"https://api.github.com/repos/rxn1d/courses/deployments","created_at":"2016-01-25T18:50:28Z","updated_at":"2016-02-23T20:13:37Z","pushed_at":"2016-03-20T22:36:05Z","git_url":"git://github.com/rxn1d/courses.git","ssh_url":"git@github.com:rxn1d/courses.git","clone_url":"https://github.com/rxn1d/courses.git","svn_url":"https://github.com/rxn1d/courses","homepage":null,"size":2371,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rxn1d/courses/pulls/31"},"html":{"href":"https://github.com/rxn1d/courses/pull/31"},"issue":{"href":"https://api.github.com/repos/rxn1d/courses/issues/31"},"comments":{"href":"https://api.github.com/repos/rxn1d/courses/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/rxn1d/courses/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/rxn1d/courses/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rxn1d/courses/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/rxn1d/courses/statuses/6138368aea60c302bc0ae70a651d582db908ad28"}}}}