private void handleNotesOntologyChanged(List<OWLOntologyChange> changes) { try { OWLOntologyManager notesOntologyManager = notesOntology.getOWLOntologyManager(); if (notesOntologyManager.getOntologyFormat(notesOntology) instanceof BinaryOWLOntologyDocumentFormat) { OWLAPIProjectDocumentStore documentStore = OWLAPIProjectDocumentStore.getProjectDocumentStore(project.getProjectId()); List<OWLOntologyChangeData> infoList = new ArrayList<OWLOntologyChangeData>(); for (OWLOntologyChange change : changes) { OWLOntologyChangeRecord rec = change.getChangeRecord(); OWLOntologyChangeData info = rec.getData(); infoList.add(info); } BinaryOWLOntologyDocumentSerializer serializer = new BinaryOWLOntologyDocumentSerializer(); serializer.appendOntologyChanges( notesOntologyDocument, new OntologyChangeDataList(infoList, System.currentTimeMillis())); } else { // Swap it over notesOntologyManager.saveOntology(notesOntology, new BinaryOWLOntologyDocumentFormat()); } } catch (OWLOntologyStorageException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
public void loadOntology() { try { /* * --apaitoymena vimata gia th dhmioyrgia mapped ontologias: * 1.dhmioyrgoyme ena toBeMappedIRI me skopo toy thn antistoixish me * to local File. 2.dhmioyrgoyme ena File me th dieythynsh ths * ontologias sto topiko apothikeytiko meso. 3.dhmioyrgoyme enan * SimpleIRIMapper kai ton prosthetoyme mesw toy manager. o * SimpleIRIMapper syndeei to toBeMappedIRI poy dwsame arxika, me * thn fysikh topothesia ths ontologias sto topiko apothikeytiko * meso. 4.dhmioyrgoyme ena ontologyIRI me akrivws thn idia arxiki * timh me to toBeMappedIRI to opoio tha einai to IRI ths ontologias * mas 5.dhmioyrgoyme thn ontologia mas xrhsimopoiwntas to * manager.loadOntology(ontologyIRI); */ String sep = File.separator; manager = OWLManager.createOWLOntologyManager(); toBeMappedIRI = IRI.create( "http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl"); // ontFile = new File("../src/ontologyresources/ptyxiaki_v0.8.owl"); ontFile = new File("src/ontologyresources/ptyxiaki_v0.8.owl"); // in case of alternative location on load time when the application is jar'ed! if (!ontFile.canRead()) { ontFile = new File("ontologyresources/ptyxiaki_v0.8.owl"); } manager.addIRIMapper(new SimpleIRIMapper(toBeMappedIRI, IRI.create(ontFile))); ontologyIRI = IRI.create( "http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl"); topIxOnt = manager.loadOntology(ontologyIRI); OWLFactory = manager.getOWLDataFactory(); topIxFormat = manager.getOntologyFormat(topIxOnt); topIxPrefixManager = new DefaultPrefixManager(topIxOnt.getOntologyID().getOntologyIRI().toString() + '#'); System.out.println("loaded ontology: " + this.topIxOnt); System.out.println("from: " + this.manager.getOntologyDocumentIRI(this.topIxOnt)); } catch (OWLException oex) { logger.info(oex.getMessage()); } }
private boolean isOBOFormat(OWLOntology ontology) { OWLOntologyManager man = ontology.getOWLOntologyManager(); return man.getOntologyFormat(ontology) instanceof OBOOntologyFormat; }