{"action":"created","comment":{"url":"https://api.github.com/repos/phenotips/phenotips/pulls/comments/46724390","id":46724390,"diff_hunk":"@@ -183,4 +189,78 @@ public void writeJSON(Patient patient, JSONObject json, Collection<String> selec\n             }\n         }\n     }\n+\n+    @Override\n+    public PatientData<Map<String, String>> readJSON(JSONObject json)\n+    {\n+        Object testGeneJson = json.get(this.getJsonPropertyName());\n+        if (testGeneJson == null) {\n+            return null;\n+        }\n+\n+        try {\n+            JSONArray genesJson = json.getJSONArray(this.getJsonPropertyName());\n+            List<Map<String, String>> allGenes = new LinkedList<Map<String, String>>();\n+            for (Object geneJsonUncast : genesJson) {\n+                JSONObject geneJson = JSONObject.fromObject(geneJsonUncast);\n+                Map<String, String> singleGene = new LinkedHashMap<String, String>();\n+                for (String property : getProperties()) {\n+                    // todo. it makes no sense to have no gene name, but to have comments, which can occur\n+                    if (geneJson.has(property)) {\n+                        String field = geneJson.getString(property);\n+                        if (field != null) {\n+                            singleGene.put(property, field);\n+                        }\n+                    }\n+                }\n+                allGenes.add(singleGene);\n+            }\n+\n+            if (allGenes.isEmpty()) {\n+                return null;\n+            } else {\n+                return new IndexedPatientData<Map<String, String>>(getName(), allGenes);\n+            }\n+        } catch (Exception e) {\n+            this.logger.error(\"Could not load genes from JSON\", e.getMessage());\n+        }\n+        return null;\n+    }\n+\n+    @Override\n+    public void save(Patient patient)\n+    {\n+        try {\n+            XWikiDocument doc = (XWikiDocument) this.documentAccessBridge.getDocument(patient.getDocument());\n+            if (doc == null) {\n+                throw new NullPointerException(ERROR_MESSAGE_NO_PATIENT_CLASS);\n+            }\n+\n+            // todo. does not check for existing genes\n+            PatientData<Map<String, String>> genes = patient.getData(getName());\n+            if (!genes.isIndexed()) {\n+                return;\n+            }\n+\n+            XWikiContext context = (XWikiContext) this.execution.getContext().getProperty(\"xwikicontext\");\n+            Iterator<Map<String, String>> iterator = genes.iterator();\n+            while (iterator.hasNext()) {\n+                Map<String, String> gene = iterator.next();","path":"components/patient-data/impl/src/main/java/org/phenotips/data/internal/controller/GeneListController.java","position":87,"original_position":87,"commit_id":"7ec8f3370581d0ab282ae96109a16ccfcd0ec49e","original_commit_id":"7ec8f3370581d0ab282ae96109a16ccfcd0ec49e","user":{"login":"allasm","id":4990078,"avatar_url":"https://avatars.githubusercontent.com/u/4990078?v=3","gravatar_id":"","url":"https://api.github.com/users/allasm","html_url":"https://github.com/allasm","followers_url":"https://api.github.com/users/allasm/followers","following_url":"https://api.github.com/users/allasm/following{/other_user}","gists_url":"https://api.github.com/users/allasm/gists{/gist_id}","starred_url":"https://api.github.com/users/allasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allasm/subscriptions","organizations_url":"https://api.github.com/users/allasm/orgs","repos_url":"https://api.github.com/users/allasm/repos","events_url":"https://api.github.com/users/allasm/events{/privacy}","received_events_url":"https://api.github.com/users/allasm/received_events","type":"User","site_admin":false},"body":"As our previous struggles with items in a list show, maybe we should add a try-catch within the while(), so that we catch and omit any individual mis-formatted/broken-in-any-way genes individually, without failing the entire gene import? Genes will be a complicated entity, so we are somewhat likely to fail import of amn individual gene even if all other genes are ok?","created_at":"2015-12-04T19:51:07Z","updated_at":"2015-12-04T19:51:07Z","html_url":"https://github.com/phenotips/phenotips/pull/1945#discussion_r46724390","pull_request_url":"https://api.github.com/repos/phenotips/phenotips/pulls/1945","_links":{"self":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/comments/46724390"},"html":{"href":"https://github.com/phenotips/phenotips/pull/1945#discussion_r46724390"},"pull_request":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1945"}}},"pull_request":{"url":"https://api.github.com/repos/phenotips/phenotips/pulls/1945","id":52712174,"html_url":"https://github.com/phenotips/phenotips/pull/1945","diff_url":"https://github.com/phenotips/phenotips/pull/1945.diff","patch_url":"https://github.com/phenotips/phenotips/pull/1945.patch","issue_url":"https://api.github.com/repos/phenotips/phenotips/issues/1945","number":1945,"state":"open","locked":false,"title":"PT-2275: Add ability to import gene data","user":{"login":"antonkatz","id":3529008,"avatar_url":"https://avatars.githubusercontent.com/u/3529008?v=3","gravatar_id":"","url":"https://api.github.com/users/antonkatz","html_url":"https://github.com/antonkatz","followers_url":"https://api.github.com/users/antonkatz/followers","following_url":"https://api.github.com/users/antonkatz/following{/other_user}","gists_url":"https://api.github.com/users/antonkatz/gists{/gist_id}","starred_url":"https://api.github.com/users/antonkatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonkatz/subscriptions","organizations_url":"https://api.github.com/users/antonkatz/orgs","repos_url":"https://api.github.com/users/antonkatz/repos","events_url":"https://api.github.com/users/antonkatz/events{/privacy}","received_events_url":"https://api.github.com/users/antonkatz/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-04T19:42:57Z","updated_at":"2015-12-04T19:51:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"23a4de6e7e329aae4d7b5f56b2ed07c8d7808239","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/phenotips/phenotips/pulls/1945/commits","review_comments_url":"https://api.github.com/repos/phenotips/phenotips/pulls/1945/comments","review_comment_url":"https://api.github.com/repos/phenotips/phenotips/pulls/comments{/number}","comments_url":"https://api.github.com/repos/phenotips/phenotips/issues/1945/comments","statuses_url":"https://api.github.com/repos/phenotips/phenotips/statuses/7ec8f3370581d0ab282ae96109a16ccfcd0ec49e","head":{"label":"phenotips:pt-2275","ref":"pt-2275","sha":"7ec8f3370581d0ab282ae96109a16ccfcd0ec49e","user":{"login":"phenotips","id":4872353,"avatar_url":"https://avatars.githubusercontent.com/u/4872353?v=3","gravatar_id":"","url":"https://api.github.com/users/phenotips","html_url":"https://github.com/phenotips","followers_url":"https://api.github.com/users/phenotips/followers","following_url":"https://api.github.com/users/phenotips/following{/other_user}","gists_url":"https://api.github.com/users/phenotips/gists{/gist_id}","starred_url":"https://api.github.com/users/phenotips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phenotips/subscriptions","organizations_url":"https://api.github.com/users/phenotips/orgs","repos_url":"https://api.github.com/users/phenotips/repos","events_url":"https://api.github.com/users/phenotips/events{/privacy}","received_events_url":"https://api.github.com/users/phenotips/received_events","type":"Organization","site_admin":false},"repo":{"id":2685841,"name":"phenotips","full_name":"phenotips/phenotips","owner":{"login":"phenotips","id":4872353,"avatar_url":"https://avatars.githubusercontent.com/u/4872353?v=3","gravatar_id":"","url":"https://api.github.com/users/phenotips","html_url":"https://github.com/phenotips","followers_url":"https://api.github.com/users/phenotips/followers","following_url":"https://api.github.com/users/phenotips/following{/other_user}","gists_url":"https://api.github.com/users/phenotips/gists{/gist_id}","starred_url":"https://api.github.com/users/phenotips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phenotips/subscriptions","organizations_url":"https://api.github.com/users/phenotips/orgs","repos_url":"https://api.github.com/users/phenotips/repos","events_url":"https://api.github.com/users/phenotips/events{/privacy}","received_events_url":"https://api.github.com/users/phenotips/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phenotips/phenotips","description":"PhenoTips provides an easy-to-use Web interface and standardized database back-end for collecting clinical findings observed in patients with possible genetic disorders.","fork":false,"url":"https://api.github.com/repos/phenotips/phenotips","forks_url":"https://api.github.com/repos/phenotips/phenotips/forks","keys_url":"https://api.github.com/repos/phenotips/phenotips/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phenotips/phenotips/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phenotips/phenotips/teams","hooks_url":"https://api.github.com/repos/phenotips/phenotips/hooks","issue_events_url":"https://api.github.com/repos/phenotips/phenotips/issues/events{/number}","events_url":"https://api.github.com/repos/phenotips/phenotips/events","assignees_url":"https://api.github.com/repos/phenotips/phenotips/assignees{/user}","branches_url":"https://api.github.com/repos/phenotips/phenotips/branches{/branch}","tags_url":"https://api.github.com/repos/phenotips/phenotips/tags","blobs_url":"https://api.github.com/repos/phenotips/phenotips/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phenotips/phenotips/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phenotips/phenotips/git/refs{/sha}","trees_url":"https://api.github.com/repos/phenotips/phenotips/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phenotips/phenotips/statuses/{sha}","languages_url":"https://api.github.com/repos/phenotips/phenotips/languages","stargazers_url":"https://api.github.com/repos/phenotips/phenotips/stargazers","contributors_url":"https://api.github.com/repos/phenotips/phenotips/contributors","subscribers_url":"https://api.github.com/repos/phenotips/phenotips/subscribers","subscription_url":"https://api.github.com/repos/phenotips/phenotips/subscription","commits_url":"https://api.github.com/repos/phenotips/phenotips/commits{/sha}","git_commits_url":"https://api.github.com/repos/phenotips/phenotips/git/commits{/sha}","comments_url":"https://api.github.com/repos/phenotips/phenotips/comments{/number}","issue_comment_url":"https://api.github.com/repos/phenotips/phenotips/issues/comments{/number}","contents_url":"https://api.github.com/repos/phenotips/phenotips/contents/{+path}","compare_url":"https://api.github.com/repos/phenotips/phenotips/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phenotips/phenotips/merges","archive_url":"https://api.github.com/repos/phenotips/phenotips/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phenotips/phenotips/downloads","issues_url":"https://api.github.com/repos/phenotips/phenotips/issues{/number}","pulls_url":"https://api.github.com/repos/phenotips/phenotips/pulls{/number}","milestones_url":"https://api.github.com/repos/phenotips/phenotips/milestones{/number}","notifications_url":"https://api.github.com/repos/phenotips/phenotips/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phenotips/phenotips/labels{/name}","releases_url":"https://api.github.com/repos/phenotips/phenotips/releases{/id}","created_at":"2011-11-01T05:55:21Z","updated_at":"2015-12-03T09:51:58Z","pushed_at":"2015-12-04T19:42:57Z","git_url":"git://github.com/phenotips/phenotips.git","ssh_url":"git@github.com:phenotips/phenotips.git","clone_url":"https://github.com/phenotips/phenotips.git","svn_url":"https://github.com/phenotips/phenotips","homepage":"http://phenotips.org/","size":808268,"stargazers_count":24,"watchers_count":24,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":294,"forks":15,"open_issues":294,"watchers":24,"default_branch":"master"}},"base":{"label":"phenotips:master","ref":"master","sha":"c5264633fb2a1133049ae917faa19347f83ad7d7","user":{"login":"phenotips","id":4872353,"avatar_url":"https://avatars.githubusercontent.com/u/4872353?v=3","gravatar_id":"","url":"https://api.github.com/users/phenotips","html_url":"https://github.com/phenotips","followers_url":"https://api.github.com/users/phenotips/followers","following_url":"https://api.github.com/users/phenotips/following{/other_user}","gists_url":"https://api.github.com/users/phenotips/gists{/gist_id}","starred_url":"https://api.github.com/users/phenotips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phenotips/subscriptions","organizations_url":"https://api.github.com/users/phenotips/orgs","repos_url":"https://api.github.com/users/phenotips/repos","events_url":"https://api.github.com/users/phenotips/events{/privacy}","received_events_url":"https://api.github.com/users/phenotips/received_events","type":"Organization","site_admin":false},"repo":{"id":2685841,"name":"phenotips","full_name":"phenotips/phenotips","owner":{"login":"phenotips","id":4872353,"avatar_url":"https://avatars.githubusercontent.com/u/4872353?v=3","gravatar_id":"","url":"https://api.github.com/users/phenotips","html_url":"https://github.com/phenotips","followers_url":"https://api.github.com/users/phenotips/followers","following_url":"https://api.github.com/users/phenotips/following{/other_user}","gists_url":"https://api.github.com/users/phenotips/gists{/gist_id}","starred_url":"https://api.github.com/users/phenotips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phenotips/subscriptions","organizations_url":"https://api.github.com/users/phenotips/orgs","repos_url":"https://api.github.com/users/phenotips/repos","events_url":"https://api.github.com/users/phenotips/events{/privacy}","received_events_url":"https://api.github.com/users/phenotips/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phenotips/phenotips","description":"PhenoTips provides an easy-to-use Web interface and standardized database back-end for collecting clinical findings observed in patients with possible genetic disorders.","fork":false,"url":"https://api.github.com/repos/phenotips/phenotips","forks_url":"https://api.github.com/repos/phenotips/phenotips/forks","keys_url":"https://api.github.com/repos/phenotips/phenotips/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phenotips/phenotips/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phenotips/phenotips/teams","hooks_url":"https://api.github.com/repos/phenotips/phenotips/hooks","issue_events_url":"https://api.github.com/repos/phenotips/phenotips/issues/events{/number}","events_url":"https://api.github.com/repos/phenotips/phenotips/events","assignees_url":"https://api.github.com/repos/phenotips/phenotips/assignees{/user}","branches_url":"https://api.github.com/repos/phenotips/phenotips/branches{/branch}","tags_url":"https://api.github.com/repos/phenotips/phenotips/tags","blobs_url":"https://api.github.com/repos/phenotips/phenotips/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phenotips/phenotips/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phenotips/phenotips/git/refs{/sha}","trees_url":"https://api.github.com/repos/phenotips/phenotips/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phenotips/phenotips/statuses/{sha}","languages_url":"https://api.github.com/repos/phenotips/phenotips/languages","stargazers_url":"https://api.github.com/repos/phenotips/phenotips/stargazers","contributors_url":"https://api.github.com/repos/phenotips/phenotips/contributors","subscribers_url":"https://api.github.com/repos/phenotips/phenotips/subscribers","subscription_url":"https://api.github.com/repos/phenotips/phenotips/subscription","commits_url":"https://api.github.com/repos/phenotips/phenotips/commits{/sha}","git_commits_url":"https://api.github.com/repos/phenotips/phenotips/git/commits{/sha}","comments_url":"https://api.github.com/repos/phenotips/phenotips/comments{/number}","issue_comment_url":"https://api.github.com/repos/phenotips/phenotips/issues/comments{/number}","contents_url":"https://api.github.com/repos/phenotips/phenotips/contents/{+path}","compare_url":"https://api.github.com/repos/phenotips/phenotips/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phenotips/phenotips/merges","archive_url":"https://api.github.com/repos/phenotips/phenotips/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phenotips/phenotips/downloads","issues_url":"https://api.github.com/repos/phenotips/phenotips/issues{/number}","pulls_url":"https://api.github.com/repos/phenotips/phenotips/pulls{/number}","milestones_url":"https://api.github.com/repos/phenotips/phenotips/milestones{/number}","notifications_url":"https://api.github.com/repos/phenotips/phenotips/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phenotips/phenotips/labels{/name}","releases_url":"https://api.github.com/repos/phenotips/phenotips/releases{/id}","created_at":"2011-11-01T05:55:21Z","updated_at":"2015-12-03T09:51:58Z","pushed_at":"2015-12-04T19:42:57Z","git_url":"git://github.com/phenotips/phenotips.git","ssh_url":"git@github.com:phenotips/phenotips.git","clone_url":"https://github.com/phenotips/phenotips.git","svn_url":"https://github.com/phenotips/phenotips","homepage":"http://phenotips.org/","size":808268,"stargazers_count":24,"watchers_count":24,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":294,"forks":15,"open_issues":294,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1945"},"html":{"href":"https://github.com/phenotips/phenotips/pull/1945"},"issue":{"href":"https://api.github.com/repos/phenotips/phenotips/issues/1945"},"comments":{"href":"https://api.github.com/repos/phenotips/phenotips/issues/1945/comments"},"review_comments":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1945/comments"},"review_comment":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1945/commits"},"statuses":{"href":"https://api.github.com/repos/phenotips/phenotips/statuses/7ec8f3370581d0ab282ae96109a16ccfcd0ec49e"}}}}