@Override public OWLOntologyManager getVolatileManager() { if (null == _volatileManager) _volatileManager = OWLManager.createConcurrentOWLOntologyManager(); return _volatileManager; }
@Override public OWLOntologyManager getVolatileManager() { if (null == _volatileManager) _volatileManager = OWLManager.createConcurrentOWLOntologyManager(); return _volatileManager; }
@Override public OWLOntologyManager getVolatileManager() { if (null == _volatileManager) _volatileManager = OWLManager.createConcurrentOWLOntologyManager(); return _volatileManager; }
@Nonnull public static OWLOntologyManager createManager() { return OWLManager.createConcurrentOWLOntologyManager(); } }
public void testFile(final String fileName) throws IOException { final String common = "file:" + base + fileName; testRealization(OWLManager.createConcurrentOWLOntologyManager(), common + ".owl"); }
public void testFile(final String fileName) throws IOException { final String common = "file:" + base + fileName; testClassification(OWLManager.createConcurrentOWLOntologyManager(), common + ".owl"); }
public void process(final File file) { try { final OWLOntology o = OWLManager.createConcurrentOWLOntologyManager().loadOntologyFromOntologyDocument(file); renameObjects(o); // o.add(OWL.classAssertion(OWL.Individual("y:impossible"), OWL.and(OWL.Class("y:cls/a"), OWL.not(OWL.Class("y:cls/a"))))); final OWLAxiom[] axioms = o.axioms().toArray(OWLAxiom[]::new); for (int i = 0; i < nCPU; i++) _executor.execute(new Worker(axioms.clone())); // new Worker(axioms.clone()).run(); } catch (final Exception e) { e.printStackTrace(); } }
/** * @return The storage manager if you have call setOntologiesDirectory() before; else it throw a RuntimeException. * @since 2.5.1 */ @Override public synchronized OWLOntologyManager getPersistentManager() { if (null == _persistentManager) { _persistentManager = OWLManager.createConcurrentOWLOntologyManager(); if (!getOntologiesDirectory().isPresent()) { final String msg = "You should define a directory for stored ontologies before using stored ontologies."; final OWLException ex = new OWLException(msg); Log.error(getLogger(), msg, ex); throw ex; } try { _storageListener = new OWLIncrementalFlatFileStorageManagerListener(getOntologiesDirectory().get(), new File(getOntologiesDirectory().get().getPath() + File.separator + OWLHelper._delta), this); getPersistentManager().addOntologyChangeListener(_storageListener); } catch (final Exception e) { throw new OWLException(e); } } return _persistentManager; }
/** * @return The storage manager if you have call setOntologiesDirectory() before; else it throw a RuntimeException. * @since 2.5.1 */ @Override public synchronized OWLOntologyManager getPersistentManager() { if (null == _persistentManager) { _persistentManager = OWLManager.createConcurrentOWLOntologyManager(); if (!getOntologiesDirectory().isPresent()) { final String msg = "You should define a directory for stored ontologies before using stored ontologies."; final OWLException ex = new OWLException(msg); Log.error(getLogger(), msg, ex); throw ex; } try { _storageListener = new OWLIncrementalFlatFileStorageManagerListener(getOntologiesDirectory().get(), new File(getOntologiesDirectory().get().getPath() + File.separator + OWLHelper._delta), this); getPersistentManager().addOntologyChangeListener(_storageListener); } catch (final Exception e) { throw new OWLException(e); } } return _persistentManager; }
/** * @return The storage manager if you have call setOntologiesDirectory() before; else it throw a RuntimeException. * @since 2.5.1 */ @Override public synchronized OWLOntologyManager getPersistentManager() { if (null == _persistentManager) { _persistentManager = OWLManager.createConcurrentOWLOntologyManager(); if (!getOntologiesDirectory().isPresent()) { final String msg = "You should define a directory for stored ontologies before using stored ontologies."; final OWLException ex = new OWLException(msg); Log.error(getLogger(), msg, ex); throw ex; } try { _storageListener = new OWLIncrementalFlatFileStorageManagerListener(getOntologiesDirectory().get(), new File(getOntologiesDirectory().get().getPath() + File.separator + OWLHelper._delta), this); getPersistentManager().addOntologyChangeListener(_storageListener); } catch (final Exception e) { throw new OWLException(e); } } return _persistentManager; }
OWLManager.createConcurrentOWLOntologyManager()// .createOntology(IRI.create("http://com.github.galigator.openllet/ontologies#demo2"));
public void testPersistenceRemoves(final String inputOnt) throws IOException { final File testFile = new File(TEST_FILE); final OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager(); final OWLOntology ontology = OntologyUtils.loadOntology(manager, inputOnt); final ModuleExtractor moduleExtractor = createModuleExtractor(); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, moduleExtractor); modular.classify(); manager.removeAxioms(ontology, TestUtils.selectRandomAxioms(ontology, 1).stream()); // at this point there should be a change to the ontology that is not applied yet to the classifier // this should cause the save operation to fail try (FileOutputStream fos = new FileOutputStream(testFile)) { IncrementalClassifierPersistence.save(modular, fos); fail("The incremental classifer must not allow itself to be persisted if there are any unapplied changes to the ontology"); } catch (final IllegalStateException e) { _logger.log(Level.FINE, "", e); assertTrue(testFile.delete()); // correct behavior } }
public void testPersistenceAdds(final String inputOnt) throws IOException { final File testFile = new File(TEST_FILE); final OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager(); final OWLOntology ontology = OntologyUtils.loadOntology(manager, inputOnt); final ModuleExtractor moduleExtractor = createModuleExtractor(); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, moduleExtractor); // first remove a random axiom final Set<OWLAxiom> axiomsToRemove = TestUtils.selectRandomAxioms(ontology, 1); manager.removeAxioms(ontology, axiomsToRemove.stream()); // classify (i.e., update) modular.classify(); // add the axiom back but do not classify (do not cause an update) manager.addAxioms(ontology, axiomsToRemove.stream()); // at this point there should be a change to the ontology that is not applied yet to the classifier // this should cause the save operation to fail try (final FileOutputStream fos = new FileOutputStream(testFile)) { IncrementalClassifierPersistence.save(modular, fos); fail("The incremental classifer must not allow itself to be persisted if there are any unapplied changes to the ontology"); } catch (final IllegalStateException e) { _logger.log(Level.FINE, "", e); assertTrue(testFile.delete()); // correct behavior } modular.dispose(); }
public void testAllowedUpdates(final String inputOnt) throws IOException { final File testFile = new File(TEST_FILE); final OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager(); final OWLOntology ontology = OntologyUtils.loadOntology(manager, inputOnt); final ModuleExtractor moduleExtractor = createModuleExtractor(); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, moduleExtractor); modular.classify(); // first remove a random axiom final Set<OWLAxiom> axiomsToRemove = TestUtils.selectRandomAxioms(ontology, 1); manager.removeAxioms(ontology, axiomsToRemove.stream()); // add the axiom back but do not classify manager.addAxioms(ontology, axiomsToRemove.stream()); // remove another random axiom manager.removeAxioms(ontology, TestUtils.selectRandomAxioms(ontology, 1).stream()); // classify (i.e., update) modular.classify(); // at this point, the ontology should be updated (despite the changes), and the save should succeed. try (final FileOutputStream fos = new FileOutputStream(testFile)) { IncrementalClassifierPersistence.save(modular, fos); } assertTrue(testFile.delete()); }
public void testUpdatesWhenPersisted(final String inputOnt) throws IOException { final File testFile = new File(TEST_FILE); final OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager(); final OWLOntology ontology = OntologyUtils.loadOntology(manager, inputOnt); IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, createModuleExtractor()); modular.classify(); try (final FileOutputStream fos = new FileOutputStream(testFile)) { IncrementalClassifierPersistence.save(modular, fos); } // perform changes while the classifier is stored on disk; first remove a random axiom manager.removeAxioms(ontology, TestUtils.selectRandomAxioms(ontology, 1).stream()); try (final FileInputStream fis = new FileInputStream(testFile)) { modular = IncrementalClassifierPersistence.load(fis, ontology); } final OpenlletReasoner expected = OpenlletReasonerFactory.getInstance().createReasoner(ontology); assertClassificationEquals(expected, modular); }
OWLOntologyManager loadingManager = OWLManager.createConcurrentOWLOntologyManager();
if (!man.contains(importParameters.getOntologyID())) { try { OWLOntologyManager loadingManager = OWLManager.createConcurrentOWLOntologyManager(); loadingManager.getIRIMappers() .add(man.getIRIMappers());
/** * Tests whether the restored classifier can be updated. The test creates one original classifier (modular), persists it, reads it back as another * classifier (modular2). Then it performs the same modifications of the ontology on them, and checks whether their behavior is identical. * * @param inputOnt * @throws IOException */ public void testUpdatesAfterPersistence2(final String inputOnt) throws IOException { final File testFile = new File(TEST_FILE); final OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager(); final OWLOntology ontology = OntologyUtils.loadOntology(manager, inputOnt); IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, createModuleExtractor()); modular.classify(); try (final FileOutputStream fos = new FileOutputStream(testFile)) { IncrementalClassifierPersistence.save(modular, fos); } try (final FileInputStream fis = new FileInputStream(testFile)) { modular = IncrementalClassifierPersistence.load(fis, ontology); } // first remove a random axiom manager.removeAxioms(ontology, TestUtils.selectRandomAxioms(ontology, 1).stream()); modular.classify(); final OpenlletReasoner expected = OpenlletReasonerFactory.getInstance().createReasoner(ontology); assertClassificationEquals(expected, modular); }
/** * Tests whether the restored classifier can be updated. The test creates one original classifier (modular), persists it, reads it back as another * classifier (modular2). Then it performs the same modifications of the ontology on them, and checks whether their behavior is identical. * * @param inputOnt * @throws IOException */ public void testUpdatesAfterPersistence(final String inputOnt) throws IOException { final File testFile = new File(TEST_FILE); final OWLOntologyManager manager = OWLManager.createConcurrentOWLOntologyManager(); final OWLOntology ontology = OntologyUtils.loadOntology(manager, inputOnt); final ModuleExtractor moduleExtractor = createModuleExtractor(); IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, moduleExtractor); modular.classify(); try (final FileOutputStream fos = new FileOutputStream(testFile)) { IncrementalClassifierPersistence.save(modular, fos); } try (final FileInputStream fis = new FileInputStream(testFile)) { modular = IncrementalClassifierPersistence.load(fis); } // first remove a random axiom manager.removeAxioms(ontology, TestUtils.selectRandomAxioms(ontology, 1).stream()); modular.classify(); final OpenlletReasoner expected = OpenlletReasonerFactory.getInstance().createReasoner(modular.getRootOntology()); assertClassificationEquals(expected, modular); }
public OWLModelManagerImpl() { super(); manager = OWLManager.createConcurrentOWLOntologyManager(); manager.addOntologyChangeListener(this); manager.addOntologyLoaderListener(this); // URI mappers for loading - added in reverse order PriorityCollection<OWLOntologyIRIMapper> iriMappers = manager.getIRIMappers(); iriMappers.clear(); iriMappers.add(userResolvedIRIMapper); iriMappers.add(new WebConnectionIRIMapper()); AutoMappedRepositoryIRIMapper autoMappedRepositoryIRIMapper = new AutoMappedRepositoryIRIMapper(ontologyCatalogManager); iriMappers.add(autoMappedRepositoryIRIMapper); objectRenderer = new OWLObjectRendererImpl(this); owlEntityRenderingCache = new OWLEntityRenderingCacheImpl(); owlEntityRenderingCache.setOWLModelManager(this); owlObjectRenderingCache = new OWLObjectRenderingCache(this); owlExpressionCheckerFactory = new ManchesterOWLExpressionCheckerFactory(this); //needs to be initialized activeOntologiesStrategy = new ImportsClosureOntologySelectionStrategy(this); historyManager = new HistoryManagerImpl(this); owlReasonerManager = new OWLReasonerManagerImpl(this); owlReasonerManager.getReasonerPreferences().addListener(() -> fireEvent(EventType.ONTOLOGY_CLASSIFIED)); // force the renderer to be created // to prevent double cache rebuild once ontologies loaded getOWLEntityRenderer(); put(OntologySourcesManager.ID, new OntologySourcesManager(this)); }