@Override public void addIRIMapper(OWLOntologyIRIMapper mapper) { delegate.addIRIMapper(mapper); }
/** * Given a URI of an owl file returns the * translated OWLOntology object * @param tboxFile - the URI of the file * @return the translated OWLOntology * @throws Exception */ private OWLOntology getOntologyFromFile(URI tboxFile) throws Exception{ //get owl ontology from file OWLOntologyIRIMapper iriMapper = new AutoIRIMapper(new File(tboxFile).getParentFile(), false); man.addIRIMapper(iriMapper); OWLOntology owlontology = man.loadOntologyFromOntologyDocument(new File(tboxFile)); return owlontology; }
public DefaultExplanationOrderer() { currentExplanation = Collections.emptySet(); lhs2AxiomMap = new HashMap<OWLEntity, Set<OWLAxiom>>(); entitiesByAxiomRHS = new HashMap<OWLAxiom, Set<OWLEntity>>(); seedExtractor = new SeedExtractor(); man = OWLManager.createOWLOntologyManager(); man.addIRIMapper(new OWLOntologyIRIMapper() { public IRI getDocumentIRI(IRI ontologyIRI) { return ontologyIRI; } }); mappedAxioms = new HashMap<OWLObject, Set<OWLAxiom>>(); passTypes = new HashSet<AxiomType>(); // I'm not sure what to do with disjoint classes yet. At the // moment, we just shove them at the end at the top level. passTypes.add(AxiomType.DISJOINT_CLASSES); consumedAxioms = new HashSet<OWLAxiom>(); }
public static void addIRIMapper(OWLOntologyManager manager) { URL metaprojectURL = MetaprojectVocabulary.class.getClassLoader().getResource("metaproject.owl"); if (metaprojectURL != null) { IRI metaprojectIRI; try { metaprojectIRI = IRI.create(metaprojectURL.toURI()); } catch (URISyntaxException use) { throw new RuntimeException("Unexpected class loader exception", use); } manager.addIRIMapper(new SimpleIRIMapper(IRI.create(NS), metaprojectIRI)); } }
/** * {@inheritDoc} */ @Override public void setIgnoreImports(boolean ignoreImports) { this.ignoreImports = ignoreImports; if( ignoreImports ) { manager.clearIRIMappers(); manager.addIRIMapper( iriMapper ); } else { manager.clearIRIMappers(); manager.addIRIMapper( new NonMappingOntologyIRIMapper() ); } }
/** * {@inheritDoc} */ @Override public void setIgnoreImports(boolean ignoreImports) { this.ignoreImports = ignoreImports; if( ignoreImports ) { manager.clearIRIMappers(); manager.addIRIMapper( iriMapper ); } else { manager.clearIRIMappers(); manager.addIRIMapper( new NonMappingOntologyIRIMapper() ); } }
@SuppressWarnings("javadoc") public DefaultExplanationOrderer() { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); man.addIRIMapper(new OWLOntologyIRIMapper() { @Override public IRI getDocumentIRI(IRI ontologyIRI) { return ontologyIRI; } }); delegate = new ExplanationOrdererImpl(man); }
public static void addIRIMappers(OWLOntologyManager manager) { manager.addIRIMapper(new SimpleIRIMapper(IRI.create("http://jamesnaish.wordpress.com/ROREKnowledgeModel.owl"), IRI.create(new File(ONTOLOGY_ROOT, FEB_PATH + File.separator + "ROREKnowledgeModel.owl")))); manager.addIRIMapper(new SimpleIRIMapper(IRI.create("http://jamesnaish.wordpress.com/Model/AutopilotSourceModel.owl"), IRI.create(new File(ONTOLOGY_ROOT, FEB_PATH + File.separator + "AutopilotSourceModel.owl")))); } }
private Ontology readOntology(String tboxFile) throws Exception { File f = new File(tboxFile); OWLOntologyIRIMapper iriMapper = new AutoIRIMapper(f.getParentFile(), false); man.addIRIMapper(iriMapper); OWLOntology owlontology = null; if (tboxFile.contains("file:")) { owlontology = man.loadOntologyFromOntologyDocument(new URL(tboxFile).openStream()); } else { owlontology = man.loadOntologyFromOntologyDocument(new File(tboxFile)); } closure = man.getImportsClosure(owlontology); return OWLAPITranslatorUtility.mergeTranslateOntologies(closure); }
/** * * @param localDirs * . If null or empty, no offline support will be added * @return */ public static OWLOntologyManager createOWLOntologyManager(IRI[] locations) { OWLOntologyManager mgr = OWLManager.createOWLOntologyManager(); for (OWLOntologyIRIMapper mapper : getMappers(locations)) { mgr.addIRIMapper(mapper); } return mgr; }
public void configureEditorKit(EditorKit editorKit) { ((OWLEditorKit) editorKit).getOWLModelManager().getOWLOntologyManager().addIRIMapper(iriMapper); }
public void configureEditorKit(EditorKit editorKit) { ((OWLEditorKit) editorKit).getOWLModelManager().getOWLOntologyManager().addIRIMapper(iriMapper); }
public static OWLOntology loadOntology(String fileName) { AutoIRIMapper mapper = new AutoIRIMapper(new File(fileName.substring(0, fileName.lastIndexOf('/'))), false); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); manager.addIRIMapper(mapper); //System.out.println(mapper.getDocumentIRI(IRI.create("http://semantics.crl.ibm.com/univ-bench-dl.owl"))); OWLOntology ontology = null; try { ontology = manager.loadOntologyFromOntologyDocument(new File(fileName)); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } // manager.removeIRIMapper(mapper); return ontology; }
public void configureEditorKit(EditorKit editorKit) { ((OWLEditorKit) editorKit).getOWLModelManager().getOWLOntologyManager().addIRIMapper(iriMapper); }
public void configureEditorKit(EditorKit editorKit) { ((OWLEditorKit) editorKit).getOWLModelManager().getOWLOntologyManager().addIRIMapper(iriMapper); }
/** * Load OWL files from given directory and in its subdirectories, using a prefix * mapper to resolve URLs internally and deriving ontology names from the relative * paths. This uses the resolver passed at initialization only to create the * namespace. It's only meant for core knowledge not seen by users. * * @param kdir * @throws KlabIOException */ public void load(File kdir) throws KlabException { AutoIRIMapper imap = new AutoIRIMapper(kdir, true); manager.addIRIMapper(imap); File[] files = kdir.listFiles(); // null in error if (files != null) { for (File fl : files) { loadInternal(fl, "", null); } } else { throw new KlabIOException("Errors reading core ontologies: system will be nonfunctional. Check server distribution."); } }
public OWLOntology importRawProjectSources(RawProjectSources projectSources) throws OWLOntologyCreationException { try { manager.addIRIMapper(projectSources.getOntologyIRIMapper()); OWLOntology ontology = null; for (OWLOntologyDocumentSource documentSource : projectSources.getDocumentSources()) { ontology = manager.loadOntologyFromOntologyDocument(documentSource, loaderConfig); } return ontology; } finally { manager.removeIRIMapper(projectSources.getOntologyIRIMapper()); } }
private void addImportMapping(OWLOntology ontology, IRI importLocation, IRI physicalLocation) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); manager.addIRIMapper(new SimpleIRIMapper(importLocation, physicalLocation)); try { IRI importersDocumentLocation = manager.getOntologyDocumentIRI(ontology); if (importersDocumentLocation.getScheme().equals("file")) { File f = new File(importersDocumentLocation.toURI()); XMLCatalog catalog = eKit.getModelManager().addRootFolder(f.getParentFile()); URI physicalUri = CatalogUtilities.relativize(physicalLocation.toURI(), catalog); catalog.addEntry(0, new UriEntry("Imports Wizard Entry", catalog, importLocation.toURI().toString(), physicalUri, null)); CatalogUtilities.save(catalog, OntologyCatalogManager.getCatalogFile(f.getParentFile())); } } catch (Throwable t) { ProtegeApplication.getErrorLog().logError(t); } }
private void addImportMapping(OWLOntology ontology, IRI importLocation, IRI physicalLocation) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); manager.addIRIMapper(new SimpleIRIMapper(importLocation, physicalLocation)); try { IRI importersDocumentLocation = manager.getOntologyDocumentIRI(ontology); if (UIUtil.isLocalFile(importersDocumentLocation.toURI())) { File f = new File(importersDocumentLocation.toURI()); XMLCatalog catalog = eKit.getModelManager().addRootFolder(f.getParentFile()); URI physicalUri = CatalogUtilities.relativize(physicalLocation.toURI(), catalog); catalog.addEntry(0, new UriEntry("Imports Wizard Entry", catalog, importLocation.toURI().toString(), physicalUri, null)); CatalogUtilities.save(catalog, OntologyCatalogManager.getCatalogFile(f.getParentFile())); } } catch (Throwable t) { ProtegeApplication.getErrorLog().logError(t); } }
/** * Creates an OWL ontology manager that is configured with standard parsers, * storeres etc. * * @param dataFactory The data factory that the manager should have a reference to. * @return The manager. */ public static OWLOntologyManager createOWLOntologyManager(OWLDataFactory dataFactory) { // Create the ontology manager and add ontology factories, mappers and storers OWLOntologyManager ontologyManager = new OWLOntologyManagerImpl(dataFactory); ontologyManager.addOntologyStorer(new RDFXMLOntologyStorer()); ontologyManager.addOntologyStorer(new OWLXMLOntologyStorer()); ontologyManager.addOntologyStorer(new OWLFunctionalSyntaxOntologyStorer()); ontologyManager.addOntologyStorer(new ManchesterOWLSyntaxOntologyStorer()); ontologyManager.addOntologyStorer(new OBOFlatFileOntologyStorer()); ontologyManager.addOntologyStorer(new KRSS2OWLSyntaxOntologyStorer()); ontologyManager.addOntologyStorer(new TurtleOntologyStorer()); ontologyManager.addOntologyStorer(new LatexOntologyStorer()); ontologyManager.addIRIMapper(new NonMappingOntologyIRIMapper()); ontologyManager.addOntologyFactory(new EmptyInMemOWLOntologyFactory()); ontologyManager.addOntologyFactory(new ParsableOWLOntologyFactory()); return ontologyManager; }