{"action":"created","issue":{"url":"https://api.github.com/repos/owlcs/owlapi/issues/580","repository_url":"https://api.github.com/repos/owlcs/owlapi","labels_url":"https://api.github.com/repos/owlcs/owlapi/issues/580/labels{/name}","comments_url":"https://api.github.com/repos/owlcs/owlapi/issues/580/comments","events_url":"https://api.github.com/repos/owlcs/owlapi/issues/580/events","html_url":"https://github.com/owlcs/owlapi/issues/580","id":191737893,"number":580,"title":"Imports not properly loaded after all ontologies removed","user":{"login":"ykazakov","id":2140361,"avatar_url":"https://avatars.githubusercontent.com/u/2140361?v=3","gravatar_id":"","url":"https://api.github.com/users/ykazakov","html_url":"https://github.com/ykazakov","followers_url":"https://api.github.com/users/ykazakov/followers","following_url":"https://api.github.com/users/ykazakov/following{/other_user}","gists_url":"https://api.github.com/users/ykazakov/gists{/gist_id}","starred_url":"https://api.github.com/users/ykazakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ykazakov/subscriptions","organizations_url":"https://api.github.com/users/ykazakov/orgs","repos_url":"https://api.github.com/users/ykazakov/repos","events_url":"https://api.github.com/users/ykazakov/events{/privacy}","received_events_url":"https://api.github.com/users/ykazakov/received_events","type":"User","site_admin":false},"labels":[{"id":28720594,"url":"https://api.github.com/repos/owlcs/owlapi/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-11-25T16:41:21Z","updated_at":"2016-12-07T23:42:12Z","closed_at":null,"body":"Create a test Java project and place these two ontologies into the resources folder:\r\n\r\n`A.owl`:\r\n```owl\r\nPrefix(owl:=<http://www.w3.org/2002/07/owl#>)\r\nPrefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)\r\nPrefix(xml:=<http://www.w3.org/XML/1998/namespace>)\r\nPrefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\r\nPrefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)\r\nPrefix(:=<http://www.example.com#>)\r\n\r\nOntology(<http://www.example.com#A>\r\n\r\nImport(<http://www.example.com#B>)\r\n\r\nSubClassOf(:A :B) # <= any axiom is OK\r\n\r\n)\r\n```\r\n\r\n`B.owl`:\r\n\r\n```owl\r\nPrefix(owl:=<http://www.w3.org/2002/07/owl#>)\r\nPrefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)\r\nPrefix(xml:=<http://www.w3.org/XML/1998/namespace>)\r\nPrefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\r\nPrefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)\r\nPrefix(:=<http://www.example.com#>)\r\n\r\nOntology(<http://www.example.com#B>\r\n\r\nSubClassOf(:B :C) # <= any axiom is OK\r\n\r\n)\r\n```\r\n\r\nThe following test fails for me with OWLAPI 4.2.7 :\r\n\r\n```java\r\nimport static org.junit.Assert.assertEquals;\r\n\r\nimport java.io.File;\r\nimport java.net.URI;\r\nimport java.net.URISyntaxException;\r\nimport java.util.Collections;\r\n\r\nimport org.junit.Test;\r\nimport org.semanticweb.owlapi.apibinding.OWLManager;\r\nimport org.semanticweb.owlapi.model.IRI;\r\nimport org.semanticweb.owlapi.model.OWLOntology;\r\nimport org.semanticweb.owlapi.model.OWLOntologyCreationException;\r\nimport org.semanticweb.owlapi.model.OWLOntologyIRIMapper;\r\nimport org.semanticweb.owlapi.model.OWLOntologyManager;\r\n\r\npublic class TestImports {\r\n\r\n\t@Test\r\n\tpublic void testImports() throws Exception {\r\n\t\tOWLOntologyManager man = OWLManager.createOWLOntologyManager();\r\n\t\tOWLOntology root = loadOntology(man, \"A.owl\");\r\n\t\tassertEquals(1, root.getImports().size()); // <= OK\r\n\t\tfor (OWLOntology ontology : man.getOntologies()) {\r\n\t\t\tman.removeOntology(ontology);\r\n\t\t}\r\n\t\tassertEquals(0, man.getOntologies().size()); // <= no ontologies left!\r\n\t\troot = loadOntology(man, \"A.owl\");\r\n\t\tassertEquals(1, root.getImports().size()); // <= FAIL!\r\n\t}\r\n\r\n\tprivate OWLOntology loadOntology(OWLOntologyManager man, String name)\r\n\t\t\tthrows URISyntaxException, OWLOntologyCreationException {\r\n\r\n\t\tfinal URI ontologyRoot = getClass().getClassLoader().getResource(\"\")\r\n\t\t\t\t.toURI();\r\n\r\n\t\tOWLOntologyIRIMapper iriMapper = new TestIRIMapper(\r\n\t\t\t\tontologyRoot.toString());\r\n\r\n\t\tman.setIRIMappers(Collections.singleton(iriMapper));\r\n\r\n\t\tfinal URI mainOntology = getClass().getClassLoader().getResource(name)\r\n\t\t\t\t.toURI();\r\n\r\n\t\treturn man.loadOntologyFromOntologyDocument(new File(mainOntology));\r\n\r\n\t}\r\n\r\n\tstatic class TestIRIMapper implements OWLOntologyIRIMapper {\r\n\t\tprivate static final long serialVersionUID = 1L;\r\n\r\n\t\tfinal String root;\r\n\r\n\t\tTestIRIMapper(String root) {\r\n\t\t\tthis.root = root;\r\n\t\t}\r\n\r\n\t\t@Override\r\n\t\tpublic IRI getDocumentIRI(IRI ontologyIRI) {\r\n\t\t\treturn IRI.create(root + \"/\" + ontologyIRI.getShortForm() + \".owl\");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n```\r\n\r\nIt seems that after A.owl is initially loaded (with the import B.owl) and the ontologies are removed from the manager, loading of A.owl does not resulting in loading of the imported ontology B.owl any longer.\r\n\r\nBackground: I am trying to reuse one instance of OWLOntologyManager in JUnit tests. After test is finished, I just remove all ontologies from the manager. This is, generally, faster than creating a new OWLOntologyManager. However, the behaviour seems to be incorrect. \r\n\r\nIs there any better way of clearing OWLOntologyManager that I may miss?"},"comment":{"url":"https://api.github.com/repos/owlcs/owlapi/issues/comments/265609450","html_url":"https://github.com/owlcs/owlapi/issues/580#issuecomment-265609450","issue_url":"https://api.github.com/repos/owlcs/owlapi/issues/580","id":265609450,"user":{"login":"ignazio1977","id":2596901,"avatar_url":"https://avatars.githubusercontent.com/u/2596901?v=3","gravatar_id":"","url":"https://api.github.com/users/ignazio1977","html_url":"https://github.com/ignazio1977","followers_url":"https://api.github.com/users/ignazio1977/followers","following_url":"https://api.github.com/users/ignazio1977/following{/other_user}","gists_url":"https://api.github.com/users/ignazio1977/gists{/gist_id}","starred_url":"https://api.github.com/users/ignazio1977/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignazio1977/subscriptions","organizations_url":"https://api.github.com/users/ignazio1977/orgs","repos_url":"https://api.github.com/users/ignazio1977/repos","events_url":"https://api.github.com/users/ignazio1977/events{/privacy}","received_events_url":"https://api.github.com/users/ignazio1977/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T23:42:12Z","updated_at":"2016-12-07T23:42:12Z","body":"Far from me to promote a recursive solution, but in this case the injector is injectable - or, to be more precise, there is nothing magic about OWLManager. The whole apibinding module can be skipped, and OWLManager replaced with another initialization class (with or without injectors).\r\nRather than complicating the injection strategy, I'd rather go down that route and provide a builder for explicit, manual injection."}}
{"actor":{"display_login":"ignazio1977"}}