From 458f5ca86d15dc4022f72e10669f356291942227 Mon Sep 17 00:00:00 2001 From: alexsilaghi Date: Wed, 11 Dec 2024 14:34:15 +0200 Subject: [PATCH 1/2] add changeRequestId to NewRevisionsEvent for history rollback --- .../protege/webprotege/project/chg/ChangeManager.java | 2 +- .../revision/uiHistoryConcern/NewRevisionsEvent.java | 8 +++++--- .../uiHistoryConcern/NewRevisionsEventEmitterService.java | 3 ++- .../NewRevisionsEventEmitterServiceImpl.java | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/stanford/protege/webprotege/project/chg/ChangeManager.java b/src/main/java/edu/stanford/protege/webprotege/project/chg/ChangeManager.java index d086c4c7a..f553d5d6a 100644 --- a/src/main/java/edu/stanford/protege/webprotege/project/chg/ChangeManager.java +++ b/src/main/java/edu/stanford/protege/webprotege/project/chg/ChangeManager.java @@ -341,7 +341,7 @@ public ChangeApplicationResult 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(); diff --git a/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEvent.java b/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEvent.java index 7e2cd9a6c..7845d9087 100644 --- a/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEvent.java +++ b/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEvent.java @@ -11,14 +11,16 @@ public record NewRevisionsEvent( EventId eventId, ProjectId projectId, - Set changes + Set changes, + ChangeRequestId changeRequestId ) implements ProjectEvent { public final static String CHANNEL = "webprotege.events.projects.uiHistory.NewRevisionsEvent"; public static NewRevisionsEvent create(EventId eventId, ProjectId projectId, - Set changes) { - return new NewRevisionsEvent(eventId, projectId, changes); + Set changes, + ChangeRequestId changeRequestId) { + return new NewRevisionsEvent(eventId, projectId, changes, changeRequestId); } @NotNull diff --git a/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterService.java b/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterService.java index 76bfafde8..0e2c02342 100644 --- a/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterService.java +++ b/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterService.java @@ -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); + void emitNewRevisionsEvent(Optional revision, ChangeRequestId changeRequestId); } diff --git a/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterServiceImpl.java b/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterServiceImpl.java index 7069f3fb8..e02a9958d 100644 --- a/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterServiceImpl.java +++ b/src/main/java/edu/stanford/protege/webprotege/revision/uiHistoryConcern/NewRevisionsEventEmitterServiceImpl.java @@ -28,13 +28,13 @@ public NewRevisionsEventEmitterServiceImpl(ProjectChangesManager changesManager, @Override - public void emitNewRevisionsEvent(Optional revision) { + public void emitNewRevisionsEvent(Optional revision, ChangeRequestId changeRequestId) { revision.ifPresent(rev -> { Set 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); }); } From 2ce5a632773f1b2863b116a6e40f93e8f3289761 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 11 Dec 2024 12:39:51 +0000 Subject: [PATCH 2/2] Bump version to 2.0.11-WHO --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c9addbdb3..bcd0710b3 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ edu.stanford.protege webprotege-backend-service - 2.0.10-WHO + 2.0.11-WHO UTF-8