use of edu.stanford.bmir.protege.web.shared.revision.RevisionNumber in project webprotege by protegeproject.
the class FileDownloadParametersTestCase method shouldParseMalformedRevisionIntoHeadRevision.
@Test
public void shouldParseMalformedRevisionIntoHeadRevision() {
when(servletRequest.getParameter(ProjectDownloadConstants.REVISION)).thenReturn("x");
RevisionNumber revisionNumber = parameters.getRequestedRevision();
assertThat(revisionNumber.isHead(), is(true));
}
use of edu.stanford.bmir.protege.web.shared.revision.RevisionNumber in project webprotege by protegeproject.
the class RevisionManagerImpl method addRevision.
@Nonnull
@Override
public Revision addRevision(@Nonnull UserId userId, @Nonnull List<? extends OWLOntologyChangeRecord> changes, @Nonnull String desc) {
try {
writeLock.lock();
long timestamp = System.currentTimeMillis();
RevisionNumber revisionNumber = revisionStore.getCurrentRevisionNumber().getNextRevisionNumber();
final String highlevelDescription = desc != null ? desc : "";
final Revision revision = new Revision(userId, revisionNumber, ImmutableList.copyOf(changes), timestamp, highlevelDescription);
revisionStore.addRevision(revision);
return revision;
} finally {
writeLock.unlock();
}
}
use of edu.stanford.bmir.protege.web.shared.revision.RevisionNumber in project webprotege by protegeproject.
the class RevisionStoreImpl method load.
public void load() {
try {
writeLock.lock();
if (!changeHistoryFile.exists()) {
changeHistoryFile.getParentFile().mkdirs();
return;
}
final ImmutableList.Builder<Revision> revisionsBuilder = ImmutableList.builder();
try {
logger.info("{} Loading change history", projectId);
Stopwatch stopwatch = Stopwatch.createStarted();
BinaryOWLOntologyChangeLog changeLog = new BinaryOWLOntologyChangeLog();
final BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(changeHistoryFile));
final Interner<OWLAxiom> axiomInterner = Interners.newStrongInterner();
final Interner<String> metadataInterner = Interners.newStrongInterner();
changeLog.readChanges(inputStream, dataFactory, (list, skipSetting, l) -> {
BinaryOWLMetadata metadata = list.getMetadata();
String userName = metadataInterner.intern(metadata.getStringAttribute(RevisionSerializationVocabulary.USERNAME_METADATA_ATTRIBUTE.getVocabularyName(), ""));
Long revisionNumberValue = metadata.getLongAttribute(RevisionSerializationVocabulary.REVISION_META_DATA_ATTRIBUTE.getVocabularyName(), 0L);
RevisionNumber revisionNumber = RevisionNumber.getRevisionNumber(revisionNumberValue);
String description = metadataInterner.intern(metadata.getStringAttribute(RevisionSerializationVocabulary.DESCRIPTION_META_DATA_ATTRIBUTE.getVocabularyName(), ""));
// RevisionType type = RevisionType.valueOf(metadata.getStringAttribute(RevisionSerializationVocabulary.REVISION_TYPE_META_DATA_ATTRIBUTE.getVocabularyName(), RevisionType.EDIT.name()));
final UserId userId = UserId.getUserId(userName);
final List<OWLOntologyChangeRecord> changeRecords = internChangeRecords(list, axiomInterner);
Revision revision = new Revision(userId, revisionNumber, ImmutableList.copyOf(changeRecords), list.getTimestamp(), description);
revisionsBuilder.add(revision);
}, SkipSetting.SKIP_NONE);
inputStream.close();
stopwatch.stop();
revisions = revisionsBuilder.build();
logger.info("{} Change history loading complete. Loaded {} revisions in {} ms.", projectId, revisions.size(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
} catch (Exception e) {
logger.error("{} Failed to load change history for project. Cause: {}", projectId, e.getMessage(), e);
}
} finally {
writeLock.unlock();
}
}
use of edu.stanford.bmir.protege.web.shared.revision.RevisionNumber in project webprotege by protegeproject.
the class DownloadProjectRequestHandlerImpl method doDownload.
private void doDownload(ProjectId projectId, DownloadFormatExtension extension) {
RevisionNumber head = RevisionNumber.getHeadRevisionNumber();
ProjectRevisionDownloader downloader = new ProjectRevisionDownloader(projectId, head, extension);
downloader.download();
}
use of edu.stanford.bmir.protege.web.shared.revision.RevisionNumber in project webprotege by protegeproject.
the class ProjectDownloadServlet method startProjectDownload.
private void startProjectDownload(HttpServletResponse resp, UserId userId, FileDownloadParameters downloadParameters) throws IOException {
ProjectId projectId = downloadParameters.getProjectId();
RevisionNumber revisionNumber = downloadParameters.getRequestedRevision();
DownloadFormat format = downloadParameters.getFormat();
projectDownloadService.downloadProject(userId, projectId, revisionNumber, format, resp);
}
Aggregations