{"action":"created","comment":{"url":"https://api.github.com/repos/archesproject/arches/pulls/comments/241151028","pull_request_review_id":184351446,"id":241151028,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTE1MTAyOA==","diff_hunk":"@@ -323,34 +406,93 @@ def findBranch(self, nodes, ontology_property, jsonld):\n             # try to find a node in the graph among a bunch of sibling nodes that has the same incoming edge (propertyclass) as\n             # the edge/node combination we're searching for from the json-ld graph\n             for node in nodes:\n-                if node['parent_edge'].ontologyproperty == ontology_property and node['node'].ontologyclass == jsonld_graph['@type']:\n-                    # print \"found %s\" % node['node'].name\n-                    nodes_copy.add((node['node'].name, node['node'].pk))\n-                    found.append(node)\n-                else:\n-                    invalid_nodes.add((node['node'].name, node['node'].pk))\n-                    pass\n+                # print \"node['node'].ontologyclass == jsonld_graph['@type']\"\n+                # print node['node'].ontologyclass == jsonld_graph['@type']\n+                # print node['node'].ontologyclass\n+                # print jsonld_graph\n+                if '@type' in jsonld_graph:\n+                    if node['parent_edge'].ontologyproperty == ontology_property and node['node'].ontologyclass == jsonld_graph['@type'][0]:\n+                        # print \"found %s\" % node['node'].name\n+                        nodes_copy.add((node['node'].name, node['node'].pk))\n+                        found.append(node)\n+                    else:\n+                        invalid_nodes.add((node['node'].name, node['node'].pk))\n+                        pass\n+                if '@value' in jsonld_graph:\n+                    if node['parent_edge'].ontologyproperty == ontology_property and node['node'].ontologyclass == str(RDFS.Literal):\n+                        # print node['parent_edge'].ontologyproperty == ontology_property and node['node'].ontologyclass == str(RDFS.Literal)\n+                        # print node['node'].name\n+                        # print node['node'].ontologyclass\n+                        # print node['parent_edge'].ontologyproperty\n+                        # print ontology_property\n+                        # print \"found %s\" % node['node'].name\n+                        nodes_copy.add((node['node'].name, node['node'].pk))\n+                        found.append(node)\n \n             # print 'found %s branches' % len(found)\n             if len(found) == 0:\n                 # print 'branch not found'\n                 raise self.DataDoesNotMatchGraphException()\n \n             # if len(self.findOntologyProperties(jsonld_graph)) == 0:\n-                # print 'at a leaf -- unwinding'\n-\n-            for ontology_prop in self.findOntologyProperties(jsonld_graph):\n+            # print 'at a leaf -- unwinding'\n+            \n+            def json_data_is_valid(node, json_ld_node):\n+                datatype = self.datatype_factory.get_instance(node.datatype)\n+                value = datatype.from_rdf(json_ld_node)\n+                print 'in json_data_is_valid'\n+                print datatype.validate(value)\n+                return len(datatype.validate(value)) == 0\n+\n+            if len(found) > 1:\n                 for found_node in found:\n-                    try:\n-                        # print 'now searching children of %s node' % found_node['node'].name\n-                        branch = self.findBranch(found_node['children'], ontology_prop, jsonld_graph[ontology_prop])\n-                    except self.DataDoesNotMatchGraphException as e:\n-                        found_node['remove'] = True\n-                        invalid_nodes.add((found_node['node'].name, found_node['node'].pk))\n-                    except self.AmbiguousGraphException as e:\n-                        # print 'threw AmbiguousGraphException'\n-                        # print nodes_copy\n-                        pass\n+                    # here we follow the algorithm supplied by the Getty\n+                    # If the range in the model is a domain-value, and the incoming data is of the right format and part of the domain-value's enumeration, then accept that node.\n+                    # If the range in the model is a number, string, or date, and the incoming data is of the right format, then accept that node.\n+                    # If the range in the model is a file-list, and the referenced file already exists, then accept that node.\n+                    # If the range in the model is a concept, then consider if the incoming data is a concept that is part of the collection for the node. If it is, then accept that node. If it is a concept, and not part of the collection, then fail. If it is not a concept, then continue.\n+                    for datatype in ['domain-value', 'number', 'string', 'date', 'file-list', 'concept']:\n+                        if found_node['node'].datatype == datatype and json_data_is_valid(found_node['node'], jsonld_graph):\n+                            return found_node\n+\n+                    # If the range is semantic, then check the class of the incoming node is the same \n+                    # class as the model's node. If it does, then recursively test the edges of the \n+                    # semantic node to determine if it is a candidate (peek-ahead). Remove from the \n+                    # candidate list if it is not.\n+                    if found_node['node'].datatype == 'semantic':\n+                        for ontology_prop in self.findOntologyProperties(jsonld_graph):\n+                            try:\n+                                # print 'now searching children of %s node' % found_node['node'].name\n+                                branch = self.findBranch(found_node['children'], ontology_prop, jsonld_graph[ontology_prop])\n+                            except self.DataDoesNotMatchGraphException as e:\n+                                found_node['remove'] = True\n+                                invalid_nodes.add((found_node['node'].name, found_node['node'].pk))\n+                            except self.AmbiguousGraphException as e:\n+                                # print 'threw AmbiguousGraphException'\n+                                # print nodes_copy\n+                                pass\n+\n+                    # If the range in the model is a resource-instance, then check that the incoming \n+                    # node has the same class as the top node of any of the referenced models. If more ","path":"arches/app/utils/data_management/resources/formats/rdffile.py","position":391,"original_position":391,"commit_id":"c96333599205a73acdc6995e9625ccc445db7ae0","original_commit_id":"c96333599205a73acdc6995e9625ccc445db7ae0","user":{"login":"stickler-ci","id":16011037,"node_id":"MDQ6VXNlcjE2MDExMDM3","avatar_url":"https://avatars3.githubusercontent.com/u/16011037?v=4","gravatar_id":"","url":"https://api.github.com/users/stickler-ci","html_url":"https://github.com/stickler-ci","followers_url":"https://api.github.com/users/stickler-ci/followers","following_url":"https://api.github.com/users/stickler-ci/following{/other_user}","gists_url":"https://api.github.com/users/stickler-ci/gists{/gist_id}","starred_url":"https://api.github.com/users/stickler-ci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stickler-ci/subscriptions","organizations_url":"https://api.github.com/users/stickler-ci/orgs","repos_url":"https://api.github.com/users/stickler-ci/repos","events_url":"https://api.github.com/users/stickler-ci/events{/privacy}","received_events_url":"https://api.github.com/users/stickler-ci/received_events","type":"User","site_admin":false},"body":"W291 trailing whitespace","created_at":"2018-12-12T19:20:03Z","updated_at":"2018-12-12T19:20:05Z","html_url":"https://github.com/archesproject/arches/pull/4349#discussion_r241151028","pull_request_url":"https://api.github.com/repos/archesproject/arches/pulls/4349","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/archesproject/arches/pulls/comments/241151028"},"html":{"href":"https://github.com/archesproject/arches/pull/4349#discussion_r241151028"},"pull_request":{"href":"https://api.github.com/repos/archesproject/arches/pulls/4349"}}},"pull_request":{"url":"https://api.github.com/repos/archesproject/arches/pulls/4349","id":238152517,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4MTUyNTE3","html_url":"https://github.com/archesproject/arches/pull/4349","diff_url":"https://github.com/archesproject/arches/pull/4349.diff","patch_url":"https://github.com/archesproject/arches/pull/4349.patch","issue_url":"https://api.github.com/repos/archesproject/arches/issues/4349","number":4349,"state":"open","locked":false,"title":"Benosteen 4186 jsonld export","user":{"login":"apeters","id":823773,"node_id":"MDQ6VXNlcjgyMzc3Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/823773?v=4","gravatar_id":"","url":"https://api.github.com/users/apeters","html_url":"https://github.com/apeters","followers_url":"https://api.github.com/users/apeters/followers","following_url":"https://api.github.com/users/apeters/following{/other_user}","gists_url":"https://api.github.com/users/apeters/gists{/gist_id}","starred_url":"https://api.github.com/users/apeters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apeters/subscriptions","organizations_url":"https://api.github.com/users/apeters/orgs","repos_url":"https://api.github.com/users/apeters/repos","events_url":"https://api.github.com/users/apeters/events{/privacy}","received_events_url":"https://api.github.com/users/apeters/received_events","type":"User","site_admin":false},"body":"re #4186 ","created_at":"2018-12-12T19:19:48Z","updated_at":"2018-12-12T19:20:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddd827faff321748df9d723041363e3b847dca1f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/archesproject/arches/pulls/4349/commits","review_comments_url":"https://api.github.com/repos/archesproject/arches/pulls/4349/comments","review_comment_url":"https://api.github.com/repos/archesproject/arches/pulls/comments{/number}","comments_url":"https://api.github.com/repos/archesproject/arches/issues/4349/comments","statuses_url":"https://api.github.com/repos/archesproject/arches/statuses/c96333599205a73acdc6995e9625ccc445db7ae0","head":{"label":"archesproject:benosteen-4186_jsonld_export","ref":"benosteen-4186_jsonld_export","sha":"c96333599205a73acdc6995e9625ccc445db7ae0","user":{"login":"archesproject","id":1852613,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTI2MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/1852613?v=4","gravatar_id":"","url":"https://api.github.com/users/archesproject","html_url":"https://github.com/archesproject","followers_url":"https://api.github.com/users/archesproject/followers","following_url":"https://api.github.com/users/archesproject/following{/other_user}","gists_url":"https://api.github.com/users/archesproject/gists{/gist_id}","starred_url":"https://api.github.com/users/archesproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archesproject/subscriptions","organizations_url":"https://api.github.com/users/archesproject/orgs","repos_url":"https://api.github.com/users/archesproject/repos","events_url":"https://api.github.com/users/archesproject/events{/privacy}","received_events_url":"https://api.github.com/users/archesproject/received_events","type":"Organization","site_admin":false},"repo":{"id":49451058,"node_id":"MDEwOlJlcG9zaXRvcnk0OTQ1MTA1OA==","name":"arches","full_name":"archesproject/arches","private":false,"owner":{"login":"archesproject","id":1852613,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTI2MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/1852613?v=4","gravatar_id":"","url":"https://api.github.com/users/archesproject","html_url":"https://github.com/archesproject","followers_url":"https://api.github.com/users/archesproject/followers","following_url":"https://api.github.com/users/archesproject/following{/other_user}","gists_url":"https://api.github.com/users/archesproject/gists{/gist_id}","starred_url":"https://api.github.com/users/archesproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archesproject/subscriptions","organizations_url":"https://api.github.com/users/archesproject/orgs","repos_url":"https://api.github.com/users/archesproject/repos","events_url":"https://api.github.com/users/archesproject/events{/privacy}","received_events_url":"https://api.github.com/users/archesproject/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/archesproject/arches","description":"Arches is a web platform for creating, managing, & visualizing geospatial data.  Arches was inspired by the needs of the Cultural Heritage community, particularly the widespread need of organizations to build & manage cultural heritage inventories","fork":false,"url":"https://api.github.com/repos/archesproject/arches","forks_url":"https://api.github.com/repos/archesproject/arches/forks","keys_url":"https://api.github.com/repos/archesproject/arches/keys{/key_id}","collaborators_url":"https://api.github.com/repos/archesproject/arches/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/archesproject/arches/teams","hooks_url":"https://api.github.com/repos/archesproject/arches/hooks","issue_events_url":"https://api.github.com/repos/archesproject/arches/issues/events{/number}","events_url":"https://api.github.com/repos/archesproject/arches/events","assignees_url":"https://api.github.com/repos/archesproject/arches/assignees{/user}","branches_url":"https://api.github.com/repos/archesproject/arches/branches{/branch}","tags_url":"https://api.github.com/repos/archesproject/arches/tags","blobs_url":"https://api.github.com/repos/archesproject/arches/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/archesproject/arches/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/archesproject/arches/git/refs{/sha}","trees_url":"https://api.github.com/repos/archesproject/arches/git/trees{/sha}","statuses_url":"https://api.github.com/repos/archesproject/arches/statuses/{sha}","languages_url":"https://api.github.com/repos/archesproject/arches/languages","stargazers_url":"https://api.github.com/repos/archesproject/arches/stargazers","contributors_url":"https://api.github.com/repos/archesproject/arches/contributors","subscribers_url":"https://api.github.com/repos/archesproject/arches/subscribers","subscription_url":"https://api.github.com/repos/archesproject/arches/subscription","commits_url":"https://api.github.com/repos/archesproject/arches/commits{/sha}","git_commits_url":"https://api.github.com/repos/archesproject/arches/git/commits{/sha}","comments_url":"https://api.github.com/repos/archesproject/arches/comments{/number}","issue_comment_url":"https://api.github.com/repos/archesproject/arches/issues/comments{/number}","contents_url":"https://api.github.com/repos/archesproject/arches/contents/{+path}","compare_url":"https://api.github.com/repos/archesproject/arches/compare/{base}...{head}","merges_url":"https://api.github.com/repos/archesproject/arches/merges","archive_url":"https://api.github.com/repos/archesproject/arches/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/archesproject/arches/downloads","issues_url":"https://api.github.com/repos/archesproject/arches/issues{/number}","pulls_url":"https://api.github.com/repos/archesproject/arches/pulls{/number}","milestones_url":"https://api.github.com/repos/archesproject/arches/milestones{/number}","notifications_url":"https://api.github.com/repos/archesproject/arches/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/archesproject/arches/labels{/name}","releases_url":"https://api.github.com/repos/archesproject/arches/releases{/id}","deployments_url":"https://api.github.com/repos/archesproject/arches/deployments","created_at":"2016-01-11T20:04:17Z","updated_at":"2018-12-12T18:50:51Z","pushed_at":"2018-12-12T19:19:49Z","git_url":"git://github.com/archesproject/arches.git","ssh_url":"git@github.com:archesproject/arches.git","clone_url":"https://github.com/archesproject/arches.git","svn_url":"https://github.com/archesproject/arches","homepage":"","size":144472,"stargazers_count":77,"watchers_count":77,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":447,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":56,"open_issues":447,"watchers":77,"default_branch":"master"}},"base":{"label":"archesproject:master","ref":"master","sha":"f1f997c5963d12a7d63c6765ae89d361d10ef9e1","user":{"login":"archesproject","id":1852613,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTI2MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/1852613?v=4","gravatar_id":"","url":"https://api.github.com/users/archesproject","html_url":"https://github.com/archesproject","followers_url":"https://api.github.com/users/archesproject/followers","following_url":"https://api.github.com/users/archesproject/following{/other_user}","gists_url":"https://api.github.com/users/archesproject/gists{/gist_id}","starred_url":"https://api.github.com/users/archesproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archesproject/subscriptions","organizations_url":"https://api.github.com/users/archesproject/orgs","repos_url":"https://api.github.com/users/archesproject/repos","events_url":"https://api.github.com/users/archesproject/events{/privacy}","received_events_url":"https://api.github.com/users/archesproject/received_events","type":"Organization","site_admin":false},"repo":{"id":49451058,"node_id":"MDEwOlJlcG9zaXRvcnk0OTQ1MTA1OA==","name":"arches","full_name":"archesproject/arches","private":false,"owner":{"login":"archesproject","id":1852613,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTI2MTM=","avatar_url":"https://avatars2.githubusercontent.com/u/1852613?v=4","gravatar_id":"","url":"https://api.github.com/users/archesproject","html_url":"https://github.com/archesproject","followers_url":"https://api.github.com/users/archesproject/followers","following_url":"https://api.github.com/users/archesproject/following{/other_user}","gists_url":"https://api.github.com/users/archesproject/gists{/gist_id}","starred_url":"https://api.github.com/users/archesproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archesproject/subscriptions","organizations_url":"https://api.github.com/users/archesproject/orgs","repos_url":"https://api.github.com/users/archesproject/repos","events_url":"https://api.github.com/users/archesproject/events{/privacy}","received_events_url":"https://api.github.com/users/archesproject/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/archesproject/arches","description":"Arches is a web platform for creating, managing, & visualizing geospatial data.  Arches was inspired by the needs of the Cultural Heritage community, particularly the widespread need of organizations to build & manage cultural heritage inventories","fork":false,"url":"https://api.github.com/repos/archesproject/arches","forks_url":"https://api.github.com/repos/archesproject/arches/forks","keys_url":"https://api.github.com/repos/archesproject/arches/keys{/key_id}","collaborators_url":"https://api.github.com/repos/archesproject/arches/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/archesproject/arches/teams","hooks_url":"https://api.github.com/repos/archesproject/arches/hooks","issue_events_url":"https://api.github.com/repos/archesproject/arches/issues/events{/number}","events_url":"https://api.github.com/repos/archesproject/arches/events","assignees_url":"https://api.github.com/repos/archesproject/arches/assignees{/user}","branches_url":"https://api.github.com/repos/archesproject/arches/branches{/branch}","tags_url":"https://api.github.com/repos/archesproject/arches/tags","blobs_url":"https://api.github.com/repos/archesproject/arches/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/archesproject/arches/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/archesproject/arches/git/refs{/sha}","trees_url":"https://api.github.com/repos/archesproject/arches/git/trees{/sha}","statuses_url":"https://api.github.com/repos/archesproject/arches/statuses/{sha}","languages_url":"https://api.github.com/repos/archesproject/arches/languages","stargazers_url":"https://api.github.com/repos/archesproject/arches/stargazers","contributors_url":"https://api.github.com/repos/archesproject/arches/contributors","subscribers_url":"https://api.github.com/repos/archesproject/arches/subscribers","subscription_url":"https://api.github.com/repos/archesproject/arches/subscription","commits_url":"https://api.github.com/repos/archesproject/arches/commits{/sha}","git_commits_url":"https://api.github.com/repos/archesproject/arches/git/commits{/sha}","comments_url":"https://api.github.com/repos/archesproject/arches/comments{/number}","issue_comment_url":"https://api.github.com/repos/archesproject/arches/issues/comments{/number}","contents_url":"https://api.github.com/repos/archesproject/arches/contents/{+path}","compare_url":"https://api.github.com/repos/archesproject/arches/compare/{base}...{head}","merges_url":"https://api.github.com/repos/archesproject/arches/merges","archive_url":"https://api.github.com/repos/archesproject/arches/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/archesproject/arches/downloads","issues_url":"https://api.github.com/repos/archesproject/arches/issues{/number}","pulls_url":"https://api.github.com/repos/archesproject/arches/pulls{/number}","milestones_url":"https://api.github.com/repos/archesproject/arches/milestones{/number}","notifications_url":"https://api.github.com/repos/archesproject/arches/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/archesproject/arches/labels{/name}","releases_url":"https://api.github.com/repos/archesproject/arches/releases{/id}","deployments_url":"https://api.github.com/repos/archesproject/arches/deployments","created_at":"2016-01-11T20:04:17Z","updated_at":"2018-12-12T18:50:51Z","pushed_at":"2018-12-12T19:19:49Z","git_url":"git://github.com/archesproject/arches.git","ssh_url":"git@github.com:archesproject/arches.git","clone_url":"https://github.com/archesproject/arches.git","svn_url":"https://github.com/archesproject/arches","homepage":"","size":144472,"stargazers_count":77,"watchers_count":77,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":447,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":56,"open_issues":447,"watchers":77,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/archesproject/arches/pulls/4349"},"html":{"href":"https://github.com/archesproject/arches/pull/4349"},"issue":{"href":"https://api.github.com/repos/archesproject/arches/issues/4349"},"comments":{"href":"https://api.github.com/repos/archesproject/arches/issues/4349/comments"},"review_comments":{"href":"https://api.github.com/repos/archesproject/arches/pulls/4349/comments"},"review_comment":{"href":"https://api.github.com/repos/archesproject/arches/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/archesproject/arches/pulls/4349/commits"},"statuses":{"href":"https://api.github.com/repos/archesproject/arches/statuses/c96333599205a73acdc6995e9625ccc445db7ae0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"stickler-ci"}}