use of org.semanticweb.owlapi.change.OWLOntologyChangeData 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();
}
}
use of org.semanticweb.owlapi.change.OWLOntologyChangeData in project webprotege by protegeproject.
the class RevisionReverterChangeListGenerator method generateChanges.
@Override
public OntologyChangeList<Boolean> generateChanges(ChangeGenerationContext context) {
Optional<Revision> revision = revisionManager.getRevision(revisionNumber);
if (!revision.isPresent()) {
return OntologyChangeList.<Boolean>builder().build(false);
}
List<OWLOntologyChange> changes = new ArrayList<>();
for (OWLOntologyChangeRecord record : revision.get()) {
OWLOntologyChangeData revertingChangeData = changeDataReverter.getRevertingChange(record);
OWLOntologyChangeRecord revertingRecord = new OWLOntologyChangeRecord(record.getOntologyID(), revertingChangeData);
OWLOntologyManager manager = rootOntology.getOWLOntologyManager();
OWLOntologyChange change = revertingRecord.createOntologyChange(manager);
changes.add(0, change);
}
return OntologyChangeList.<Boolean>builder().addAll(changes).build(true);
}
Aggregations