use of org.semanticweb.binaryowl.change.OntologyChangeDataList in project webprotege by protegeproject.
the class ProjectDocumentStore method saveOntologyChanges.
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void saveOntologyChanges(List<OWLOntologyChange> rawChangeList) {
// Put changes into a buffer
try {
writeLock.lock();
try {
ListMultimap<OWLOntology, OWLOntologyChange> changesByOntology = ArrayListMultimap.create();
for (OWLOntologyChange change : rawChangeList) {
changesByOntology.put(change.getOntology(), change);
}
for (OWLOntology ontology : changesByOntology.keySet()) {
IRI docIRI = ontology.getOWLOntologyManager().getOntologyDocumentIRI(ontology);
if (!"file".equalsIgnoreCase(docIRI.toURI().getScheme())) {
throw new RuntimeException("Document IRI is not a local file IRI");
}
List<OWLOntologyChange> ontologyChangeList = changesByOntology.get(ontology);
List<OWLOntologyChangeData> infoList = new ArrayList<>();
for (OWLOntologyChange change : ontologyChangeList) {
OWLOntologyChangeRecord changeRecord = change.getChangeRecord();
infoList.add(changeRecord.getData());
}
File file = new File(docIRI.toURI());
BinaryOWLOntologyDocumentSerializer serializer = new BinaryOWLOntologyDocumentSerializer();
serializer.appendOntologyChanges(file, new OntologyChangeDataList(infoList, System.currentTimeMillis(), BinaryOWLMetadata.emptyMetadata()));
}
} catch (IOException e) {
logger.error("An error occurred whilst saving ontology changes: {}", e.getMessage(), e);
e.printStackTrace();
}
} finally {
writeLock.unlock();
}
}
Aggregations