Search in sources :

Example 1 with ChangeHistoryFileProvider

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());
    }
}
Also used : ChangeHistoryFileProvider(edu.stanford.bmir.protege.web.server.inject.project.ChangeHistoryFileProvider) BufferedInputStream(java.io.BufferedInputStream) BinaryOWLOntologyChangeLog(org.semanticweb.binaryowl.BinaryOWLOntologyChangeLog) File(java.io.File) OWLDataFactoryImpl(uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl) Nonnull(javax.annotation.Nonnull)

Aggregations

ChangeHistoryFileProvider (edu.stanford.bmir.protege.web.server.inject.project.ChangeHistoryFileProvider)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 Nonnull (javax.annotation.Nonnull)1 BinaryOWLOntologyChangeLog (org.semanticweb.binaryowl.BinaryOWLOntologyChangeLog)1 OWLDataFactoryImpl (uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl)1