{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-rya/pulls/comments/135049554","pull_request_review_id":58416696,"id":135049554,"diff_hunk":"@@ -0,0 +1,80 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package org.apache.rya.rdftriplestore.inference;\n+\n+import java.util.LinkedHashSet;\n+import java.util.Set;\n+\n+import org.apache.log4j.Logger;\n+import org.apache.rya.api.RdfCloudTripleStoreConfiguration;\n+import org.openrdf.model.Resource;\n+import org.openrdf.model.URI;\n+import org.openrdf.model.vocabulary.RDF;\n+import org.openrdf.query.BindingSet;\n+import org.openrdf.query.algebra.BindingSetAssignment;\n+import org.openrdf.query.algebra.StatementPattern;\n+import org.openrdf.query.algebra.Var;\n+import org.openrdf.query.algebra.evaluation.QueryBindingSet;\n+\n+/**\n+ * Visitor for handling owl:oneOf inferencing on a node.\n+ */\n+public class OneOfVisitor extends AbstractInferVisitor {\n+    private static final Logger log = Logger.getLogger(OneOfVisitor.class);\n+\n+    /**\n+     * Creates a new instance of {@link OneOfVisitor}.\n+     * @param conf the {@link RdfCloudeTripleStoreConfiguration}.\n+     * @param inferenceEngine the {@link InferenceEngine}.\n+     */\n+    public OneOfVisitor(final RdfCloudTripleStoreConfiguration conf, final InferenceEngine inferenceEngine) {\n+        super(conf, inferenceEngine);\n+        include = conf.isInferOneOf();\n+    }\n+\n+    @Override\n+    protected void meetSP(final StatementPattern node) throws Exception {\n+        final Var subVar = node.getSubjectVar();\n+        final Var predVar = node.getPredicateVar();\n+        final Var objVar = node.getObjectVar();\n+        final Var conVar = node.getContextVar();\n+        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {\n+            final URI object = (URI) objVar.getValue();\n+            if (inferenceEngine.isEnumeratedType(object)) {\n+                final Set<BindingSet> solutions = new LinkedHashSet<>();\n+                final Set<Resource> enumeration = inferenceEngine.getEnumeration(object);\n+                if (enumeration != null && !enumeration.isEmpty()) {","path":"sail/src/main/java/org/apache/rya/rdftriplestore/inference/OneOfVisitor.java","position":62,"original_position":62,"commit_id":"cd8037618c9b24229e8cd843f51a68845d88b5de","original_commit_id":"cd8037618c9b24229e8cd843f51a68845d88b5de","user":{"login":"meiercaleb","id":7217377,"avatar_url":"https://avatars2.githubusercontent.com/u/7217377?v=4","gravatar_id":"","url":"https://api.github.com/users/meiercaleb","html_url":"https://github.com/meiercaleb","followers_url":"https://api.github.com/users/meiercaleb/followers","following_url":"https://api.github.com/users/meiercaleb/following{/other_user}","gists_url":"https://api.github.com/users/meiercaleb/gists{/gist_id}","starred_url":"https://api.github.com/users/meiercaleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meiercaleb/subscriptions","organizations_url":"https://api.github.com/users/meiercaleb/orgs","repos_url":"https://api.github.com/users/meiercaleb/repos","events_url":"https://api.github.com/users/meiercaleb/events{/privacy}","received_events_url":"https://api.github.com/users/meiercaleb/received_events","type":"User","site_admin":false},"body":"If getEnumeration returned an empty Set (if no enumerations existed), you wouldn't need this check.  Also, doesn't isEnumeratedType(...) = true -> enumeration != null?","created_at":"2017-08-24T15:32:05Z","updated_at":"2017-08-24T15:39:53Z","html_url":"https://github.com/apache/incubator-rya/pull/215#discussion_r135049554","pull_request_url":"https://api.github.com/repos/apache/incubator-rya/pulls/215","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-rya/pulls/comments/135049554"},"html":{"href":"https://github.com/apache/incubator-rya/pull/215#discussion_r135049554"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-rya/pulls/215"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-rya/pulls/215","id":137261864,"html_url":"https://github.com/apache/incubator-rya/pull/215","diff_url":"https://github.com/apache/incubator-rya/pull/215.diff","patch_url":"https://github.com/apache/incubator-rya/pull/215.patch","issue_url":"https://api.github.com/repos/apache/incubator-rya/issues/215","number":215,"state":"open","locked":false,"title":"RYA-300 Added owl:oneOf inference.","user":{"login":"ejwhite922","id":16158321,"avatar_url":"https://avatars2.githubusercontent.com/u/16158321?v=4","gravatar_id":"","url":"https://api.github.com/users/ejwhite922","html_url":"https://github.com/ejwhite922","followers_url":"https://api.github.com/users/ejwhite922/followers","following_url":"https://api.github.com/users/ejwhite922/following{/other_user}","gists_url":"https://api.github.com/users/ejwhite922/gists{/gist_id}","starred_url":"https://api.github.com/users/ejwhite922/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejwhite922/subscriptions","organizations_url":"https://api.github.com/users/ejwhite922/orgs","repos_url":"https://api.github.com/users/ejwhite922/repos","events_url":"https://api.github.com/users/ejwhite922/events{/privacy}","received_events_url":"https://api.github.com/users/ejwhite922/received_events","type":"User","site_admin":false},"body":"## Description\r\nInference applies owl:oneOf semantics for queries including statement patterns of the form \"?x rdf:type :DefinedClass\".\r\n\r\nOWL provides a construct for defining a range of data values, namely an enumerated datatype. This datatype format makes use of the owl:oneOf construct, that is also used for describing an enumerated class. In the case of an enumerated datatype, the subject of owl:oneOf is a blank node of class owl:DataRange and the object is a list of literals. Unfortunately, we cannot use the rdf:parseType=\"Collection\" idiom for specifying the literal list, because RDF requires the collection to be a list of RDF node elements. Therefore we have to specify the list of data values with the basic list constructs rdf:first, rdf:rest and rdf:nil.\r\n\r\nThe InferenceEngine, at refresh time, stores information about owl:oneOf. It stores a mapping of each type that has an enumeration. These mapped definitions can then be accessed by the method: getEnumeration(Resource).\r\n\r\nOneOfVisitor processes statement patterns of the form \"?x rdf:type :T2\", and if :T2 is the value type for any owl:oneOf restriction according to the inference engine, it replaces the statement pattern with a binding set assignment of all the enumeration items\r\n\r\nRdfCloudTripleStoreConnection calls the visitor along with the other inference logic.\r\n\r\nAdded a simple example of a query that relies on this inference to MongoRyaDirectExample.\r\n\r\n### Tests\r\nUnit tests\r\n\r\n### Links\r\n[Jira](https://issues.apache.org/jira/browse/RYA-300)\r\n\r\n### Checklist\r\n- [ ] Code Review\r\n- [ ] Squash Commits\r\n\r\n#### People To Review\r\n@jessehatfield \r\n@meiercaleb \r\n@isper3at \r\n@pujav65 ","created_at":"2017-08-23T16:23:07Z","updated_at":"2017-08-24T15:39:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c47b2d4f4e7be53beefe29ba40b9adc1005a409","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-rya/pulls/215/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-rya/pulls/215/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-rya/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-rya/issues/215/comments","statuses_url":"https://api.github.com/repos/apache/incubator-rya/statuses/cd8037618c9b24229e8cd843f51a68845d88b5de","head":{"label":"ejwhite922:RYA-300_OneOfInference","ref":"RYA-300_OneOfInference","sha":"cd8037618c9b24229e8cd843f51a68845d88b5de","user":{"login":"ejwhite922","id":16158321,"avatar_url":"https://avatars2.githubusercontent.com/u/16158321?v=4","gravatar_id":"","url":"https://api.github.com/users/ejwhite922","html_url":"https://github.com/ejwhite922","followers_url":"https://api.github.com/users/ejwhite922/followers","following_url":"https://api.github.com/users/ejwhite922/following{/other_user}","gists_url":"https://api.github.com/users/ejwhite922/gists{/gist_id}","starred_url":"https://api.github.com/users/ejwhite922/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejwhite922/subscriptions","organizations_url":"https://api.github.com/users/ejwhite922/orgs","repos_url":"https://api.github.com/users/ejwhite922/repos","events_url":"https://api.github.com/users/ejwhite922/events{/privacy}","received_events_url":"https://api.github.com/users/ejwhite922/received_events","type":"User","site_admin":false},"repo":{"id":47428209,"name":"incubator-rya","full_name":"ejwhite922/incubator-rya","owner":{"login":"ejwhite922","id":16158321,"avatar_url":"https://avatars2.githubusercontent.com/u/16158321?v=4","gravatar_id":"","url":"https://api.github.com/users/ejwhite922","html_url":"https://github.com/ejwhite922","followers_url":"https://api.github.com/users/ejwhite922/followers","following_url":"https://api.github.com/users/ejwhite922/following{/other_user}","gists_url":"https://api.github.com/users/ejwhite922/gists{/gist_id}","starred_url":"https://api.github.com/users/ejwhite922/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejwhite922/subscriptions","organizations_url":"https://api.github.com/users/ejwhite922/orgs","repos_url":"https://api.github.com/users/ejwhite922/repos","events_url":"https://api.github.com/users/ejwhite922/events{/privacy}","received_events_url":"https://api.github.com/users/ejwhite922/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ejwhite922/incubator-rya","description":"Mirror of Apache Rya (Incubating)","fork":true,"url":"https://api.github.com/repos/ejwhite922/incubator-rya","forks_url":"https://api.github.com/repos/ejwhite922/incubator-rya/forks","keys_url":"https://api.github.com/repos/ejwhite922/incubator-rya/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ejwhite922/incubator-rya/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ejwhite922/incubator-rya/teams","hooks_url":"https://api.github.com/repos/ejwhite922/incubator-rya/hooks","issue_events_url":"https://api.github.com/repos/ejwhite922/incubator-rya/issues/events{/number}","events_url":"https://api.github.com/repos/ejwhite922/incubator-rya/events","assignees_url":"https://api.github.com/repos/ejwhite922/incubator-rya/assignees{/user}","branches_url":"https://api.github.com/repos/ejwhite922/incubator-rya/branches{/branch}","tags_url":"https://api.github.com/repos/ejwhite922/incubator-rya/tags","blobs_url":"https://api.github.com/repos/ejwhite922/incubator-rya/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ejwhite922/incubator-rya/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ejwhite922/incubator-rya/git/refs{/sha}","trees_url":"https://api.github.com/repos/ejwhite922/incubator-rya/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ejwhite922/incubator-rya/statuses/{sha}","languages_url":"https://api.github.com/repos/ejwhite922/incubator-rya/languages","stargazers_url":"https://api.github.com/repos/ejwhite922/incubator-rya/stargazers","contributors_url":"https://api.github.com/repos/ejwhite922/incubator-rya/contributors","subscribers_url":"https://api.github.com/repos/ejwhite922/incubator-rya/subscribers","subscription_url":"https://api.github.com/repos/ejwhite922/incubator-rya/subscription","commits_url":"https://api.github.com/repos/ejwhite922/incubator-rya/commits{/sha}","git_commits_url":"https://api.github.com/repos/ejwhite922/incubator-rya/git/commits{/sha}","comments_url":"https://api.github.com/repos/ejwhite922/incubator-rya/comments{/number}","issue_comment_url":"https://api.github.com/repos/ejwhite922/incubator-rya/issues/comments{/number}","contents_url":"https://api.github.com/repos/ejwhite922/incubator-rya/contents/{+path}","compare_url":"https://api.github.com/repos/ejwhite922/incubator-rya/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ejwhite922/incubator-rya/merges","archive_url":"https://api.github.com/repos/ejwhite922/incubator-rya/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ejwhite922/incubator-rya/downloads","issues_url":"https://api.github.com/repos/ejwhite922/incubator-rya/issues{/number}","pulls_url":"https://api.github.com/repos/ejwhite922/incubator-rya/pulls{/number}","milestones_url":"https://api.github.com/repos/ejwhite922/incubator-rya/milestones{/number}","notifications_url":"https://api.github.com/repos/ejwhite922/incubator-rya/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ejwhite922/incubator-rya/labels{/name}","releases_url":"https://api.github.com/repos/ejwhite922/incubator-rya/releases{/id}","deployments_url":"https://api.github.com/repos/ejwhite922/incubator-rya/deployments","created_at":"2015-12-04T20:51:26Z","updated_at":"2017-08-08T14:06:39Z","pushed_at":"2017-08-23T21:37:39Z","git_url":"git://github.com/ejwhite922/incubator-rya.git","ssh_url":"git@github.com:ejwhite922/incubator-rya.git","clone_url":"https://github.com/ejwhite922/incubator-rya.git","svn_url":"https://github.com/ejwhite922/incubator-rya","homepage":null,"size":5736,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"e9488ff69f1a88300060c4010956403605cabd66","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":43734923,"name":"incubator-rya","full_name":"apache/incubator-rya","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-rya","description":"Mirror of Apache Rya (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-rya","forks_url":"https://api.github.com/repos/apache/incubator-rya/forks","keys_url":"https://api.github.com/repos/apache/incubator-rya/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-rya/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-rya/teams","hooks_url":"https://api.github.com/repos/apache/incubator-rya/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-rya/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-rya/events","assignees_url":"https://api.github.com/repos/apache/incubator-rya/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-rya/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-rya/tags","blobs_url":"https://api.github.com/repos/apache/incubator-rya/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-rya/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-rya/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-rya/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-rya/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-rya/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-rya/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-rya/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-rya/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-rya/subscription","commits_url":"https://api.github.com/repos/apache/incubator-rya/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-rya/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-rya/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-rya/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-rya/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-rya/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-rya/merges","archive_url":"https://api.github.com/repos/apache/incubator-rya/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-rya/downloads","issues_url":"https://api.github.com/repos/apache/incubator-rya/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-rya/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-rya/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-rya/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-rya/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-rya/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-rya/deployments","created_at":"2015-10-06T07:00:05Z","updated_at":"2017-08-17T16:47:29Z","pushed_at":"2017-08-24T02:13:19Z","git_url":"git://github.com/apache/incubator-rya.git","ssh_url":"git@github.com:apache/incubator-rya.git","clone_url":"https://github.com/apache/incubator-rya.git","svn_url":"https://github.com/apache/incubator-rya","homepage":null,"size":5275,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":46,"mirror_url":"git://git.apache.org/incubator-rya.git","open_issues_count":16,"forks":46,"open_issues":16,"watchers":41,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-rya/pulls/215"},"html":{"href":"https://github.com/apache/incubator-rya/pull/215"},"issue":{"href":"https://api.github.com/repos/apache/incubator-rya/issues/215"},"comments":{"href":"https://api.github.com/repos/apache/incubator-rya/issues/215/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-rya/pulls/215/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-rya/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-rya/pulls/215/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-rya/statuses/cd8037618c9b24229e8cd843f51a68845d88b5de"}}}}
{"actor":{"display_login":"meiercaleb"}}