Search in sources :

Example 6 with RevisionNumber

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));
}
Also used : RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber) Test(org.junit.Test)

Example 7 with RevisionNumber

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();
    }
}
Also used : RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber) Nonnull(javax.annotation.Nonnull)

Example 8 with RevisionNumber

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();
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Stopwatch(com.google.common.base.Stopwatch) RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) BinaryOWLMetadata(org.semanticweb.binaryowl.BinaryOWLMetadata) BufferedInputStream(java.io.BufferedInputStream) BinaryOWLOntologyChangeLog(org.semanticweb.binaryowl.BinaryOWLOntologyChangeLog) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) AtomicLong(java.util.concurrent.atomic.AtomicLong) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom)

Example 9 with RevisionNumber

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();
}
Also used : ProjectRevisionDownloader(edu.stanford.bmir.protege.web.client.download.ProjectRevisionDownloader) RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber)

Example 10 with RevisionNumber

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);
}
Also used : ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber)

Aggregations

RevisionNumber (edu.stanford.bmir.protege.web.shared.revision.RevisionNumber)12 Test (org.junit.Test)4 Stopwatch (com.google.common.base.Stopwatch)2 ImmutableList (com.google.common.collect.ImmutableList)2 ProjectRevisionDownloader (edu.stanford.bmir.protege.web.client.download.ProjectRevisionDownloader)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)2 Nonnull (javax.annotation.Nonnull)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Ordering (com.google.common.collect.Ordering)1 GWT (com.google.gwt.core.client.GWT)1 DateTimeFormat (com.google.gwt.i18n.shared.DateTimeFormat)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 Messages (edu.stanford.bmir.protege.web.client.Messages)1 DispatchServiceCallback (edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback)1 DispatchServiceManager (edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager)1 DialogButton (edu.stanford.bmir.protege.web.client.library.dlg.DialogButton)1 CANCEL (edu.stanford.bmir.protege.web.client.library.dlg.DialogButton.CANCEL)1 MessageBox (edu.stanford.bmir.protege.web.client.library.msgbox.MessageBox)1 LoggedInUserProjectPermissionChecker (edu.stanford.bmir.protege.web.client.permissions.LoggedInUserProjectPermissionChecker)1