Skip to content

Commit

Permalink
add changeRequestId to NewRevisionsEvent for history rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Dec 11, 2024
1 parent b873b8e commit 458f5ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public <R> ChangeApplicationResult<R> applyChanges(@Nonnull final UserId userId,

revision.ifPresent(value -> projectRevisionRepository.save(new ProjectRevision(projectId, changeRequestId, userId, value.getRevisionNumber())));

newRevisionsEmitter.emitNewRevisionsEvent(revision);
newRevisionsEmitter.emitNewRevisionsEvent(revision, changeRequestId);

} finally {
changeProcesssingLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
public record NewRevisionsEvent(
EventId eventId,
ProjectId projectId,
Set<ProjectChangeForEntity> changes
Set<ProjectChangeForEntity> changes,
ChangeRequestId changeRequestId
) implements ProjectEvent {
public final static String CHANNEL = "webprotege.events.projects.uiHistory.NewRevisionsEvent";

public static NewRevisionsEvent create(EventId eventId,
ProjectId projectId,
Set<ProjectChangeForEntity> changes) {
return new NewRevisionsEvent(eventId, projectId, changes);
Set<ProjectChangeForEntity> changes,
ChangeRequestId changeRequestId) {
return new NewRevisionsEvent(eventId, projectId, changes, changeRequestId);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package edu.stanford.protege.webprotege.revision.uiHistoryConcern;

import edu.stanford.protege.webprotege.common.ChangeRequestId;
import edu.stanford.protege.webprotege.revision.Revision;

import java.util.Optional;

public interface NewRevisionsEventEmitterService {
void emitNewRevisionsEvent(Optional<Revision> revision);
void emitNewRevisionsEvent(Optional<Revision> revision, ChangeRequestId changeRequestId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public NewRevisionsEventEmitterServiceImpl(ProjectChangesManager changesManager,


@Override
public void emitNewRevisionsEvent(Optional<Revision> revision) {
public void emitNewRevisionsEvent(Optional<Revision> revision, ChangeRequestId changeRequestId) {
revision.ifPresent(rev -> {
Set<ProjectChangeForEntity> changes = changesManager.getProjectChangesForEntitiesFromRevision(rev);
//Based on axioms in the revision we can determine if the entity was added/deleted or updated
//e.g. for adding a new entity you have Declaration axiom
//
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changes);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changes, changeRequestId);
eventDispatcher.dispatchEvent(revisionsEvent);
});
}
Expand Down

0 comments on commit 458f5ca

Please sign in to comment.