use of edu.stanford.bmir.protege.web.server.inject.project.ChangeHistoryFileProvider in project webprotege by protegeproject.
the class HeadRevisionNumberFinder method getHeadRevisionNumber.
/**
* Computes the head revision number for the specified project.
*
* @param projectId The project.
* @return The {@link RevisionNumber}
*/
@Nonnull
public RevisionNumber getHeadRevisionNumber(@Nonnull ProjectId projectId) throws IOException {
/*
This method works fairly well, even for large
projects, but it is only intended to be a stopgap and needs replacing.
*/
File projectDir = projectDirectoryFactory.getProjectDirectory(projectId);
ChangeHistoryFileProvider changeHistoryFileProvider = new ChangeHistoryFileProvider(projectDir);
File changeHistoryFile = changeHistoryFileProvider.get();
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(Files.newInputStream(changeHistoryFile.toPath()))) {
BinaryOWLOntologyChangeLog log = new BinaryOWLOntologyChangeLog();
RevisionExtractor extractor = new RevisionExtractor();
log.readChanges(bufferedInputStream, new OWLDataFactoryImpl(), extractor, SKIP_DATA);
return RevisionNumber.getRevisionNumber(extractor.getLastRevision());
}
}
Aggregations